flutter-navigation

How to Navigate from ChangeNotifier?

﹥>﹥吖頭↗ 提交于 2021-02-10 18:43:42
问题 I am learning about provider + ChangeNotifier for state management, but I can't find any official guidance on how to implement a Navigation from a ChangeNotifier . Let's say we improve the provider_shopper sample here, so when the user clicks BUY, the CartModel does some buying logic and then Navigates to a Order Review page. How's this navigation should be implemented? Do we provide a callback for the CartModel , so it will call it and trigger a Navigation on the UI? 回答1: There might be a

stream builder is not updating after navigation

二次信任 提交于 2021-02-10 12:43:56
问题 I am using a stream builder to detect if user logged in or not. return StreamBuilder<User>( stream: AuthService().user, builder: (context, snapshot) { if (snapshot.hasData) return SectionWrapper(); else return Authentication(); }); and this is the stream I am using Stream<User> get user { return _auth.onAuthStateChanged.map(_userFromFirebaseUser); } //create user object based on firebase user User _userFromFirebaseUser(FirebaseUser user) { return user != null ? User(uid: user.uid, email: user

stream builder is not updating after navigation

回眸只為那壹抹淺笑 提交于 2021-02-10 12:43:33
问题 I am using a stream builder to detect if user logged in or not. return StreamBuilder<User>( stream: AuthService().user, builder: (context, snapshot) { if (snapshot.hasData) return SectionWrapper(); else return Authentication(); }); and this is the stream I am using Stream<User> get user { return _auth.onAuthStateChanged.map(_userFromFirebaseUser); } //create user object based on firebase user User _userFromFirebaseUser(FirebaseUser user) { return user != null ? User(uid: user.uid, email: user

How to know pop event happened inside Nested Widget in Flutter

。_饼干妹妹 提交于 2021-02-05 11:31:49
问题 I am currently building app where I need to use Nested Routing keeping one screen same and routing on different one. I want to when that second route is popped so that I can change value of expanded to fill whole screen. Gist in Github. Here is code sample: import 'package:flutter/material.dart'; 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 error “Could not navigate to initial route”

萝らか妹 提交于 2021-01-27 04:16:13
问题 I'm getting the following error when starting my Flutter app: ══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════ The following message was thrown: Could not navigate to initial route. The requested route name was: "/animals/cats/lolcats" The following routes were therefore attempted: * / * /animals * /animals/cats * /animals/cats/lolcats This resulted in the following objects: * MaterialPageRoute<dynamic>("/", animation: null) *

Flutter error “Could not navigate to initial route”

自闭症网瘾萝莉.ら 提交于 2021-01-27 04:13:49
问题 I'm getting the following error when starting my Flutter app: ══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════ The following message was thrown: Could not navigate to initial route. The requested route name was: "/animals/cats/lolcats" The following routes were therefore attempted: * / * /animals * /animals/cats * /animals/cats/lolcats This resulted in the following objects: * MaterialPageRoute<dynamic>("/", animation: null) *

Flutter - How to get notified when the page I pushed was popped by back button?

偶尔善良 提交于 2021-01-07 01:33:23
问题 Assume this scenario: page1 Navigator.push to page2. user on page2 clicks the back button, so page2 pops and page1 regains view. How do I catch this event on page1? 回答1: You can check like this by passing parameter from Navigator.pop... from the second screen:- Navigator.pop(context, 'updateList'), and on the first screen check like this and pass condition which you want:- FloatingActionButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => new

Flutter - How to get notified when the page I pushed was popped by back button?

隐身守侯 提交于 2021-01-07 01:23:51
问题 Assume this scenario: page1 Navigator.push to page2. user on page2 clicks the back button, so page2 pops and page1 regains view. How do I catch this event on page1? 回答1: You can check like this by passing parameter from Navigator.pop... from the second screen:- Navigator.pop(context, 'updateList'), and on the first screen check like this and pass condition which you want:- FloatingActionButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => new

Flutter - How to get notified when the page I pushed was popped by back button?

限于喜欢 提交于 2021-01-07 01:21:03
问题 Assume this scenario: page1 Navigator.push to page2. user on page2 clicks the back button, so page2 pops and page1 regains view. How do I catch this event on page1? 回答1: You can check like this by passing parameter from Navigator.pop... from the second screen:- Navigator.pop(context, 'updateList'), and on the first screen check like this and pass condition which you want:- FloatingActionButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (BuildContext context) => new

Flutter navigation, reopen page instead of pushing it again

老子叫甜甜 提交于 2021-01-02 07:01:10
问题 I'm new to flutter and I'm working on an App that have multiple screens. I would like to know to stop flutter from creating multiple screens of the same route, for example I have Page 1 and Page 2 , if I click on the button to navigate to Page 2 and clicked again on the same button the application will push a new screen of Page 2 and i will have it twice and if I click on the return button it will send me back to the first created Page 2 is there a way to create every page only once and then