Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Rounded corners in SliverAppBar

Tags:

flutter

dart

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?

enter image description here

like image 783
Tiziano Munegato Avatar asked Apr 24 '19 09:04

Tiziano Munegato


People also ask

How do you curve the edges of AppBar in Flutter?

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.

How do you make the border of image is rounded in Flutter?

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 the AppBar in Flutter?

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.


1 Answers

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'),
);
like image 68
Simran Singh Avatar answered Oct 14 '22 18:10

Simran Singh