'Such a different problem with Fancy Bottom Navigation
There is a problem about fancy bottom navigation. I have created this structure. I have 4 bottom part. One of the bottom part, there is a button, it goes second page but when i went second page, i pushed another bottom navigation bar part, page stays in the second page although changing bottom bar button. I do not understand this situation. Could anyone help me to solve this situation?
Here are my relational code parts=> Firstly I used, fancy_bottom_navigation: ^0.3.3.
return MaterialApp(
debugShowCheckedModeBanner: false,
navigatorKey: navigatorKey,
home: Scaffold(
body: Container(
child: Center(
child: _getPage(currentPage),
),
),
bottomNavigationBar: FancyBottomNavigation(
circleColor: col.mostLightPurpleAccent,
activeIconColor: col.mostDarkPurpleAccent,
inactiveIconColor: col.mostLightPurpleAccent,
barBackgroundColor: col.mostPurple,
textColor: col.mostLightPurpleAccent,
tabs: [
TabData(
iconData: Icons.dashboard,
title: "Panel",
onclick: () {
final State<StatefulWidget>? fState = bottomNavigationKey.currentState;
}),
TabData(
iconData: Icons.trending_up_outlined,
title: "Üretim",
),
TabData(
iconData: Icons.trending_down_outlined,
title: "Tüketim",
),
TabData(
iconData: CupertinoIcons.wrench_fill,
title: "Bakım"
)
],
initialSelection: 0,
key: bottomNavigationKey,
onTabChangedListener: (position) {
setState(() {
currentPage = position;
});
},
),
),
);
_getPage(int page) {
switch (page) {
case 0:
if(Platform.isIOS){
return CupertinoApp(
debugShowCheckedModeBanner: false,
title: 'Panel',
home: FactoryDashboardScreen(locId: widget.locId,),
);
}
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Panel',
home: Scaffold(
body: FactoryDashboardScreen(locId: widget.locId,)),
);
case 1:
if(Platform.isIOS){
return CupertinoApp(
debugShowCheckedModeBanner: false,
title: 'Üretim',
home: CupertinoPageScaffold(
child: ProductionScreen(locId: widget.locId,),
),
);
}
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Üretim',
home: Scaffold(
body: ProductionScreen(locId: widget.locId,)),
);
case 2:
if(Platform.isIOS){
return CupertinoApp(
debugShowCheckedModeBanner: false,
title: 'Tüketim',
home: CupertinoPageScaffold(
child: ConsumptionScreen(locId: widget.locId,),
),
);
}
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Tüketim',
home: Scaffold(
body: ConsumptionScreen(locId: widget.locId,)),
);
default:
if(Platform.isIOS){
return CupertinoApp(
debugShowCheckedModeBanner: false,
title: 'Bakım',
home: CupertinoPageScaffold(
child:MaintenanceScreen(locId: widget.locId,),
// child: LoginApi.userUnits.contains(3) ? MaintenanceScreen(locId: widget.locId,) : NotAllowed4Dash(),
),
);
}
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Bakım',
home: Scaffold(
body: MaintenanceScreen(locId: widget.locId,)),
);
}
}
Padding(
padding: const EdgeInsets.all(16.0),
child: SizedBox(
width: width,
height: height*.24,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.all(32),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(75)),
primary: colFr.frAuroraGreen,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Çözümlenenler",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: height*.03,
color: CupertinoColors.black)),
Text("122",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: height*.03,
color: CupertinoColors.black)),
],
),
onPressed: () => {
Navigator.push(context, CupertinoPageRoute(
builder: (context) => SolvedScreen()))
},
),
),
),
The code seems independent but it is united parts which are problematical. If you want to examine the full code i have example app in my github repos here is the link: https://github.com/androloper/mobile/tree/main/hencoop_watch_app
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
