Navigator.of(context).pushReplacementNamed('/from');
Navigator.of(context).pop();
import 'package:flutter/material.dart';
import './Cate.dart';
import './User.dart';
import './Home.dart';
class Tabs extends StatefulWidget {
final index;
Tabs({Key key,this.index = 0}):super(key: key);
@override
_TabsState createState() => _TabsState(this.index);
}
class _TabsState extends State<Tabs> {
int currentIndex;
_TabsState(index){
this.currentIndex = index;
}
List _pageList = [
Home(),Cate(),User()
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: this._pageList[currentIndex],
bottomNavigationBar:BottomNavigationBar(
currentIndex: this.currentIndex,
onTap: (int index){
setState(() {
this.currentIndex = index;
});
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('首页')
),
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('首页')
),
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('首页')
)
],
),
);
}
}
跳转到指定的 tab页面
Navigator.of(context).pushAndRemoveUntil(
new MaterialPageRoute(builder:(context)=>new Tabs(index:1)), (route) => route == null);
flutte的替换路由
最新推荐文章于 2023-02-26 13:02:58 发布