Create a groove button in flutter? - flutter

Is it posible to make a button like the image? It doesn't need to be circular just is there anyway to gice that groove effect to a raised button and text field areas in Flutter?
Also link of the image is "https://css-tricks.com/circular-3d-buttons/"
This is made by css, if there is any trick to do it with material design maybe css import for such a work?

You can get a pretty similar result by using a RawMaterialButton and a decorated Container.
Container(
padding: EdgeInsets.all(10),
decoration: new BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
stops: [0.0 , 0.5, 1.0],
colors: [Colors.white, Colors.white, Colors.grey[200]]
)
),
child: RawMaterialButton(
onPressed: () {},
child: new Icon(
Icons.settings,
color: Colors.grey[600],
size: 28.0,
),
shape: new CircleBorder(),
elevation: 2.0,
fillColor: Colors.white,
padding: const EdgeInsets.all(18.0),
)
);

Try this
new RawMaterialButton(
onPressed: () {},
child: new Icon(
Icons.pause,
color: Colors.blue,
size: 35.0,
),
shape: new CircleBorder(),
elevation: 2.0,
fillColor: Colors.white,
padding: const EdgeInsets.all(15.0),
),

Related

Problem with floating action button It's notched is not visible

Hello Guys I have a problem with my bottom navigation bar. The problem is that I created a stack, in that there is a container with gradient color and then there is a bottomAppBar, I made the bottomAppBar color transparent. I actual problem is that I have a centerDocked floating action button and it's margin is 5. Because of container my floating action button notched is not visible is there any possibility that I have the gradient color along with notch below floating action button? I hope you understand my problem.
floatingActionButton: FloatingActionButton(
//backgroundColor: Color(0XFFFF4F5A),
backgroundColor: Colors.black87,
onPressed: () {},
child: const Icon(
Icons.camera_alt,
color: Colors.white,
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: Stack(
children: [
Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0XFFFF1C2A),
Color(0XFFFF4F5A),
],
),
),
height: 48,
),
BottomAppBar(
elevation: 0,
color: Colors.transparent,
shape: CircularNotchedRectangle(),
notchMargin: 5,
child: Padding(
padding: EdgeInsets.only(left: 25, right: 25),
child ...
),
)
],
)
Try this way
bottomNavigationBar: BottomAppBar(
elevation: 0,
color: Colors.transparent,
shape: CircularNotchedRectangle(),
notchMargin: 5,
clipBehavior: Clip.hardEdge,
child: Container(
height: kToolbarHeight,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0XFFFF1C2A),
Color(0XFFFF4F5A),
],
),
),
child: Padding(
padding: EdgeInsets.only(left: 25, right: 25),
child: Text("tada"),
),
)),
Add clipBehavior to BottomAppBar will make it work:
clipBehavior: Clip.antiAlias, // or Clip.hardEdge

How do you give a CircleAvatar multiple border colors in Flutter?

I'm wondering if there is a simple way to give a circle avatar multiple border colors in Flutter.
Bonus if you could set the % you want each color to fill.
Here is an image of what I mean, but note it wasn't that easy to do in Figma, hence the blurring of the colors. Color blending actually would not be the preferred behavior.
This is what came to my mind. You can change the color list to match the Figma gradient.
Container(
height: 80,
width: 80,
decoration: const BoxDecoration(
gradient: LinearGradient(colors: [
Colors.green,
Colors.yellow,
Colors.red,
Colors.purple
]),
shape: BoxShape.circle),
child: Padding(
//this padding will be you border size
padding: const EdgeInsets.all(3.0),
child: Container(
decoration: const BoxDecoration(
color: Colors.white, shape: BoxShape.circle),
child: const CircleAvatar(
backgroundColor: Colors.white,
foregroundImage: NetworkImage("https://i.ibb.co/rkG8cCs/112921315-gettyimages-876284806.jpg"),
),
),
),
),
Here is your solution,
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomLeft,
colors: [
Color(0XFF8134AF),
Color(0XFFDD2A7B),
Color(0XFFFEDA77),
Color(0XFFF58529),
],
),
shape: BoxShape.circle
),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle
),
margin: EdgeInsets.all(2),
child: Padding(
padding: const EdgeInsets.all(3.0),
child: CircleAvatar(
radius: 25,
backgroundColor: Colors.grey,
backgroundImage: NetworkImage(reels[i].image)
),
),
),
),

