Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.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
Flutter 定义floatingActionButtonLocation时,如何使用堆栈添加FAB?_Flutter - Fatal编程技术网

Flutter 定义floatingActionButtonLocation时,如何使用堆栈添加FAB?

Flutter 定义floatingActionButtonLocation时,如何使用堆栈添加FAB?,flutter,Flutter,在我的应用程序中,我定义了一个FAB,其属性floatingActionButtonLocation设置为floatingActionButtonLocation.centerDocked。我已经定义了一个底部应用程序栏,用于容纳中心对接的晶圆厂。我还想使用堆栈小部件在屏幕右上角定位另外两个晶圆厂。它应该看起来像这样- 但是,当我尝试使用堆栈时,底部应用程序栏中的FAB会显示出来,但是Stack小部件下的两个FAB是不可见的 我已定义堆栈的代码 return new Scaffold(

在我的应用程序中,我定义了一个FAB,其属性
floatingActionButtonLocation
设置为
floatingActionButtonLocation.centerDocked
。我已经定义了一个底部应用程序栏,用于容纳中心对接的晶圆厂。我还想使用
堆栈
小部件在屏幕右上角定位另外两个晶圆厂。它应该看起来像这样-

但是,当我尝试使用
堆栈时,底部应用程序栏中的FAB会显示出来,但是Stack小部件下的两个FAB是不可见的

我已定义
堆栈的代码

 return new Scaffold(
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
        floatingActionButton: Stack(
          children: <Widget>[
         Positioned(

           // the below values for stack are experimental at the moment

           left: MediaQuery.of(context).copyWith().size.width * 0.60,
           right: MediaQuery.of(context).copyWith().size.width * 0.01,
//           top: MediaQuery.of(context).copyWith().size.height * 0.20,
//           bottom: MediaQuery.of(context).copyWith().size.height * 0.7,
           child: Row(
             children: <Widget>[

               // invisible FABs

               FloatingActionButton(
                 onPressed: (){
                   _animate2Pagenegative();
//              print(widget.date);
                 },
                 child: Icon(Icons.fast_rewind),
                 heroTag: UniqueKey(),
               ),
               FloatingActionButton(
                 onPressed: (){
                   _animate2Pageforward();
//              print(widget.date);
                 },
                 heroTag: UniqueKey(),
                 child: Icon(Icons.fast_forward),
               ),
             ],
           ),
         ),

            // FAB which is displayed correctly
            FloatingActionButton(
              backgroundColor: Colors.red,
              onPressed: () async{
                String result1 =   await Navigator.push( // string which stores the user entered value
                    context,
                    MaterialPageRoute(
                      builder: (context) => InputScreen(), //screen which has TextField
                    ));
                setState(() {
                  addItem(result1, false, "");
                });
              },
              tooltip: 'Add a task',
              child: Icon(Icons.add),
              elevation: 0.0,
            ),
          ],
        ),
)
返回新脚手架(
floatingActionButtonLocation:floatingActionButtonLocation.centerDocked,
浮动操作按钮:堆栈(
儿童:[
定位(
//下面的堆栈值是目前的实验值
左:MediaQuery.of(context).copyWith().size.width*0.60,
右:MediaQuery.of(context).copyWith().size.width*0.01,
//顶部:MediaQuery.of(context).copyWith().size.height*0.20,
//底部:MediaQuery.of(context).copyWith().size.height*0.7,
孩子:排(
儿童:[
//隐形晶圆厂
浮动操作按钮(
已按下:(){
_动画2页负();
//打印(widget.date);
},
子:图标(图标。快退),
heroTag:UniqueKey(),
),
浮动操作按钮(
已按下:(){
_动画2页面前进();
//打印(widget.date);
},
heroTag:UniqueKey(),
子:图标(图标。快进),
),
],
),
),
//正确显示的晶圆厂
浮动操作按钮(
背景颜色:Colors.red,
onPressed:()异步{
String result1=await Navigator.push(//存储用户输入值的字符串
上下文
材料路线(
生成器:(上下文)=>InputScreen(),//包含TextField的屏幕
));
设置状态(){
附加项(结果1,假“”;
});
},
工具提示:“添加任务”,
子:图标(Icons.add),
标高:0.0,
),
],
),
)
脚手架主体:

  body: new Column(
          children: <Widget>[
            new Expanded(
              child: new DaysPageView(
//                onDaysChanged: getDatestring,
                physics: new NeverScrollableScrollPhysics(),
                dayoverride: getDate(widget.date),
                scrollDirection: _scrollDirection,
                pageSnapping: _pageSnapping,
                reverse: _reverse,
                controller: _daysPageController,
                pageBuilder: _daysPageBuilder,
              ),
            ),
          ],
        ),
body:新列(
儿童:[
新扩展(
孩子:新的DaysPageView(
//onDaysChanged:getDatestring,
物理学:新NeverscrollableScroll物理学(),
dayoverride:getDate(widget.date),
滚动方向:_滚动方向,
页面捕捉:_页面捕捉,
反向:_反向,
控制器:_daysPageController,
页面生成器:_daysPageBuilder,
),
),
],
),

您不需要其他floatingActionsButton来完成该设计。我的理解是,你需要上半部分不滚动的内容,因此你认为晶圆厂。实现这一目标有多种方法。下面是一个例子,我用颜色显示屏幕的不同部分。当然,这些都是随机大小来显示情况

return new Scaffold(
      body: Column(
        children: <Widget>[
          Container(
            height: 150,
            color: Colors.red,
          ),
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              Container(
                margin: EdgeInsets.only(top: 20, left: 20),
                child: Text(
                  "- 2 TASKS MORE",
                  style: TextStyle(
                    fontSize: 35
                  ),
                ),
              ),
              GestureDetector(
                onTap: () {
                  print('left arrow pressed');
                },
                child: Container(
                    margin: EdgeInsets.only(top: 20, left: 20),
                    child: Icon(Icons.arrow_left)
                ),
              ),
              GestureDetector(
                onTap: () {
                  print('right arrow pressed');
                },
                child: Container(
                    margin: EdgeInsets.only(top: 20, left: 20),
                    child: Icon(Icons.arrow_right)
                ),
              )
            ],
          ),
          SingleChildScrollView(
            physics: AlwaysScrollableScrollPhysics(),
            child: Column(
              children: <Widget>[
                Container(
                  height: 600,
                  color: Colors.deepPurpleAccent,
                ),
              ],
            ),
          )
        ],
      ),
      bottomNavigationBar: BottomAppBar(
        child: Row(
          mainAxisSize: MainAxisSize.max,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[

          ],
        ),
        shape: CircularNotchedRectangle(),
        color: Colors.red,
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      floatingActionButton: FloatingActionButton(
        backgroundColor: Colors.red,
        onPressed: ()
        async {
          print('FAB pressed');
        },
        tooltip: 'Add a task',
        child: Icon(Icons.add),
        elevation: 0.0,
      ),
    );
