In Flutter you can have custom shape in AppBar widget with shape property, but this property is missing in SliverAppBar widget
AppBar(
title: Text('Hello'),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30),
),
),
),
how to have rounded corners in SliverAppBar?
You can use BoxDecoration to add border radius and shadow to a Container/DecoratedBox. You can also create a custom widget using below code snippet. In Flutter, you can have a custom shape in the AppBar Widget with shape property. AppBar( title: Text('My App'), shape: RoundedRectangleBorder( borderRadius: BorderRadius.
To add a border radius or create a rounded border around the image, you can wrap the image widget inside the Container widget. Inside the Container, add the decoration parameter and then the BoxDecoration. You can use the BoxDecoration to set the border to Border. all(width: 5) and and borderRadius to BorderRadius.
How do you add a border to an icon in Flutter? Replace the IconButton widget with the Material widget. Inside the Material widget, set type to MaterialType. Inside the Ink widget, add the decoration property and assign the Boxdecoration with border parameter set to Border.
This is the right and easy way to change the shape of a SliverAppBar (As mentioned in Flutter docs). No need you use any tricks. Even you can shape it as any shape you want.
SliverAppBar(
shape: ContinuousRectangleBorder(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(30), bottomRight: Radius.circular(30))),
title: Text('Sliver AppBar'),
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With