fix(navigation-view): back button closing the app from any page (#1019)

This commit is contained in:
Aabed Khan 2023-07-13 19:25:48 +05:45 committed by GitHub
parent 0462815014
commit c5b0621323
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,7 +13,16 @@ class NavigationView extends StatelessWidget {
return ViewModelBuilder<NavigationViewModel>.reactive(
onViewModelReady: (model) => model.initialize(context),
viewModelBuilder: () => locator<NavigationViewModel>(),
builder: (context, model, child) => Scaffold(
builder: (context, model, child) => WillPopScope(
onWillPop: ()async{
if(model.currentIndex == 0){
return true;
}else{
model.setIndex(0);
return false;
}
},
child: Scaffold(
body: PageTransitionSwitcher(
duration: const Duration(milliseconds: 400),
transitionBuilder: (
@ -67,6 +76,7 @@ class NavigationView extends StatelessWidget {
],
),
),
),
);
}
}