返回新脚手架(
正文:专栏(
儿童:[
容器(
身高:150,
颜色:颜色,红色,
),
划船(
crossAxisAlignment:crossAxisAlignment.center,
儿童:[
容器(
页边距:仅限边集(顶部:20,左侧:20),
子:文本(
“-2项以上任务”,
样式:TextStyle(
尺码:35
),
),
),
手势检测器(
onTap:(){
打印(“按下左箭头”);
},
子:容器(
页边距:仅限边集(顶部:20,左侧:20),
子:图标(图标。向左箭头)
),
),
手势检测器(
onTap:(){
打印(“按下右箭头”);
},
子:容器(
页边距:仅限边集(顶部:20,左侧:20),
子:图标(图标。向右箭头)
),
)
],
),
SingleChildScrollView(
物理:AlwaysScrollableScrollPhysics(),
子:列(
儿童:[
容器(
身高:600,
颜色:颜色。深紫色,
),
],
),
)
],
),
bottomNavigationBar:BottomAppBar(
孩子:排(
mainAxisSize:mainAxisSize.max,
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
],
),
形状:CircularNotchedRectangle(),
颜色:颜色,红色,
),
floatingActionButtonLocation:floatingActionButtonLocation.centerDocked,
浮动操作按钮:浮动操作按钮(
背景颜色:Colors.red,
已按下:()
异步的{
印刷品(‘工厂印刷’);
},
工具提示:“添加任务”,
子:图标(Icons.add),
标高:0.0,
),
);
结果如下


这不是你提问的方式。你应该在你的代码上下功夫,把你到目前为止所做的事情放在这里。阅读帮助中心主题,了解有关您可以提出哪些问题以及必须避免的问题类型的更多信息。