Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.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
Ios 如何使用按钮和底部导航栏颤振导航?_Ios_Flutter_Dart_Button_Navigation - Fatal编程技术网

Ios 如何使用按钮和底部导航栏颤振导航?

Ios 如何使用按钮和底部导航栏颤振导航?,ios,flutter,dart,button,navigation,Ios,Flutter,Dart,Button,Navigation,我是新来的,有个大问题。 我想使用一个底部导航栏来切换屏幕,我想在这些屏幕上有一些按钮,在那里我可以导航到其他屏幕。当我试图将我编写的带有按钮的代码放到onTab中时,它说它与上下文有问题,我过去用按钮导航上下文。有人能帮我吗? 谢谢你的回答。 这是我的密码 import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'dart:math'; void main() {

我是新来的,有个大问题。 我想使用一个底部导航栏来切换屏幕,我想在这些屏幕上有一些按钮,在那里我可以导航到其他屏幕。当我试图将我编写的带有按钮的代码放到onTab中时,它说它与上下文有问题,我过去用按钮导航上下文。有人能帮我吗? 谢谢你的回答。 这是我的密码

 import 'package:flutter/material.dart';
 import 'package:flutter/cupertino.dart';
 import 'dart:math';

  void main() {
 runApp(MaterialApp(
  title: 'Navigation Basics',
   debugShowCheckedModeBanner: false,
   home: FirstRoute(),
  ));
   }

class FirstRoute extends StatefulWidget {
 @override
  _FirstRouteState createState() => _FirstRouteState();
}

class _FirstRouteState extends State<FirstRoute> {
 int _currentIndex = 0;
 final tabs = [
   Center(),
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
     bottomNavigationBar: BottomNavigationBar(
     currentIndex: _currentIndex,
    items: [
      BottomNavigationBarItem(
          icon: Icon(Icons.home, color: Colors.indigo),
          title: Text(
            "Home",
            style: TextStyle(color: Colors.indigo),
          ),
          backgroundColor: Colors.indigo),
      BottomNavigationBarItem(
          icon: Icon(
            Icons.settings,
            color: Colors.indigo,
          ),
          title: Text(
            "Settings",
            style: TextStyle(color: Colors.indigo),
          ),
          backgroundColor: Colors.indigo),
      BottomNavigationBarItem(
          icon: Icon(Icons.folder, color: Colors.indigo),
          title: Text(
            "Saved",
            style: TextStyle(color: Colors.indigo),
          ),
          backgroundColor: Colors.indigo),
    ],
    onTap: (index) {
      setState(() {
        _currentIndex = index;
      });
    },
  ),
  appBar: PreferredSize(
    preferredSize: Size.fromHeight(35.0),
    child: AppBar(
      title: Text(
        "BeGentle",
      ),
      backgroundColor: Colors.indigo,
    ),
  ),
  body: Center(
    child: new ListView(
      children: <Widget>[
        Container(
          decoration: BoxDecoration(
            color: Colors.indigo,
            borderRadius: BorderRadius.circular(30.0),
            boxShadow: [
              BoxShadow(
                color: Colors.grey.withOpacity(1.0),
                spreadRadius: 5,
                blurRadius: 10,
                // changes position of shadow
              ),
            ],
          ),
          height: 120.0,
          width: 400.0,
          padding: EdgeInsets.all(5.0),
          margin: EdgeInsets.all(5.0),
          alignment: Alignment.center,
          child: FlatButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => 
SecondRoute1()),
              );
            },
            child: Text(
              "Öffentlichkeit",
              style: TextStyle(
                  fontSize: 32.0,
                  fontWeight: FontWeight.w600,
                  color: Colors.white),
            ),
          ),
        ),
        Container(
          decoration: BoxDecoration(
            color: Colors.indigo,
            borderRadius: BorderRadius.circular(30.0),
            boxShadow: [
              BoxShadow(
                color: Colors.grey.withOpacity(1.0),
                spreadRadius: 5,
                blurRadius: 10,
                // changes position of shadow
              ),
            ],
          ),
          height: 120.0,
          width: 400.0,
          padding: EdgeInsets.all(5.0),
          margin: EdgeInsets.all(5.0),
          alignment: Alignment.center,
          child: FlatButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => 
SecondRoute2()),
              );
            },
            child: Text(
              "Gesprächsthemen",
              style: TextStyle(
                  fontSize: 32.0,
                  fontWeight: FontWeight.w600,
                  color: Colors.white),
            ),
          ),
        ),
        Container(
          decoration: BoxDecoration(
            color: Colors.indigo,
            borderRadius: BorderRadius.circular(25.0),
            boxShadow: [
              BoxShadow(
                color: Colors.grey.withOpacity(1.0),
                spreadRadius: 5,
                blurRadius: 10,
                // changes position of shadow
              ),
            ],
          ),
          height: 120.0,
          width: 400.0,
          padding: EdgeInsets.all(5.0),
          margin: EdgeInsets.all(5.0),
          alignment: Alignment.center,
          child: FlatButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => 
SecondRoute3()),
              );
            },
            child: Text(
              "Essen",
              style: TextStyle(
                  fontSize: 34.0,
                  fontWeight: FontWeight.w600,
                  color: Colors.white),
            ),
          ),
        ),
        Container(
          decoration: BoxDecoration(
            color: Colors.indigo,
            borderRadius: BorderRadius.circular(30.0),
            boxShadow: [
              BoxShadow(
                color: Colors.grey.withOpacity(1.0),
                spreadRadius: 5,
                blurRadius: 10,
                // changes position of shadow
              ),
            ],
          ),
          height: 120.0,
          width: 400.0,
          padding: EdgeInsets.all(5.0),
          margin: EdgeInsets.all(5.0),
          alignment: Alignment.center,
          child: FlatButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => 
 SecondRoute4()),
              );
            },
            child: Text(
              "Treffen",
              style: TextStyle(
                  fontSize: 32.0,
                  fontWeight: FontWeight.w600,
                  color: Colors.white),
            ),
          ),
        ),
        Container(
          decoration: BoxDecoration(
            color: Colors.indigo,
            borderRadius: BorderRadius.circular(30.0),
            boxShadow: [
              BoxShadow(
                color: Colors.grey.withOpacity(1.0),
                spreadRadius: 5,
                blurRadius: 10,
                // changes position of shadow
              ),
            ],
          ),
          height: 120.0,
          width: 400.0,
          padding: EdgeInsets.all(5.0),
          margin: EdgeInsets.all(5.0),
          alignment: Alignment.center,
          child: FlatButton(
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => 
SecondRoute5()),
              );
            },
            child: Text(
              "Social Interacting",
              style: TextStyle(
                  fontSize: 32.0,
                  fontWeight: FontWeight.w600,
                  color: Colors.white),
            ),
          ),
        ),
      ],
    ),
       ),
     );
    }
}
导入“包装:颤振/材料.省道”;
进口“包装:颤振/cupertino.dart”;
导入“dart:math”;
void main(){
runApp(材料应用程序)(
标题:“导航基础”,
debugShowCheckedModeBanner:false,
主页:FirstRoute(),
));
}
类FirstRoute扩展StatefulWidget{
@凌驾
_FirstRouteState createState()=>\u FirstRouteState();
}
类_firstroutstate扩展状态{
int _currentIndex=0;
最终选项卡=[
中心(),
];
@凌驾
小部件构建(构建上下文){
返回脚手架(
底部导航栏:底部导航栏(
currentIndex:_currentIndex,
项目:[
底部导航气压计(
图标:图标(Icons.home,color:Colors.indigo),
标题:正文(
“家”,
样式:TextStyle(颜色:Colors.indigo),
),
背景颜色:颜色。靛蓝),
底部导航气压计(
图标:图标(
图标。设置,
颜色:颜色,靛蓝,
),
标题:正文(
“设置”,
样式:TextStyle(颜色:Colors.indigo),
),
背景颜色:颜色。靛蓝),
底部导航气压计(
图标:图标(Icons.folder,颜色:Colors.indigo),
标题:正文(
“保存”,
样式:TextStyle(颜色:Colors.indigo),
),
背景颜色:颜色。靛蓝),
],
onTap:(索引){
设置状态(){
_currentIndex=索引;
});
},
),
appBar:首选大小(
首选尺寸:从高度开始的尺寸(35.0),
孩子:AppBar(
标题:正文(
“贝根特尔”,
),
背景颜色:Colors.indigo,
),
),
正文:中(
子:新列表视图(
儿童:[
容器(
装饰:盒子装饰(
颜色:颜色,靛蓝,
边界半径:边界半径。圆形(30.0),
boxShadow:[
箱形阴影(
颜色:颜色。灰色。不透明度(1.0),
扩展半径:5,
半径:10,
//改变阴影的位置
),
],
),
身高:120.0,
宽度:400.0,
填充:所有边缘设置(5.0),
边距:所有边缘集(5.0),
对齐:对齐.center,
孩子:扁平按钮(
已按下:(){
导航器。推(
上下文
MaterialPage路线(生成器:(上下文)=>
SecondRoute1()),
);
},
子:文本(
“Öffentlichkeit”,
样式:TextStyle(
字体大小:32.0,
fontWeight:fontWeight.w600,
颜色:颜色。白色),
),
),
),
容器(
装饰:盒子装饰(
颜色:颜色,靛蓝,
边界半径:边界半径。圆形(30.0),
boxShadow:[
箱形阴影(
颜色:颜色。灰色。不透明度(1.0),
扩展半径:5,
半径:10,
//改变阴影的位置
),
],
),
身高:120.0,
宽度:400.0,
填充:所有边缘设置(5.0),
边距:所有边缘集(5.0),
对齐:对齐.center,
孩子:扁平按钮(
已按下:(){
导航器。推(
上下文
MaterialPage路线(生成器:(上下文)=>
SecondRoute2()),
);
},
子:文本(
“Gesprächstemen”,
样式:TextStyle(
字体大小:32.0,
fontWeight:fontWeight.w600,
颜色:颜色。白色),
),
),
),
容器(
装饰:盒子装饰(
颜色:颜色,靛蓝,
边界半径:边界半径。圆形(25.0),
boxShadow:[
箱形阴影(
颜色:颜色。灰色。不透明度(1.0),
扩展半径:5,
半径:10,
//改变阴影的位置
),
],
),
身高:120.0,
宽度:400.0,
填充:所有边缘设置(5.0),
边距:所有边缘集(5.0),
对齐:对齐.center,
孩子:扁平按钮(
已按下:(){
导航器。推(
上下文
MaterialPage路线(生成器:(上下文)=>
SecondRoute3()),
);
},
子:文本(
“埃森”,
样式:TextStyle(
字体大小:34.0,
fontWeight:fontWeight.w600,
颜色:颜色。白色),
),
),
),
容器(
装饰:盒子装饰(
颜色:颜色,靛蓝,
边界半径:边界半径。圆形(30.0),
boxShadow:[
箱形阴影(
颜色:颜色。灰色。不透明度(1.0),
扩展半径:5,
半径:10,
//改变阴影的位置
),
],
),
身高:120.0,
宽度:400.0,
填充:所有边缘设置(5.0),
边距:所有边缘集(5.0),
对齐:对齐.center,
孩子:扁平按钮(
已按下:(){
导航器。推(
上下文