简体   繁体   English

Flutter - SliverAppBar 中的圆角

[英]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在 Flutter 中,您可以在AppBar小部件中使用shape属性自定义形状,但SliverAppBar小部件中缺少此属性

  AppBar(
    title: Text('Hello'),
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.vertical(
        bottom: Radius.circular(30),
      ),
    ),
  ),

how to have rounded corners in SliverAppBar ?如何在SliverAppBar 中圆角

在此处输入图片说明

In Flutter you can have custom shape in AppBar widget with shape property, but this property is missing in SliverAppBar widget在Flutter中,您可以在带有形状属性的AppBar小部件中具有自定义形状,但是SliverAppBar小部件中缺少此属性

  AppBar(
    title: Text('Hello'),
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.vertical(
        bottom: Radius.circular(30),
      ),
    ),
  ),

how to have rounded corners in SliverAppBar ?如何在SliverAppBar中圆角

在此处输入图片说明

In Flutter you can have custom shape in AppBar widget with shape property, but this property is missing in SliverAppBar widget在Flutter中,您可以在带有形状属性的AppBar小部件中具有自定义形状,但是SliverAppBar小部件中缺少此属性

  AppBar(
    title: Text('Hello'),
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.vertical(
        bottom: Radius.circular(30),
      ),
    ),
  ),

how to have rounded corners in SliverAppBar ?如何在SliverAppBar中圆角

在此处输入图片说明

In Flutter you can have custom shape in AppBar widget with shape property, but this property is missing in SliverAppBar widget在Flutter中,您可以在带有形状属性的AppBar小部件中具有自定义形状,但是SliverAppBar小部件中缺少此属性

  AppBar(
    title: Text('Hello'),
    shape: RoundedRectangleBorder(
      borderRadius: BorderRadius.vertical(
        bottom: Radius.circular(30),
      ),
    ),
  ),

how to have rounded corners in SliverAppBar ?如何在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. SliverAppBar 小部件中没有缺少此属性,它就像 AppBar 小部件,但您不需要 Scaffold 小部件中的“appBar:”属性,您需要“body:”属性,并且必须在其上添加 CustomScrollView 小部件,并在“slivers:”中属性,您可以添加从 SliverAppBar 开始的小部件列表,并且您可以根据需要添加 SliverList、SliverGrid,我试过了,它完成了,这是我的代码。 Scaffold( body: CustomScrollView( slivers: [ SliverAppBar( expandedHeight: 180, title: Text('RoundedRectangleBorder'), shape: RoundedRectangleBorder( borderRadius: BorderRadius.vertical( bottom: Radius.circular(40), ), ), ), ], ), ); Scaffold( body: CustomScrollView( slivers: [ SliverAppBar( expandHeight: 180, title: Text('RoundedRectangleBorder'), shape: RoundedRectangleBorder( borderRadius: BorderRadius.vertical(bottom: Radius.circular(40), ), ), ), ] , ), );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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