Persist Bloc State in Flutter - Hydrated Bloc Tutorial

Sdílet
Vložit
  • čas přidán 4. 09. 2019
  • 📗 Learn from the written tutorial & get the project 👇👇
    resocoder.com/hydrated-bloc-t...
    👨‍💻 Do you write good code? Find out now!
    resocoder.com/good-code-quiz
    Users expect your apps to be easy and quick to use and they surely don't want to be slowed down by having to reenter some data every time they launch the app. Think about it - would you like it if the browser on your phone didn't remember the last website you opened?
    That's why good apps persist their state to local storage. Sure, you can handle persistence in many ways, however, if you're using the flutter_bloc library, going the hydrated_bloc route is the best choice you can make.
    Go to my website for more information, code examples, and articles:
    ● resocoder.com
    Follow me on social media:
    ● / resocoder
    ● / resocoder
    ● / resocoder

Komentáře • 33

  • @lukaszglowacz8578
    @lukaszglowacz8578 Před 3 lety

    Woow! I was dreaming of such a tutorial, and there it is. You are awesome! Thank you.
    If anybody struggled with "flutter packages pub run build_runner build" do not forget to add "build_runner:" under dev_dependencies:

  • @matthias8582
    @matthias8582 Před 4 lety

    Thanks for your great explanations. I learned a lot from your videos and I come back to them often when I want to deepen my knowledge.

  • @abderrahmansettani9843
    @abderrahmansettani9843 Před 4 lety +2

    Great one bro ! We are still waiting for the part 4 of the Clean Architecture.

  • @StrifeTheHorseman
    @StrifeTheHorseman Před 3 lety

    Cool video, my friend! Now the setup is a bit different than it was at the moment you made this video but in general very cool and it's not hard to read official usage documentation to understand how to do all the setup by yourself. Also this code generation with json_annotation and json_serialization was absolutely new to me and it's quite handy in conjunction with hydrated_bloc.

  • @dennisosamuyimen6378
    @dennisosamuyimen6378 Před 4 lety

    this was helpful

  • @galloalcoy
    @galloalcoy Před 2 lety +2

    Hello! Can you do an update video for the hydrated_bloc versión 7.0.0 or higher? I really have a lot of difficulties right now about the update

  • @yashpaneliya1362
    @yashpaneliya1362 Před 3 lety

    Jsonserializable was something new for me!! Great videos !!

  • @sajithtm4864
    @sajithtm4864 Před 4 lety

    Turning the main method async a good approach? Will it delays the execution of runApp().

  • @karlon908
    @karlon908 Před 4 lety +1

    May i ask your thouhts about provider vs bloc?

  • @itssidhere
    @itssidhere Před 4 lety

    What if a state returns List of the model class how to return the list when the return type is Map of both toJson and fromJson

  • @slymanyonga7226
    @slymanyonga7226 Před rokem

    Please update these wonderful videos, its great but it's not working at all now.

  • @LexPrimost
    @LexPrimost Před 4 lety

    Its me again. My example is a shopping cart. My state(containing list of products added to the cart) are stored and restored with success after watching your tutorial, thanks for that. But everytime i add new products to the restored cart or remove a product from it. The cart empty itself. i mean the list of products in the cart which was restored by hydrated get empty. Do you know why? Can you help?

  • @yathink2406
    @yathink2406 Před 4 lety

    How you customized ubuntu ,tell about that

  • @claudedaiga5897
    @claudedaiga5897 Před 4 lety +1

    Great tutorial. Could you do this same tutorial using firebase and hydrated bloc?

    • @ChumX100
      @ChumX100 Před 4 lety +1

      Firestore and RealtimeDatabase implement their own local storage strategies with the great advantage that they sync the local data with the online servers automatically. So hydrated bloc is not really needed, you can use a regular Bloc and get your initial data directly through the Firestore SDK and let it handle the rest.

  • @pathakvivek7865
    @pathakvivek7865 Před 4 lety +4

    where are remaining TDD & CLEAN architecture videos?

    • @ResoCoder
      @ResoCoder  Před 4 lety +6

      Some of them unedited on my SSD, most of them in preparation.

  •  Před 4 lety +1

    coming from web-dev I don't understand why does keeping track of a single string value takes 8 files, 300 lines of code and 5 packages... also it does not seem linke something that would scale very well, as all those things would need to be duplicated for every single model.

    • @ResoCoder
      @ResoCoder  Před 4 lety +1

      True, but Flutter can handle this in just a few lines as well. It's all about the architecture around what you're trying to accomplish...

  • @Ainigma
    @Ainigma Před 4 lety

    Hive just came as an update to hydrated_bloc -> can you make a video about it? Some changes to the code need to be done and a tutorial would be splendid.

    • @LjaDj5XQKey9mSDxh4
      @LjaDj5XQKey9mSDxh4 Před 3 lety

      I thought that hydrated_bloc uses Hive under the hood. I don't understand what you mean. Do you have some resource where I can read about it?

  • @jasonnelford3179
    @jasonnelford3179 Před 4 lety

    In the Dart language tour it recommends to not use the "part" keyword (dart.dev/guides/libraries/create-library-packages). Has something changed that I'm not aware of? Or is there an important reason for using this against the recommendations in the official documentation? Thanks!

    • @TheJaniable
      @TheJaniable Před 3 lety

      The part keyword is necessary for the code generation to work. This way the generator can manage it's own files, and doesn't touch any files written by the developer. Lots of libs work that way.

  • @code5189
    @code5189 Před 4 lety

    If you see any plugin error, you have to add the following line of code in the main function
    ``WidgetsFlutterBinding.ensureInitialized();``
    before the run app function
    for more information visit this answer on stackoverflow : stackoverflow.com/questions/57689492/flutter-unhandled-exception-servicesbinding-defaultbinarymessenger-was-accesse

  • @peekpt
    @peekpt Před 4 lety

    Thank you for the tip! One more thing, could you make a video how use @override transform: in the bloc
    I am building a weather app based on your lessons and I found a way to debounce the input text:
    @override
    Stream transform(Stream events,
    Stream Function(WeatherApiEvent event) next) {
    return super.transform(
    Observable(events).debounceTime(Duration(milliseconds: 500)).distinct(),
    next);
    }
    It debounces but how do I filter the events I want to be debounced. Cheers m8. Thank you

    • @ResoCoder
      @ResoCoder  Před 4 lety

      I may create a tutorial on that, of course! In the mean time, you are probably using an older version of the bloc package, since the "transform" method no longer exists. Check out the release notes for version 0.15.

    • @peekpt
      @peekpt Před 4 lety

      @@ResoCoder I'm using flutter_bloc: ^0.20.0 , meanwhile I found a solution: Stream transform(Stream events,
      Stream Function(WeatherApiEvent event) next) {
      return super.transform(
      // Debounces all Events except ApiErrorEvent
      Observable(events).debounce(
      (window) => (window is ApiErrorEvent)
      ? window
      : TimerStream(true, Duration(milliseconds: 500)),
      ),
      next,
      );
      }

    • @peekpt
      @peekpt Před 4 lety

      edit: I updated to flutter_bloc 0.21.x which uses bloc 0.15.x transformEvents instead of transform is just a matter of renaming . transformStates override was added though

  • @davidagyakwa288
    @davidagyakwa288 Před 3 lety

    please update the hydrated bloc package

  • @LexPrimost
    @LexPrimost Před 4 lety

    i get this issue after following the tutorial "Converting object to an encodable object failed" can you help ?

    • @LexPrimost
      @LexPrimost Před 4 lety +1

      nevermind i fixed it by passing "explicitToJson: true" parameter to @JsonSerializable() in my model

  • @programan6391
    @programan6391 Před 4 lety