简体   繁体   English

有什么办法可以在短时间内剪辑应用栏?

[英]is there any way to clip an appbar in flutter?

I'm trying to clip two of the appbars corners. 我正在尝试修剪两个appbars角落。 I unfortunately can't find anything and I was wondering if there's a work around. 不幸的是我找不到任何东西,我想知道是否有解决方法。 Or, possibly if somebody would be kind enough to help me by breaking into Appbar's original code and modifying in some way to clip it. 或者,也许有人会友好地闯入Appbar的原始代码并以某种方式进行修改以裁剪它,以帮助我。

For those who don't want to use Master channel & are on stable channel - other workaround is using - ClipRRect 对于那些不想使用Master channel并且在stable channel -使用其他解决方法ClipRRect

Scaffold(
                appBar: PreferredSize(
                  preferredSize: Size.fromHeight(kToolbarHeight),
                  child: ClipRRect(
                    clipBehavior: Clip.antiAlias,
                    borderRadius: BorderRadius.only(
                        bottomLeft: Radius.circular(20.0),
                        bottomRight: Radius.circular(20.0)),
                    child: AppBar(
                      centerTitle: true,
                      title: Text(title),
                    ),
                  ),
                ),

在此处输入图片说明

You might look for the shapeBorder option added with https://github.com/flutter/flutter/pull/21834 您可能会寻找https://github.com/flutter/flutter/pull/21834添加的shapeBorder选项

  const RoundedRectangleBorder roundedRectangleBorder = RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(15.0)));

  MaterialApp(
    home: AppBar(
      leading: const Text('L'),
      title: const Text('No Scaffold'),
      shape: roundedRectangleBorder,
      actions: const <Widget>[Text('A1'), Text('A2')],
    ),
  ),

It seems this is only available in master yet and not shown in the docs. 看来这仅在master可用,而未在文档中显示。

flutter channel master
flutter doctor

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

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