'close modal bottom sheet and navigate to another page after clicking the text button
I'm displaying modal bottom sheet using cupertino navigation bar, and i want to make the bottom sheet closed when i click the text button to navigate to another page. I use Navigator.pop(context); to do it, but it only closing modal bottom sheet and won't go to another page. I'm wondering everyone want to help me solve issue, thank you. sourcecode
Solution 1:[1]
You can do By this :
Navigator.of(context).popAndPushNamed(routeName)
If you dont have the route specified in main.dart . you can write it like this :
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
accentColor: Colors.amber,
fontFamily: 'Raleway',
textTheme: ThemeData.light().textTheme.copyWith(
bodyText1: TextStyle(
color: Color.fromRGBO(20, 51, 51, 1),
),
bodyText2: TextStyle(
color: Color.fromRGBO(20, 51, 51, 1),
),
headline1: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
fontFamily: 'RobotoCondensed',
)),
canvasColor: Color.fromRGBO(255, 254, 229, 1),
visualDensity: VisualDensity.adaptivePlatformDensity,
),
//home: MyHomePage(title: ''),
initialRoute: HomeScreen.homeScreenRoute,
routes: {
'/': (context) => LoginScreen(),
'home': (context) => HomeScreen(),
},
);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tasnuva Tavasum oshin |
