代码之家  ›  专栏  ›  技术社区  ›  Ampersanda

拆下杯托上的衬垫发货导航栏

  •  1
  • Ampersanda  · 技术社区  · 7 年前

    我正在尝试使用 cupertinosdelivernavigationbar ,实际上它很好,但出于某种原因,我不能将右后角放在导航栏的末尾。我查了一下,发现里面有 填充物

    这是我的密码

    新Cupertinopagescaffold( 子级:新建自定义滚动视图( 长条:<小工具>。[ 新的CupertinosDeliverNavigationBar( largetitle:新文本(“任务”), 尾随:新Cupertinobutton( 子:新图标(additionalCupertinicons.compose,大小:32.0) 按下时:(){ 显示对话框( 上下文:上下文, 生成器:(BuildContext上下文){ 返回new cupertinoalertDialog(); })(二) },请 填充:edgeinsets.all(0.0), ),请 ) ],请 ),请 ),请 Padding 在里面

    enter image description here

    这是我的密码

       new CupertinoPageScaffold(
            child: new CustomScrollView(
              slivers: <Widget>[
                new CupertinoSliverNavigationBar(
                  largeTitle: new Text('Tasks'),
                  trailing: new CupertinoButton(
                    child: new Icon(AdditionalCupertinoIcons.compose, size: 32.0),
                    onPressed: () {
                      showDialog(
                          context: context,
                          builder: (BuildContext context) {
                            return new CupertinoAlertDialog();
                          });
                    },
                    padding: EdgeInsets.all(0.0),
                  ),
                )
              ],
            ),
          ),
    
    2 回复  |  直到 6 年前
        1
  •  1
  •   creativecreatorormaybenot    7 年前

    可悲的是,没有 可以 .

    看着 this line of source code ,您可以看到他们正在使用 Padding 最后,就是 _kNavBarEdgePadding ,即 16.0 .同样适用于 start .

    这意味着 CupertinoSliverNavigationBar 您将无法删除 衬垫 因为没有访问点来更改它。您必须创建 自己的小工具 为了这个。

    这个 _CupertinoPersistentNavigationBar widget 包含 衬垫 并且被 铜离子传送导航栏 尽可能 seen here 为了完成 here .

        2
  •  0
  •   Dominik Dassow    6 年前

    有一种简单的方法可以在屏幕上移动小部件:

    Widget _adjustNavigationBarButtonPosition(Widget button, double x) {
        if (button == null) return null;
    
        return Container(
            transform: Matrix4.translationValues(x, 0, 0),
            child: button,
        );
    }
    

    使用此方法包装cupertinobutton并指定偏移量。要完全删除填充,偏移量应为 16.0 .