What is the proper way to style Flutter RaisedButton?

Currently I am styling it using
MaterialApp(
theme: ThemeData(
buttonTheme: ButtonThemeData(
buttonColor: Colors.blueAccent,
shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20) ),
textTheme: ButtonTextTheme.primary
)
)
)
But it is insane to assume that there is only one style apply to all buttons in the entire apps.
Currently I have 4 type of styles which to apply to RaisedButton, and can't figure out a good way of doing so. It is also a bit of hassle to subclass RaisedButton for each and every styles.
You can access the parameters for RaisedButton
RaisedButton(
onPressed: () {},
textColor: Colors.white,
padding: const EdgeInsets.all(0.0),
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: <Color>[
Color(0xFF0D47A1),
Color(0xFF1976D2),
Color(0xFF42A5F5),
],
),
),
padding: const EdgeInsets.all(10.0),
child:
const Text('Gradient Button', style: TextStyle(fontSize: 20)),
),
),

How to add a border color to an OutlineButton

How can I add a border color to an OutlineButton? I tried setting a highlightedBorderColor, but it is not working. How can I solve this issue?
This is my code:
OutlineButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
onPressed:(){},child: Padding(
padding: const EdgeInsets.all(12),
child: Text("add to cart",style: TextStyle(color: Colors.red,fontSize: 20),),
),highlightedBorderColor: Colors.red,
),
Add the following line to your code:
borderSide: BorderSide(width: 2.0, color: Colors.red),
This should change the border color of your button to red
Take a try with it:
OutlineButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
borderSide: BorderSide(color: Colors.pink, width: 1),
onPressed: () {},
child: Padding(
padding: const EdgeInsets.all(12),
child: Text(
"add to cart",
style: TextStyle(color: Colors.red, fontSize: 20),
),
),
)

Flutter :- Create circular border around icons

I want to create circular borders around the icons as shown in the image.
Container(
margin: EdgeInsets.all(20),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: Colors.white,
border: Border.all(
width: 2
)
),
child: Icon(Icons.arrow_downward,color: Colors.white,),
)
I don't need cuts in the circular borders as they are shown in the image but the complete circular border, I have also tried this code =>This Answer
I am doing some mistakes in my above code. but I have figured out and here is the new code.
Container(
margin: EdgeInsets.all(20),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
border: Border.all(width: 2, color: Colors.white)),
child: Icon(
Icons.cancel,
color: Colors.white,
),
)),
Also if you want to make complete Widget clickable then you can use it like this.
GestureDetector(
onTap: () {
//Navigator.of(context).pop();
},
child: new Align(
alignment: Alignment.bottomRight,
child: Container(
margin: EdgeInsets.all(20),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
border: Border.all(width: 2, color: Colors.white)),
child: Icon(
Icons.cancel,
color: Colors.white,
),
)),
),
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: Colors.white)
),
child: Icon(Icons.check, color: Colors.white,),
)
or you can use Material if you're going to need some fancy effects:
Material(
color: Colors.transparent,
shape: CircleBorder(
side: BorderSide(color: Colors.white)
),
child: Icon(Icons.check, color: Colors.white,),
)
Updated: OutlinedButton (instead of deprecated OutlineButton)
OutlinedButton(
onPressed: () {},
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100),
side: BorderSide(color: Colors.green),
)),
),
child: Icon(Icons.print, color: Colors.green),
)
Original response:
I think that the easiest way is to use an OutlineButton:
OutlineButton(
onPressed: () { },
shape: CircleBorder(),
borderSide: BorderSide(color: Colors.green),
child: Icon(Icons.print, color: Colors.green),
)
You can also go with FloatingActionButton.