【发布时间】:2020-02-17 23:32:23
【问题描述】:
我有一个关于显示底部导航栏的问题。我不明白为什么控制台没有问题。
class MyApp extends StatefulWidget {
@override
State<StatefulWidget> createState(){
return _MyAppState();
}
}
class _MyAppState extends State<MyApp> {
int _selectedPage =0;
final _pageOptions = [
HomeScreen(),
ProfileScreen(),
];
@override
Widget build(BuildContext context) {
var localizationDelegate = LocalizedApp.of(context).delegate;
return LocalizationProvider(
state: LocalizationProvider.of(context).state,
child: MaterialApp(
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
localizationDelegate
],
initialRoute: '',
onGenerateRoute: MyRoutes().getRoute,
supportedLocales: localizationDelegate.supportedLocales,
// locale: localizationDelegate.currentLocale,
theme: ThemeData( primarySwatch: Colors.red),
home: Scaffold(
body: _pageOptions[_selectedPage],
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _selectedPage,
onTap: (int index){
setState(() {
_selectedPage = index;
});
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('Home'),
),
BottomNavigationBarItem(
icon: Icon(Icons.account_circle),
title: Text('Me'),
),
]
),
),
),
);
}
}
我使用 flutter_translate。我知道这是一个非常简单的案例,但我坚持下去。我在谷歌搜索,但没有找到适合我的情况。
谢谢。
已解决
- 从我的设备(移动设备)中删除应用程序
- 控制台中的 Flutter clean
- 在 Android Studio 中启动调试
【问题讨论】:
-
这里是实现基本底部导航的教程的链接tutorial
标签: flutter dart android-bottomappbar