How to make circle Gradient color button in Flutter | Flutter

858

You can use a FloatingActionButton for this:

enter image description here

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      home: MyWidget(),
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: FloatingActionButton(
        child: Container(
          width: 60,
          height: 60,
          child: Icon(Icons.add),
          decoration: BoxDecoration(
            shape: BoxShape.circle,
            gradient: LinearGradient(
              colors: [Color(0xff43cea2), Color(0xff185a9d)],
            ),
          ),
        ),
        onPressed: () {},
      ),
    );
  }
}
Share:
858
Murali Krishnan
Author by

Murali Krishnan

Updated on December 27, 2022

Comments

  • Murali Krishnan
    Murali Krishnan over 1 year
    ConstrainedBox(
                    constraints: BoxConstraints.tightFor(width: 60, height: 60),
                    child: ElevatedButton(
                      child: Text(
                        'GO',
                        style: TextStyle(fontSize: 18),
                      ),
                      onPressed: () {},
                      style: ElevatedButton.styleFrom(
                        shape: CircleBorder(),
                      ),
                    ),
                  ),
    

    Iam trying to create a gradient circle shaped button, but in this code it creates rounded circle button but how i add gradient color to it.