flutter-provider

Flutter provider state management, logout concept

坚强是说给别人听的谎言 提交于 2020-02-14 17:09:17
问题 I am trying to implement custom logout solution for my application, where no matter where user currently is, once the Logout button is clicked, app will navigate back to Login page . My idea was, that instead of listening on every component for state changes, I would have one single listener on a master component -> MyApp . For the sake of simplicity, I have stripped down items to bare minimum. Here is how my Profile class could look like: class Profile with ChangeNotifier { bool

Flutter provider state management, logout concept

北城余情 提交于 2020-02-14 17:09:02
问题 I am trying to implement custom logout solution for my application, where no matter where user currently is, once the Logout button is clicked, app will navigate back to Login page . My idea was, that instead of listening on every component for state changes, I would have one single listener on a master component -> MyApp . For the sake of simplicity, I have stripped down items to bare minimum. Here is how my Profile class could look like: class Profile with ChangeNotifier { bool

How to setup StreamProvider which take a param value from another StreamProvider?

怎甘沉沦 提交于 2020-01-24 20:57:37
问题 I'm using FirebaseAuth and Firestore for my application. 'User' is a model which represent a document on firestore and use uid from FirebaseUser to be its DocumentId as well. In order to get a 'User', I have to pass in uid from FirebaseUser. My idea is setup a StreamProvider of FirebaseUser, and then setup another StreamProvider of User, which takes FirebaseUser as a param. But error occurs, I couldn't found the solution for this issue, any advice would help me very much. List

How to access Provided (Provider.of()) value inside showModalBottomSheet?

折月煮酒 提交于 2020-01-20 07:23:56
问题 I have a FloatingActionButton inside a widget tree which has a BlocProvider from flutter_bloc. Something like this: BlocProvider( builder: (context) { SomeBloc someBloc = SomeBloc(); someBloc.dispatch(SomeEvent()); return someBloc; }, child: Scaffold( body: ... floatingActionButton: FloatingActionButton( onPressed: _openFilterSchedule, child: Icon(Icons.filter_list), ), ) ); Which opens a modal bottom sheet: void _openFilterSchedule() { showModalBottomSheet<void>( context: context, builder:

How to access Provided (Provider.of()) value inside showModalBottomSheet?

浪子不回头ぞ 提交于 2020-01-20 07:23:05
问题 I have a FloatingActionButton inside a widget tree which has a BlocProvider from flutter_bloc. Something like this: BlocProvider( builder: (context) { SomeBloc someBloc = SomeBloc(); someBloc.dispatch(SomeEvent()); return someBloc; }, child: Scaffold( body: ... floatingActionButton: FloatingActionButton( onPressed: _openFilterSchedule, child: Icon(Icons.filter_list), ), ) ); Which opens a modal bottom sheet: void _openFilterSchedule() { showModalBottomSheet<void>( context: context, builder:

StreamProvider not updating state

会有一股神秘感。 提交于 2020-01-14 15:48:32
问题 I am trying to use a StreamProvider (from this awesome package), but I've been struggling to get a particular stream to work. I create a StreamController which I use to add data to its Stream via its Sink . All of this seems to be working fine. But when using this Stream with a StreamProvider , the widget tree does not reflect the changes of the Stream . It does however work fine using a StreamBuilder . The code using a StreamProvider : class TestPage extends StatelessWidget { final Mockup

How to access to provider field from class that do not have context?

烂漫一生 提交于 2020-01-14 06:52:06
问题 I am using Provider . I have got two classes: class TenderApiData {} it's stand alone class (not widget). How I can write accesstoken to AppState ? class AppState extends ChangeNotifier // putted to ChangeNotifierProvider { String _accesstoken; // need to fill not from widget but from stand alone class String _customer; // Fill from widget List<String> _regions; // Fill from widget List<String> _industry; // Fill from widget ... } I need way to read\write accesstoken from stand alone classes.

Could not find the correct provider above this widget

五迷三道 提交于 2020-01-03 06:27:15
问题 I have a problem using Flutter Provider... My flow is like this: After login user id is passed to new widget -> from there it preforms save to db and then it redirects to new widget (Dashboard). And this is a code of a widget after Login: return MaterialApp( title: title, home: Scaffold( appBar: AppBar( title: Text(title), ), body: ListView( children: <Widget>[ Container( margin: EdgeInsets.all(8.0), child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(8

BLoC: how to pass it?

佐手、 提交于 2019-12-24 08:12:31
问题 I would like to know the best way to pass the bloc. I read about the bloc providers, but what`s the difference between using them and just passing the bloc in the constructor like: ExampleView X = ExampleView(bloc,...) Actually I find this way easier to test and also a better way to keep the code cleaner. For example, if I have more blocs, something like this can happen: XBlocProvider( bloc: XBloc, child: YBlocProvider( bloc: Y, child: ZBlocProvider... ) or maybe it's just my lack of

Error when adding provider package to flutter web project

天涯浪子 提交于 2019-12-10 15:07:52
问题 I tried to add the provider package to my flutter web project and got the following error: Because every version of provider depends on flutter any from sdk which is >forbidden, provider is forbidden. So, because WebApplication depends on provider ^3.0.0, version solving >failed. Flutter users should run flutter packages get instead of pub get . Process finished with exit code 69 I tried flutter packages get and also upgraded flutter to the newest version. When running flutter packages get