[![enter image description here][1]][1]A little bit of a beginner question, but I have been messing with it for a long time and looking around without finding an answer.
I am using Flutter framework and I am trying to run multiple Stateless widgets, a bottom navigation bar and a top appbar to hold menu and other navigation buttons.
I am struggling to get both running at once and I can not find a way to run them both.
At the moment, when I call home:MyBottomNavigationBar
only this appears and not the other(Makes sense) But what command or solution would help me run multiple widgets? I have tried tons of different ways to use home, but nothing seems to work.
My code is very simple. Just creating a Navigation bar and appbar with stf inside main.dart.
If needed I can attach the code, but hopefully my question is clear enough.
Done In Xamarin, I can have both BottomNavBar and Couple of Nav buttons at the top easily. [1]: https://i.stack.imgur.com/Q2qXg.png
BottomNavBar.dart in Widgets folder
import 'dart:io';
class MyBottomNavigationBar extends StatefulWidget
{
@override
MyBottomNavigationBarState createState() => MyBottomNavigationBarState();
}
class MyBottomNavigationBarState extends State<MyBottomNavigationBar>
{
int _currentIndex = 0;
final List <Widget> _children =
[
HomePage(),
ExplorePage(),
ProgressPage(),
ChallengesPage(),
ProfilePage(),
];
void onTappedBar(int index)
{
setState((){
_currentIndex=index;
});
}
@override
Widget build(BuildContext context)
{
return new Scaffold
(
body: _children[_currentIndex],
bottomNavigationBar: BottomNavigationBar
(
onTap: onTappedBar,
currentIndex: _currentIndex,
items:
[
BottomNavigationBarItem
(
backgroundColor: Colors.pinkAccent,
icon: new Icon(Icons.home,
color: Colors.black),
label: 'Feed',
//activeBackgroundColor: Colors.red, // this is the change
),
main.dart
void main() async
{
WidgetsFlutterBinding.ensureInitialized();
runApp(MyApp());
}
/// This is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context)
{
MyBottomNavigationBar();
}
return MaterialApp(
title: _title,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home:HomePage()
);
}
}
And then I have a widget for a couple of buttons at the top appbar, but I can only run either BottomNavBar or The AppBar buttons. I would like to have them both working at the same time.