Reputation: 107
I have an issue about to display Bottom Navigation Bar. I don't understand why I have no issues in the console.
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'),
),
]
),
),
),
);
}
}
I use flutter_translate. I know it's a very simple case but I'm stuck on it. I search in google but I find nothing which can fit my case.
Thank you.
Upvotes: 2
Views: 532
Reputation: 127
You can try this,
Bottom navigationbar is the property of scaffold.
bottomNavigationBar: BottomAppBar(
shape: CircularNotchedRectangle(),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 48.0, vertical: 3),
child: new Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(
icon: Icon(Icons.home),
color: Colors.white,
onPressed: () {},
),
IconButton(
icon: Icon(Icons.contact_phone),
color: Colors.white,
onPressed: () {},
),
],
),
),
color: Colors.blueGrey,
);
Upvotes: 1
Reputation: 1584
Without the location code, works fine, have you made setup of flutter_translate correctly? settings delegate and assets like below:
var delegate = await LocalizationDelegate.create(
fallbackLocale: 'en_US',
supportedLocales: ['en_US', 'es', 'fa']);
runApp(LocalizedApp(delegate, MyApp()));
https://github.com/bratan/flutter_translate/wiki/1.-Installation,-Configuration-&-Usage
Seens to me that you have missing something in that setup.
Can you describe more what happens exactly? Show some print or gif with behavior?
see ya
Upvotes: 1