Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.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 颤振中浮动动作按钮的放置_Flutter_Dart_Flutter Layout - Fatal编程技术网

Flutter 颤振中浮动动作按钮的放置

Flutter 颤振中浮动动作按钮的放置,flutter,dart,flutter-layout,Flutter,Dart,Flutter Layout,我正在制作这样的屏幕视图。我想要的是,当它在“药物”选项卡上时,它应该在角落处显示一个浮动操作按钮,如图所示 对于历史选项卡,它应该消失。就像这张照片一样 我的代码是: import 'package:epicare/HomeScreen.dart'; import 'package:flutter/material.dart'; class Medicines extends StatefulWidget { @override _MedicinesState createSta

我正在制作这样的屏幕视图。我想要的是,当它在“药物”选项卡上时,它应该在角落处显示一个浮动操作按钮,如图所示

对于历史选项卡,它应该消失。就像这张照片一样

我的代码是:

import 'package:epicare/HomeScreen.dart';
import 'package:flutter/material.dart';

class Medicines extends StatefulWidget {
  @override
  _MedicinesState createState() => _MedicinesState();
}

class _MedicinesState extends State<Medicines> with TickerProviderStateMixin {
  TabController _tabController;
  @override
  void initState() {
    _tabController = TabController(length: 2, vsync: this);
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
    _tabController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        backgroundColor: const Color(0xffE5E0A1),
        elevation: 0,
        centerTitle: true,
        title: Text(
          "Medicine",
          style: TextStyle(
            fontSize: 15.0,
            color: Colors.black,
            fontFamily: 'Montserrat',
            fontWeight: FontWeight.normal,
          ),
        ),
        leading: IconButton(
          icon: Icon(
            Icons.arrow_back,
            color: Colors.black,
          ),
          onPressed: () {
            Navigator.push(
              context,
              MaterialPageRoute(
                builder: (context) {
                  return HomeScreen();
                },
              ),
            );
          },
        ),
      ),
      body: Padding(
        padding: const EdgeInsets.only(top: 32,right: 32,left: 32),
        child: Column(
          children: [
            // give the tab bar a height [can change height to preferred height]
            Container(
              height: 45,
              decoration: BoxDecoration(
                color: const Color(0xffE5E0A1),
                borderRadius: BorderRadius.circular(
                  17.0,
                ),
                border: Border.all(
                    width: 1.0, color: const Color(0xff2f363d)),
              ),
              child: TabBar(
                controller: _tabController,
                // give the indicator a decoration (color and border radius)
                indicator: BoxDecoration(
                  borderRadius: BorderRadius.circular(
                    17.0,
                  ),
                  color: Colors.black,
                ),
                labelColor: const Color(0xffd4d411),
                unselectedLabelColor: Colors.black,
                tabs: [
                  // first tab [you can add an icon using the icon property]
                  Tab(
                    child: Text(
                      'Medicine',
                      style: TextStyle(
                        fontFamily: 'Montserrat',
                        fontSize: 16,
                        //color: const Color(0xffd4d411),
                        letterSpacing: 0.48,
                      ),
                      textAlign: TextAlign.left,
                    ),
                  ),

                  // second tab [you can add an icon using the icon property]
                  Tab(
                    child: Text(
                      'History',
                      style: TextStyle(
                        fontFamily: 'Montserrat',
                        fontSize: 16,
                        //color: const Color(0xffd4d411),
                        letterSpacing: 0.48,
                      ),
                      textAlign: TextAlign.left,
                    ),
                  ),
                ],
              ),
            ),
            // tab bar view her
            Expanded(
              child: TabBarView(
                controller: _tabController,
                children: [
                  // first tab bar view widget
                  Column(
                    children: [
                      Image.asset(("assets/images/Medicine-amico.png")),
                      SizedBox(
                        height: 20,
                      ),
                      Text(
                        'Hurray! You don\'t have any pending medicines to take!',
                        style: TextStyle(
                          fontFamily: 'Montserrat',
                          fontWeight: FontWeight.w600,
                          fontSize: 14,
                          color: const Color(0x78000000),
                          height: 1.4285714285714286,
                        ),
                        textAlign: TextAlign.center,
                      ),
                    ],

                  ),

                  // second tab bar view widget
                  Column(
                    children: [
                      Image.asset(("assets/images/Time management-pana.png")),
                      Text(
                        'You have no data here!\nPlease complete your prescriptions',
                        style: TextStyle(
                          fontFamily: 'Montserrat',
                          fontWeight: FontWeight.w600,
                          fontSize: 14,
                          color: const Color(0x78000000),
                          height: 1.4285714285714286,
                        ),
                        textAlign: TextAlign.center,
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
      // floatingActionButton: FloatingActionButton(
      //   child: Icon(
      //     Icons.add,
      //     size: 40,
      //   ),
      //   backgroundColor: const Color(0xffd4d411),
      //   onPressed: () {},
      // ),
    );
  }

  Widget addmedicine() {
    return FloatingActionButton(
        child: Icon(
            Icons.add,
            size: 40,
          ),
          backgroundColor: const Color(0xffd4d411),
          onPressed: () {},
    );
  }
}
import'软件包:epicare/HomeScreen.dart';
进口“包装:颤振/材料.省道”;
类扩展StatefulWidget{
@凌驾
_MedicineState createState()=>\u MedicineState();
}
类_MedicinesState使用TickerProviderStateMixin扩展状态{
TabController\u TabController;
@凌驾
void initState(){
_tabController=tabController(长度:2,vsync:this);
super.initState();
}
@凌驾
无效处置(){
super.dispose();
_tabController.dispose();
}
@凌驾
小部件构建(构建上下文){
返回脚手架(
背景颜色:Colors.white,
appBar:appBar(
背景颜色:常量颜色(0xffE5E0A1),
海拔:0,
标题:对,
标题:正文(
“医学”,
样式:TextStyle(
字体大小:15.0,
颜色:颜色,黑色,
fontFamily:“蒙特塞拉特”,
fontWeight:fontWeight.normal,
),
),
领先:IconButton(
图标:图标(
Icons.arrow_back,
颜色:颜色,黑色,
),
已按下:(){
导航器。推(
上下文
材料路线(
生成器:(上下文){
返回主屏幕();
},
),
);
},
),
),
主体:填充物(
填充:仅限常量边集(顶部:32,右侧:32,左侧:32),
子:列(
儿童:[
//为选项卡栏指定高度[可以将高度更改为首选高度]
容器(
身高:45,
装饰:盒子装饰(
颜色:常量颜色(0xffE5E0A1),
borderRadius:borderRadius.circular(
17.0,
),
边界:边界(
宽度:1.0,颜色:常量颜色(0xff2f363d)),
),
孩子:TabBar(
控制器:\ tab控制器,
//对指示器进行装饰(颜色和边框半径)
指标:盒子装饰(
borderRadius:borderRadius.circular(
17.0,
),
颜色:颜色,黑色,
),
labelColor:const Color(0xFFD4411),
未选择的标签颜色:Colors.black,
选项卡:[
//第一个选项卡[可以使用图标属性添加图标]
标签(
子:文本(
"药",,
样式:TextStyle(
fontFamily:“蒙特塞拉特”,
尺寸:16,
//颜色:常量颜色(0xFFD411),
字母间距:0.48,
),
textAlign:textAlign.left,
),
),
//第二个选项卡[可以使用icon属性添加图标]
标签(
子:文本(
"历史",,
样式:TextStyle(
fontFamily:“蒙特塞拉特”,
尺寸:16,
//颜色:常量颜色(0xFFD411),
字母间距:0.48,
),
textAlign:textAlign.left,
),
),
],
),
),
//选项卡栏查看她
扩大(
子项:选项卡视图(
控制器:\ tab控制器,
儿童:[
//第一个选项卡栏视图小部件
纵队(
儿童:[
Image.asset((“assets/images/Medicine amico.png”),
大小盒子(
身高:20,
),
正文(
“万岁!你没有任何待服用的药物!”,
样式:TextStyle(
fontFamily:“蒙特塞拉特”,
fontWeight:fontWeight.w600,
尺寸:14,
颜色:常量颜色(0x78000000),
身高:1.4285714285714286,
),
textAlign:textAlign.center,
),
],
),
//第二个选项卡栏视图小部件
纵队(
儿童:[
Image.asset((“assets/images/Time management pana.png”),
正文(
“此处没有数据!\n请填写您的处方”,
样式:TextStyle(
fontFamily:“蒙特塞拉特”,
fontWeight:fontWeight.w600,
尺寸:14,
颜色:常量颜色(0x78000000),
身高:1.4285714285714286,
),
textAlign:textAlign.center,
),
],
),
],
),
),
],
),
),
//浮动操作按钮:浮动操作按钮(
//子:图标(
//Icons.add,
//尺码:40,
//   ),
//背景颜色:常量颜色(0xFFD441),
//按下:(){},
// ),
);
}
医学杂志{
返回浮动操作按钮(
子:图标(
a.图标