Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 如何在颤振中不使用AppBar添加后退按钮?_User Interface_Flutter_Dart_Back Button_Appbar - Fatal编程技术网

User interface 如何在颤振中不使用AppBar添加后退按钮?

User interface 如何在颤振中不使用AppBar添加后退按钮?,user-interface,flutter,dart,back-button,appbar,User Interface,Flutter,Dart,Back Button,Appbar,我想在appBar上添加一个后退按钮,并想使appBar透明,以便它只显示后退按钮 只需将您的小部件包装到堆栈中,然后在堆栈顶部添加一个图标按钮,并在按钮onPressed()上弹出(上下文)。 那应该能解决你的问题 return Stack( alignment: Alignment.topLeft, children: <Widget>[ YourScrollViewWidget(), IconButton( icon: I

我想在appBar上添加一个后退按钮,并想使appBar透明,以便它只显示后退按钮


只需将您的小部件包装到堆栈中,然后在堆栈顶部添加一个图标按钮,并在按钮onPressed()上弹出(上下文)。 那应该能解决你的问题

return Stack(
    alignment: Alignment.topLeft,
    children: <Widget>[
      YourScrollViewWidget(),
      IconButton(
        icon: Icon(Icons.arrow_back),
        onPressed: (){
          Navigator.pop(context);
        },
      )
    ],
  );
返回堆栈(
对齐:alignment.topLeft,
儿童:[
YourScrollViewWidget(),
图标按钮(
图标:图标(图标。箭头返回),
已按下:(){
Navigator.pop(上下文);
},
)
],
);

Simran,这有点棘手,但如果将
堆栈
SingleChildScrollView
AppBar
结合使用,这是可能的。下面是一个快速的例子来说明这一点

return Scaffold(
              body: Stack(children: <Widget>[
                Container(
                  color: Colors.white,// Your screen background color
                ),
                SingleChildScrollView(
                    child: Column(children: <Widget>[
                      Container(height: 70.0),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                    ])
                ),
                new Positioned(
                  top: 0.0,
                  left: 0.0,
                  right: 0.0,
                  child: AppBar(
                    title: Text(''),// You can add title here
                    leading: new IconButton(
                      icon: new Icon(Icons.arrow_back_ios, color: Colors.grey),
                      onPressed: () => Navigator.of(context).pop(),
                    ),
                    backgroundColor: Colors.blue.withOpacity(0.3), //You can make this transparent
                    elevation: 0.0, //No shadow
                  ),),
              ]),
              );
返回脚手架(
主体:堆栈(子对象:[
容器(
颜色:Colors.white,//您的屏幕背景色
),
SingleChildScrollView(
子项:列(子项:[
集装箱(高度:70.0),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
buildRow('这是测试行'),
])
),
新定位(
排名:0.0,
左:0.0,
右:0.0,
孩子:AppBar(
title:Text(“”),//您可以在此处添加标题
领先:新图标按钮(
图标:新图标(Icons.arrow\u back\u ios,颜色:Colors.grey),
onPressed:()=>Navigator.of(context.pop(),
),
backgroundColor:Colors.blue.withOpacity(0.3),//您可以使其透明
标高:0.0,//无阴影
),),
]),
);

注意:您可以使
AppBar
完全透明。然而,您需要相应地设计小部件,以确保后退按钮可见。在上面的例子中,我只是设置了不透明度


希望这有帮助。祝你好运

这不允许我按下并滚动滚动滚动视图。还有其他建议吗?您是否尝试将堆栈的fit属性添加为StackFit.loose?或者尝试将图标包装到Align小部件中,并将对齐方式设置为alignment.topLeft