properly when i’m on reserving display then i swap to groups or highlights or one after the opposite so as, when urgent again on the these display the chosen merchandise within the backside navigation bar stays mounted and never adjustments the display goes again
like when i press on the stats merchandise in backside navigation bar and there in stats display when i press again button then the display adjustments to the earlier display however within the backside navingation bar nonetheless the stats merchandise is proven as chosen with the inexperienced shade not the merchandise refering thr present display
that is code code for the HomeView Widget
import 'package deal:flutter/cupertino.dart';
import 'package deal:flutter/materials.dart';
import 'package deal:sportifan_user/screens/fundamental/bookings.dart';
import 'package deal:sportifan_user/screens/fundamental/choose_match.dart';
import 'package deal:sportifan_user/screens/fundamental/create_team.dart';
import 'package deal:sportifan_user/screens/fundamental/edit_team.dart';
import 'package deal:sportifan_user/screens/fundamental/highlights.dart';
import 'package deal:sportifan_user/screens/fundamental/stats.dart';
import 'package deal:sportifan_user/screens/fundamental/venue_screen.dart';
import 'package deal:sportifan_user/screens/fundamental/your_teams.dart';
import 'package deal:sportifan_user/widgets/highlights_widget.dart';
import 'package deal:sportifan_user/widgets/sidebar.dart';
import 'package deal:sportifan_user/widgets/top_navigation_bar.dart';
class HomeView extends StatefulWidget {
const HomeView({tremendous.key});
@override
State<HomeView> createState() => _HomeViewState();
}
class _HomeViewState extends State<HomeView> with RouteAware {
int currentIndex = 0;
ultimate GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
ultimate GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
void onTap(int index) {
setState(() {
currentIndex = index;
});
swap (index) {
case 0:
navigatorKey.currentState?.pushNamed("https://stackoverflow.com/");
break;
case 1:
navigatorKey.currentState?.pushNamed('/groups');
break;
case 2:
navigatorKey.currentState?.pushNamed('/highlights');
break;
case 3:
navigatorKey.currentState?.pushNamed('/stats');
break;
}
}
ultimate RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>();
@override
void didChangeDependencies() {
tremendous.didChangeDependencies();
routeObserver.subscribe(this, ModalRoute.of(context) as PageRoute);
}
@override
void dispose() {
routeObserver.unsubscribe(this);
tremendous.dispose();
}
@override
void didPopNext() {
_updateCurrentIndex();
}
void _updateCurrentIndex() {
// Outline this technique to replace currentIndex based mostly on the present route
swap (ModalRoute.of(context)?.settings.title) {
case "https://stackoverflow.com/":
setState(() {
currentIndex = 0;
});
break;
case '/groups':
setState(() {
currentIndex = 1;
});
break;
case '/highlights':
setState(() {
currentIndex = 2;
});
break;
case '/stats':
setState(() {
currentIndex = 3;
});
break;
}
}
@override
Widget construct(BuildContext context) {
TextEditingController teamController = TextEditingController();
TextEditingController uidController = TextEditingController();
TextEditingController controller = TextEditingController();
return WillPopScope(
onWillPop: () async {
if (navigatorKey.currentState?.canPop() ?? false) {
navigatorKey.currentState?.pop();
Future.delayed(Period.zero, () {
_updateCurrentIndex(); // Add this line
});
return false; // Stop the default again button habits
}
return true; // Enable the default again button habits if there is no path to pop
},
little one: Container(
shade: Colour(0xFF238F20),
little one: SafeArea(
little one: Scaffold(
key: _scaffoldKey,
appBar: PreferredSize(
preferredSize: Dimension.fromHeight(72.0), // Set the peak right here
little one: TopNavigationBar(
controller: controller,
onNotificationIconTapped: () {
_scaffoldKey.currentState?.openDrawer();
},
),
),
drawer: SideBar(
notificationExists: true,
),
physique: NotificationListener<PopNavigatorNotification>(
onNotification: (notification) {
_updateCurrentIndex();
return true;
},
little one: Navigator(
key: navigatorKey,
initialRoute: "https://stackoverflow.com/",
onGenerateRoute: (RouteSettings settings) {
WidgetBuilder builder;
swap (settings.title) {
case "https://stackoverflow.com/":
builder = (BuildContext _) => BookingView();
break;
case '/groups':
builder = (BuildContext _) => YourTeams();
break;
case '/highlights':
builder = (BuildContext _) =>
HighlightsView(highlightsExists: true);
break;
case '/stats':
builder =
(BuildContext _) => StatsView(statsExists: true);
break;
default:
throw Exception('Invalid route: ${settings.title}');
}
return MaterialPageRoute(
builder: builder, settings: settings);
},
),
),
bottomNavigationBar: Theme(
information: Theme.of(context).copyWith(
canvasColor: Colours.white,
primaryColor: Colour(0xFF238F20),
textTheme: Theme.of(context).textTheme.copyWith(
caption: TextStyle(shade: Colours.gray),
),
bottomNavigationBarTheme: BottomNavigationBarThemeData(
backgroundColor: Colours.white,
elevation: 0,
),
),
little one: BottomNavigationBar(
currentIndex: currentIndex,
onTap: onTap,
gadgets: [
BottomNavigationBarItem(
icon: Icon(
Icons.book,
),
label: 'Booking',
),
BottomNavigationBarItem(
icon: Icon(Icons.people),
label: 'Teams',
),
BottomNavigationBarItem(
icon: Icon(Icons.sports_cricket),
label: 'Highlights',
),
BottomNavigationBarItem(
icon: Icon(Icons.graphic_eq),
label: 'Stats',
),
],
selectedItemColor:
Colour(0xFF238F20), // change this to your most well-liked shade
unselectedItemColor: Colours.gray,
showSelectedLabels: true,
showUnselectedLabels: true,
),
),
),
),
),
);
}
}
class PopNavigatorNotification extends Notification {}
I attempted loads which u will see after going by means of the code however gained nothing in return, if somebody may also help please do…