frideosapps / frideos_examples

A collection of examples on how to use the frideos flutter package.
BSD 2-Clause "Simplified" License
20 stars 5 forks source link

Authentication state #1

Closed aniltc-rails closed 5 years ago

aniltc-rails commented 5 years ago

Can you publish or explain how to maintain login state through out application/widgets and when we click logout it should be reset (should clear token). Is it possible ?

if we have multiple dynamic text boxes ( let us say (name1 & name 2), here name 1 is a textbox and name 2 is a textbox and We will have a button to add more textbox group. if we click another name1 and name2 will be displayed. Its a multiform. How to handle this situation.

Thanks

frideosapps commented 5 years ago

Hello @aniltc-rails, for the first question, the simplest solution is to have a singleton class where you store the state of your app, and creating methods ad hoc for login and logout. You could make the instance of this class global or use an InheritedWidget (I think it is a better solution) so that in this way all the widgets on the tree can access to the same source of data. You can find this architecture in my trivia example, where I have an AppState class for the state of the app and a TriviaBloc for the business logic of the game.

For the second question it is not easy to explain without writing a specific example but it's a good argument for writing an article about it, so I think I'll write something as I have a little free time.

aniltc-rails commented 5 years ago

Thanks for your reply The second question, I have done using set state but now I am moving to bloc pattern. You can see my sample code here https://stackoverflow.com/questions/55727876/managing-dynamic-form-using-bloc

frideosapps commented 5 years ago

Hello @aniltc-rails, I've just wrote a little example, you can find it in this branch: https://github.com/frideosapps/frideos_examples/tree/dynamic_form_fields.

aniltc-rails commented 5 years ago

Great , Will check examples.

---Missing Delete option & submit button. But its looking good

frideosapps commented 5 years ago

Hello, the submit button is the one the top of the screen showing "Valid" or "Form not valid" text and calling the "someActions" method on the BLoC class, but it does nothing more the showing a print on the debug console. The delete option is missing, check out this repo in the next days cause I'm planning to make a thorough refactoring of the app and I'll add this feature too. I'm going to close this issue and pin it for the other users asking for the same thing. Feel free to reopen it or a new one.