How to make circle Gradient color button in Flutter | Flutter
858
You can use a FloatingActionButton
for this:
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: () {},
),
);
}
}
Author by
Murali Krishnan
Updated on December 27, 2022Comments
-
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.
-
milan pithadia about 3 yearsstackoverflow.com/questions/52243364/… please check this is usefull for you
-
Shubham Narkhede about 3 yearsYou may need to use of
RadialGradient
-