简体   繁体   中英

Flutter - Rounded corners in SliverAppBar

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 ?

在此处输入图片说明

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 ?

在此处输入图片说明

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 ?

在此处输入图片说明

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 ?

在此处输入图片说明

this property is not missing in SliverAppBar widget it's like AppBar Widget but you don't need to 'appBar:' property in Scaffold Widget, you need 'body:' property and on it you must add CustomScrollView Widget, and in 'slivers:' property you can add list of Widgets starting from SliverAppBar, and as you like you can add SliverList, SliverGrid, I tried that and it's done, this is my code. Scaffold( body: CustomScrollView( slivers: [ SliverAppBar( expandedHeight: 180, title: Text('RoundedRectangleBorder'), shape: RoundedRectangleBorder( borderRadius: BorderRadius.vertical( bottom: Radius.circular(40), ), ), ), ], ), );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM