Flutter Provider EASY Tutorial

Поделиться
HTML-код
  • Опубликовано: 2 июл 2024
  • This is how you can learn to use Provider with Flutter. This tutorial gets straight to the point, and you won't require any other beginner's tutorial on Provider after this one. Provider is a popular and powerful state management solution for Flutter applications. It simplifies the process of managing and sharing state between different parts of your Flutter app. Provider is used to create and manage data models (usually by extending ChangeNotifier), which can then be accessed and updated throughout your app.
    Here are some key aspects of Provider in Flutter:
    👉 State Management: Provider helps you manage the state of your Flutter application. You can create data models that extend ChangeNotifier to hold your app's data and business logic.
    👉 InheritedWidget: Provider uses the InheritedWidget pattern to make data available throughout the widget tree. This means you can access your data model anywhere in your widget hierarchy.
    👉 Simple Syntax: Provider provides a simple and readable syntax for working with data. It allows you to access data using context.watch (listen to changes) or context.read (don't listen to changes) , making it easy to update your UI when the state changes.
    👉 Scalability: Provider is highly scalable and can be used for both small and complex applications.
    👉 Reduced Boilerplate: Provider reduces the amount of boilerplate code needed for state management compared to some other solutions, making it a popular choice among Flutter developers.
    👉 Separation of Concerns: Provider encourages the separation of your app's logic from your UI, helping you write clean and maintainable code.
    Overall, Provider is a versatile and widely adopted state management solution in the Flutter ecosystem. It's a valuable tool for Flutter developers looking to efficiently manage and share state in their applications.
    OVERVIEW
    0:00​ Flutter Provider
    0:13 ✅ Step 1: Example
    0:46 Class Provider
    1:25 MultiProvider
    2:05 .watch
    2:51 .read
    4:10 Recap
    4:37 ✅ Step 2: Practical exercise
    5:09 Class Provider
    6:48 MultiProvider
    7:14 .watch
    7:32 .read
    LINK
    Cheat Sheet: fluttermapp.com/provider
    Documentation: pub.dev/packages/provider
    CREDIT
    Packages author: Remi Rousselet
    MISSION
    Our mission at Flutter Mapp (Flutter Mobile App) is to help purpose driven Flutter developers go full-time doing what they love and making an impact through coding. We achieve this with useful Flutter tips and straight to the point Flutter videos.
    WEBSITE
    www.FlutterMapp.com
    CONTACT
    For business inquiries email me here: info@fluttermapp.com
    #Flutter

Комментарии • 124

  • @RandalLSchwartz
    @RandalLSchwartz 8 месяцев назад +22

    Keep in mind, Remi (the creator of both Provider and Riverpod) has said that Provider is in maintenance mode only, and all new projects should be using Riverpod instead.

    • @wakkowb
      @wakkowb 7 месяцев назад +5

      do you have any source pls?

    • @SkjoyBd
      @SkjoyBd 6 месяцев назад +4

      ​@@wakkowb Speech without authentic source!

    • @iamawesomeheheh
      @iamawesomeheheh 4 месяца назад

      thanks @RandalLSchwartz! but I'm wondering what can't Provider do that Riverpod can? care to share?

  • @sehmendoza
    @sehmendoza 8 месяцев назад +2

    That's very nice of you providing this information. Thank you so much! For sure, a lot of people appreciate it!

  • @renecura
    @renecura 7 месяцев назад +2

    Amazing tutorial, clean and clear.

  • @faezansar5417
    @faezansar5417 6 месяцев назад

    You made it loook so simple ,hats off

  • @Mark_Thrasher
    @Mark_Thrasher 5 месяцев назад

    Excellent video! It is succinct and provided the general overview I wanted!

  • @noise3d
    @noise3d 7 месяцев назад

    Absolutely loved this. All the other videos were so confusing. Thank you. Hope you do one for Riverpod soon.

  • @unaisulhadi6445
    @unaisulhadi6445 7 месяцев назад

    Simplest explanation. Kudos

  • @RomanShepel
    @RomanShepel 5 месяцев назад

    Thank you! It was very helpful!

  • @reaganza23
    @reaganza23 8 месяцев назад +13

    Man I've been longing for the provider video for a long time and no youtuber have been able to explain it this way. Dude you are amazing.

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +3

      Glad I could help! Thank you Reaganza 🔥👍

  • @indigomedia4158
    @indigomedia4158 6 месяцев назад

    Thank you very much for making this tutorial, you helped me a lot, i appreciate

  • @muhendis_
    @muhendis_ 20 дней назад

    what a beautiful lesson

  • @CodingwithDay
    @CodingwithDay 2 месяца назад

    Thanks for the amazing video!

  • @ajatajay4877
    @ajatajay4877 2 месяца назад

    Life Saver video❤

  • @BorgKingMJ
    @BorgKingMJ 28 дней назад +1

    Not garbage, good tutorial :))

  • @icoweb500
    @icoweb500 5 месяцев назад

    thanks chief. well put.

  • @shreyasachar5528
    @shreyasachar5528 6 месяцев назад +3

    Last Line was Insane 😂😂😂😂...btw Great video buddy

  • @helloharendra
    @helloharendra 3 месяца назад +1

    Easy to understand , well explained , love it.

  • @aisadak
    @aisadak Месяц назад

    Thank u so much

  • @5ays470
    @5ays470 2 месяца назад

    THANKS!!

  • @davidactions3090
    @davidactions3090 8 месяцев назад +2

    Really helpful. Thank you again.

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +2

      You're very welcome!

  • @princesekey
    @princesekey 2 месяца назад +1

    Excellent 👌👌

  • @Socsob
    @Socsob 2 месяца назад

    This was awesome also I love the accent

  • @pradeeps4826
    @pradeeps4826 11 дней назад

    thank you sir

  • @MrAlwandawi
    @MrAlwandawi 6 месяцев назад

    you are amazing bro ...

  • @user-wt2sq1bx7e
    @user-wt2sq1bx7e 8 месяцев назад +1

    it was really helpful to understand the concept of provider thank you.

  • @hanifireffas4404
    @hanifireffas4404 8 месяцев назад +1

    great content.. thank u philip ♥

  • @vbk-no4pk
    @vbk-no4pk 8 месяцев назад +1

    Thank for sharing such kind of amazing content with us

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +2

      Pleasure, thank you ✌

  • @safwanjmuhammed6816
    @safwanjmuhammed6816 8 месяцев назад +1

    Perfect explanation 💯💙

  • @Engineer-Samibress
    @Engineer-Samibress 8 месяцев назад +1

    Thanks a lot for your time 😊

  • @mechul419
    @mechul419 7 месяцев назад

    Thank you I get it👌

  • @joshuabumanlag396
    @joshuabumanlag396 8 месяцев назад +1

    Amazing video as always man! Manifesting for your to have a BloC tutorial soon!

  • @pranaygsk5045
    @pranaygsk5045 8 месяцев назад +1

    Got clarity how provider works, really simplified one on internet!

  • @elitearmedforce
    @elitearmedforce 8 месяцев назад +1

    Amazing video, thank you for creating one. Now i am waiting for riverpod

  • @artem-ai
    @artem-ai 8 месяцев назад

    Thank you very much. Very useful. If possible, please make a tutorial: provider for shop cart

  •  8 месяцев назад +1

    Good lesson. Teşekkürler, Thank you

  • @berkay2410
    @berkay2410 8 месяцев назад +5

    Same video for Riverpod please!! Great video

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +2

      Will do, thank you Berkay

  • @joncov
    @joncov 8 месяцев назад

    just to express genuine gratitude and respect
    all your tuts are perfect, every second used 100%

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад

      Do you prefer if I begin the tutorial without the whole 'Hi, my name is..., welcome to my channel, hit the notification bell, etc.' routine? 😄 Lol, just kidding, I can't stand it when people do that on RUclips! It's great that you also appreciate straightforward content. 🙏

    • @joncov
      @joncov 7 месяцев назад

      @@FlutterMapp it is not only about the straightforward content; you combine thorough understanding with a natural gift to distill what's most important in it, with the effort to prepare the clips that are short but comprehensive
      can be compared to the communication race engineer to driver in F1 :) max content in min time in unequivocal way

  • @pyproger
    @pyproger 6 месяцев назад

    nice man

  • @berkaykzgr1933
    @berkaykzgr1933 8 месяцев назад

    Waiting for Bloc Tutorial and difference between them

  • @tulasireddy6557
    @tulasireddy6557 8 месяцев назад +1

    This tutorials was very nice, Please make tutorials on Flutter Bloc and RiverPod also

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +1

      RiverPod is comming, thank you!

  • @ajatajay4877
    @ajatajay4877 Месяц назад

    loved the video, but how did you navigate between settings page and home page with bottom navigation bar??

  • @paolabarrios4589
    @paolabarrios4589 8 месяцев назад

    Hola amigo, hoy me suscribí me encantan tus videos, y recién apenas conozco el canal. Tenes algún video o vas a subir de GETX?

  • @kelpindev9150
    @kelpindev9150 8 месяцев назад

    waw that is really good explanation 😍, can you create a video tutorial with provider too but using rest api ?

  • @rechi_0054
    @rechi_0054 2 месяца назад

    grate explanation. ist there a diffrence in using the Consumer widget ot the read method when listening to the provider

  • @jandurak
    @jandurak 8 месяцев назад +1

    Thanks

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +1

      Pleasure Jandurak 👍

  • @manishmg3994
    @manishmg3994 8 месяцев назад +1

    need more such videos

  • @kishores-ik4zw
    @kishores-ik4zw 8 месяцев назад +1

    I know provider well but I just learned from mistake when I am learning it's to hard for me but your video helps lots of people it's so simple and clean

    • @kishores-ik4zw
      @kishores-ik4zw 8 месяцев назад +1

      and explain about consumer that's the next level usage of provider

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +2

      Could you please explain why 'Consumer' is the next level of usage? Can't you just use '.watch,' and it will achieve the same result?

    • @kishores-ik4zw
      @kishores-ik4zw 8 месяцев назад

      you can used to listen to changes in a specific piece of data provided by a ChangeNotifier it's will optimise your code and get better response also @@FlutterMapp

    • @yoto6730
      @yoto6730 7 месяцев назад

      .watch and Consumer serve the purpose of listening to changes in a provider and triggering rebuilds, but .watch is more direct and concise, especially for simple use cases where you just need the value from the provider. On the other hand, Consumer provides more control over the widget tree that gets rebuilt when the provider changes, making it useful for more complex scenarios where you want to isolate specific parts of your UI.@@FlutterMapp

  • @JonnyS569
    @JonnyS569 8 месяцев назад +5

    Thanks for the video. Great work. I think a video about Riverpod and especially the new auto generate function's would be great because I provider is already pretty outdated isn't it?

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +4

      Yes a video just like this one about Riverpod is coming 👍

    • @JonnyS569
      @JonnyS569 8 месяцев назад +1

      @@FlutterMapp Perfect. Thank you very much ❤️

    • @elitearmedforce
      @elitearmedforce 8 месяцев назад +1

      ​@@FlutterMappI am highly looking forward to it.

  • @mohamednizam5298
    @mohamednizam5298 5 месяцев назад

    Do you have an example where u teach how to use both provider & sqflite? Planning to?

  • @Lancelot69
    @Lancelot69 2 месяца назад

    Why did you use "async" for the first provider's notifyListeners() but not use it for the 2nd one?

  • @abdullahkhaled6543
    @abdullahkhaled6543 8 месяцев назад

    👌

  • @satdevlpr
    @satdevlpr 7 месяцев назад

    is this rebuilds the whole page or just the particular widget ( Text widget in case of Counter example )?

  • @zakblacki
    @zakblacki 8 месяцев назад +2

    Thank you very simple, but I suggest you next time to provide more complex example usage. would be nice to have more state management Redux, Bloc, Mobus, Binder.
    Can you make a video explaining Models json map when creating some app MVC

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +3

      Good idea to talk about JSON map models. I will add this to the to-do list. Thank you! 👍

    • @zakblacki
      @zakblacki 8 месяцев назад +1

      @@FlutterMapp also consider usage of constructor examples

  • @charithasds
    @charithasds 8 месяцев назад +1

    Awesome! 🤩 Can you do the same for Riverpod (Provider 2.0)?

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +2

      Yes, soon, thank you

  • @twrk139
    @twrk139 7 месяцев назад

    Is it better to wrap the MaterialApp with MultiProvider in the build method of the, in your case "MyApp", or inside the runApp call in the main function?

    • @ravi2048
      @ravi2048 6 месяцев назад

      I wrapped the "MyApp()" inside the "runApp()" function because it was throwing an error and was suggesting me to wrap the "MyApp()" function.

  • @001Debjeet
    @001Debjeet 8 месяцев назад +1

    please make video on riverpod 2 a short but without no counter value

  • @ShaunyTravels.
    @ShaunyTravels. 5 месяцев назад

    More videos 😢please !!!

  • @chaitanyadamarasingu979
    @chaitanyadamarasingu979 8 месяцев назад +1

    I was searching and found this video OMG its 6 hrs ago

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +1

      Lol, hope it was useful 🔥.

  • @martinseal1987
    @martinseal1987 8 месяцев назад +1

    I'll stick to inherited widgets

  • @sofianemaaradji2625
    @sofianemaaradji2625 8 месяцев назад

    Thnx.first comment 😅

  • @WaniTech
    @WaniTech 8 месяцев назад +1

    i am a bit confused, when i first time used Providers to fetch and display the data, the way i used the providers was first create a class which inherits from changenotifier then whereever i have to use the fetched data from the app i just created the instance of the api class(extends changeNotifier) like this final api = Provider.of(context, listen: false); then inside the futurebuilder i called getData() method future: api.getData(), i dont know if this is the right way or not it was my first time using providers however my application was working somehow but my code was a mess, i was using the the getdata method once but i had to use it in two screens to display the data but i dont know why it fetched the data two times or more that made the screen flicker.
    which way is the right way to use providers the way used it or yours?

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +2

      Provider.of(context, listen: false) is the same as using .read 👍 .read is just simple to using in my opinion. You have a simple definition on this provider checklist. fluttermapp.com/provider . 🔥

    • @WaniTech
      @WaniTech 8 месяцев назад +1

      Thanks@@FlutterMapp

    • @WaniTech
      @WaniTech 8 месяцев назад +1

      by the way i have alot of questions regarding flutter keywords, can i ask you here or somewhere else? for example "context", "key", ".of()"method etc

  • @martinseal1987
    @martinseal1987 8 месяцев назад +5

    I don't need the explanation simplified I need the implementation simplified 😂

  • @wezone88
    @wezone88 8 месяцев назад +1

    riverpod is wraper this provider?

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +2

      Riverpod is the "newest" version. A tutorial similar to this one will be released.

  • @yoto6730
    @yoto6730 7 месяцев назад

    what is the last icon name

  • @ThePilli41
    @ThePilli41 8 месяцев назад +1

    is there any reason to use provide orver Riverpod? I know its build on the top of it, but its also simpler I would say...

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +2

      The only reason for this tutorial is that the two previous provider tutorials on this channel were terrible (Absolute garbage), so this is the redemption arc, lol. The next one is about Riverpod 🙏.

    • @ThePilli41
      @ThePilli41 8 месяцев назад

      I see I see. no matter what, I still very much appreciate the video! :) tbh you are the one I have started my flutter journey with, couple months ago ^^
      @@FlutterMapp

    • @xD-x-xD
      @xD-x-xD 8 месяцев назад +1

      probably best redemption arc then cyberpunk

  • @RianY2K
    @RianY2K 8 месяцев назад +2

    thank you for tutorial, can you make tutorial about Riverpod provider too?

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +2

      Yes, it's the next one on the list 🎉

  • @AdhamFaisal875
    @AdhamFaisal875 5 дней назад

    please need link of repo github

  • @caoviet.techlonogy
    @caoviet.techlonogy 2 месяца назад

    Why not show skeleton.dart ???

  • @TrojanPiece
    @TrojanPiece 5 месяцев назад

    You haven't showed how you initialized your userNameController variable, so the emulator is giving exception errors everytime now.

  • @demojoe28
    @demojoe28 8 месяцев назад +1

    Can you link the github repo please 🙏

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +1

      There is no github repo. 📖

    • @jv18creator
      @jv18creator 8 месяцев назад +1

      @@FlutterMapp could you please upload the code?

  • @boulderfailguy
    @boulderfailguy 8 месяцев назад +1

    C'était un ostie d'ordure!
    Nah just kidding - people complaining about it being too simple cleary didn't listen to the intro.

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +2

      loll. Merci. Ouai c'est vraiment Provider for beginners, just to keep things simple.

  • @gasfeesofficial3557
    @gasfeesofficial3557 3 месяца назад

    good video but simplistic examples don't do the justice to the power of using "Provider" or why someone should use it ... the authors examples could be solved just as easily by using simple state updates because what he is trying to do to explain the usage of Provider is too simplistic. if someone is confused like I was, here is something that will simplify ...
    Provider is best used for cases where you can have multiple inputs but a single output. Best case scenario is: where you update one widget based on several data-inputs that can invoke a different states for the widget. For example say you are updating a candlestick chart on a screen and are using a charting package/library like syncfusion or fl_chart. But you can't find one API that does it all or you are limited by # of calls from one also, some APIs may give data on one timeframe (1 d) vs. others may give data on other time frames (1 min, 5 min, 15 min etc.). You want to update the same chart widget, which is located on the center of the screen, based on possible changes to these multiple inputs (i.e. different timeframes). Additionally, you may also have a dropdown where the user can select a different instrument (like, BTCUSD, ETHUSD, US500 etc.) ... but you still want the same chart widget to update in the center of the screen. Furthermore, You may have a zoom button that pulls in more data from your API etc. ... Provider does best for these cases ... because you define a main listener (i.e. Consumer i.e. chart widget which comes from a library) .. .and you simply notify that widget when you manipulate it's data candlestick data sources.
    There are a lot of other approaches to accomplish the same thing too -> instead of using a charting library, you could break your widget down into individual candles and create a synthetic widget made of rectangles and lines. Fetch your data in a specific way -> manipulate your chart or specific candle that you are interested in. That's more of one-input -> update state -> display widget simplified lifecycle.
    Also, if you have better understanding of server-side/back-end technologies and can control of your data better... you can manipulate the data first and have it ready just as you would update it -> fetch the data -> then pass it into simple state-update widget all at once.

  • @chomanthapa
    @chomanthapa 8 месяцев назад +3

    yo! sexy voice.. great . provider is old can you do riverpod instead. ?

    • @FlutterMapp
      @FlutterMapp  8 месяцев назад +3

      100% 👍 Will do this one next.

  • @juniorlanga4505
    @juniorlanga4505 4 месяца назад +1

    Hahahahaha the tutorial was no garbage 😅

  • @ahmed_alharthi
    @ahmed_alharthi 8 месяцев назад

    Part2 is missing

  • @gjlmotea
    @gjlmotea 3 месяца назад

    Nice! but one question
    why 1:21 user_provider.dart extend "ChangeNotifier" class but the file name call "user_provider.dart"?
    there are exist "ChangeNotifierProvider" Class in flutter 1:3
    I don't know what is that and difference.