Flutter State Management using ChangeNotifier and AnimatedBuilder - No Packages

Поділитися
Вставка
  • Опубліковано 15 вер 2024
  • Dashboard using `ChangeNotifier` and `AnimatedBuilder`.
    State Management by using built-in Flutter classes. No Packages.
    What is covered
    In this project, you are going to take a look at:
    - How to use `ChangeNotifier` and `AnimatedBuilder` to selectively rebuild individual widgets for performance
    - State Management with build-in classes, no packages
    The Problem:
    - Dashboard app needs to chart espresso, coffee, latte and total consumption
    - Drawing each section bar, the chart needs to refresh independently for performance
    The Solution:
    - Use the `ChangeNotifier` and `AnimatedBuilder` to allow to selectively rebuild individual widgets for performance
    ChangeNotifier and AnimatedBuilder
    The `ChangeNotifier` and `AnimatedBuilder` allow to selectively rebuild individual widgets for performance
    1. Create a class that extends `ChangeNotifier`
    2. Add fields to contain data
    3. Add methods to modify data and call the `notifyListeners()` method
    4. Add the `AnimatedBuilder` widget in the widget tree to rebuild widgets selectively if the data changed
    How it Works
    `ChangeNotifier` and `ValueListenableBuilder` - The `ChangeNotifier` and `AnimatedBuilder` allow to selectively rebuild individual widgets for performance. Use fields to contain data defining them in the `ChangeNotifier`. Use methods to modify data and call the `notifyListeners()` method. Use the `AnimatedBuilder` widget in the widget tree to rebuild widgets selectively if the data changed.
    GitHub: github.com/Jed...
    Twitter: / jedipixels
    Looking for Updates: JediPixels.dev
    Blog Article: jedipixels.dev...
    #flutter #fluttertutorial #dart #flutterdev #flutterdeveloper #appdevelopment

КОМЕНТАРІ • 4

  • @joeyroman84
    @joeyroman84 Рік тому +2

    Thank you for these 3 videos! I have been using BloC and Riverpod but have no idea what is going on in the background. At least with these methods I understand what it is I am doing. Streams next I am assuming? :D Are there any performance differences between Inherited/ValueNotifier/ChangeNotifier? Seems like they can all be used interchangeably.

    • @JediPixels
      @JediPixels  Рік тому +2

      Yes, I am planning using Streams for future videos. Like you said, they can be use interchangeably, it's a preference depending on the goal that you need to accomplish. With the projects I have worked on, I have not seen any serious difference in performance. What can effect the performance is the app's logic that runs the custom task before the changes are redrawn on the screen.
      Thanks you.

  • @prasantkumar7693
    @prasantkumar7693 2 роки тому +2

    Nice explanation and interesting research by you. Thank you