GetX in Flutter - Part 1 (Observables)

  Рет қаралды 20,857

The Flutter Factory

The Flutter Factory

3 жыл бұрын

New intro for the new channel name! There are many state management options to choose from (Bloc, Provider, Mobx, etc). GetX is the new kid in town, but it's gaining a lot of traction for good reason. It has a lot in common with the Provider package, but it's slightly easer to use and is more readable in my opinion. If you understand Provider, then switching to GetX will be relatively simple. This video will get you started with using observables state in GetX.
*The aspect ratio of this video seems a little off. I was experimenting with a few things. It should be corrected going forward.
⚡Connect on Facebook: / flutterfactory
⚡Connect on Twitter: / flutterfactory
🎷 Music from www.Bensound.com
💻 Follow along with the initial code here: github.com/theflutterfactory/...

Пікірлер: 58
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
What do you think about GetX? I think it will be the primary method of state management in Flutter at some point.
@meeDipesh
@meeDipesh 3 жыл бұрын
Simple and easy to implement. It is life saviour. Flutter itself was easy to learn and with GetX I am enjoying it more.
@Dush999
@Dush999 3 жыл бұрын
Agree
@yodartt
@yodartt 3 жыл бұрын
Hey GREAT Video! I had a quick question: What if I wanted multiple controllers and each one building a different page. For example: A UserController that its used on a profile page, but say I'm on profile 1 and tap on a comment of user 2 and go to profile 2 wouldn't this new page still use data from the previous one?
@paanoop
@paanoop 3 жыл бұрын
All the programmers in my community are using BLOC still. They have never heard of this! Getx is too good considering statemgmt & routing features!
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
Having different options is always a good thing. They are all different. Though RiverPod will likely replace provider in the near future since it's essentially an upgraded version of provider created by the same person.
@RajA-me9cl
@RajA-me9cl 3 жыл бұрын
Unique && clean illustration. So grateful 🙏🏼
@MoAdel92
@MoAdel92 3 жыл бұрын
Really informative video thanks for your contribution in the flutter community
@vishalmakam7291
@vishalmakam7291 3 жыл бұрын
Covered most of the important things... Nice 👍
@meeDipesh
@meeDipesh 3 жыл бұрын
You just gained a new subscriber 😉
@zerosugar2126
@zerosugar2126 3 жыл бұрын
Thank you for sharing!
@NedimMalik
@NedimMalik 2 жыл бұрын
Excellent teaching, thanks a lot ;)
@babayevnariman
@babayevnariman 3 жыл бұрын
best getx video thank u
@Jan123.
@Jan123. 3 жыл бұрын
Great video.
@CarlosHernandez-dv1ib
@CarlosHernandez-dv1ib 3 жыл бұрын
What a great example, I saw your post on flutter's Facebook group.
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
Thanks. I will have more Getx videos soon
@setyatama8256
@setyatama8256 3 жыл бұрын
​@@TheFlutterFactory Im waiting for a more video about GetX, thanks
@pemangodup6549
@pemangodup6549 3 жыл бұрын
loved it and thank you soooo much.....
@kanishkchawla8997
@kanishkchawla8997 3 жыл бұрын
I am the first to comment Happy to comment on my fab channel Really good vedios sir ❤️️️❤️️️
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
Congrats😁. And thanks!
@shogi23
@shogi23 3 жыл бұрын
wow thanks men the movi is amasing
@ameya730
@ameya730 3 жыл бұрын
Really informative video. Has helped me a lot with state management. Just one question though... I want to get the duration & position till which a video has been video so that I can save its state [to use later]. Is it possible to declare duration and position as .obs and if yes, how do I do it ?
@TheFlutterFactory
@TheFlutterFactory 2 жыл бұрын
I don't know how you setup your video playback, but I'm assuming you have a way to listen for updates in the video playback. You would just set the controller values as the video plays. Your duration probably wouldn't change unless you're trimming a video.
@ameya730
@ameya730 2 жыл бұрын
@@TheFlutterFactory Thanks for your comment. The listner part is what I was missing which I was able to figure out after seeing your reply.
@yodartt
@yodartt 3 жыл бұрын
Hey GREAT Video! I had a quick question: What if I wanted multiple controllers and each one building a different page. For example: A UserController that its used on a profile page, but say I'm on profile 1 and tap on a comment of user 2 and go to profile 2 wouldn't this new page still use data from the previous one? @Cheetah Coding
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
The amount of controllers, the data they hold and where you use them are all in your control. You are the architect of your app. 🙂. If you feel like one controller per screen makes sense for your design, do it. But there's nothing stopping you from having one single controller for all screens or the same 5 controllers in all screens. Think about the general flow of your app before you start coding it. Software architecture is a huge topic by itself. Read about different patterns like MVP, MVVM, Clean Architecture, etc.
@zeljkosh
@zeljkosh 3 жыл бұрын
Very nice video, just curious about one thing (lets say around 29min to 30 min), you use rounded input to add a follower, but after submit how can you clear value of the rounded input. Do you have to do it from controller, or do you have to make Rounded input also obx wrapped?
@zeljkosh
@zeljkosh 3 жыл бұрын
i added TextEditingController to add followers, and after restaurantController.addFollowers(value); i just user textInputController.clear(); (and it works, is it proper way no idea )
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
yep. Your UI should only talk to the restaurantController to manipulate state. You can listen for that state change wherever you want in the app. A TextEditingController is a built-in Flutter StateNotifier that holds/changes the state of that TextEdit. You can peek into the TextEditingController and learn more about it.
@mohsinikram8921
@mohsinikram8921 3 жыл бұрын
Hi thanks for this informative video. I have one question. The Obx() basically return a widget. But I want just need callback. Like when I will click on a button it will send me data so now it will up to me on where I will use this data.
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
You don't have to use the data in your UI if you don't want to. A controller is used to store state/data that your app needs during the current session and to 'control' other aspects of your app that sets/gets that data. For example when you click a button, you can make an api call with a method in your controller that logs a user in. It's very likely that your UI needs to be notified and update when that happens so you can store whatever response you want from that in your controller in a variable. You don't have to listen for the data with an obx/Getbuilder if you don't need to, but it's there in your controller in case some other screen/widget wants to access it.
@mohsinikram8921
@mohsinikram8921 3 жыл бұрын
@@TheFlutterFactory Let me ask one thing, what is the best way for your point of view, I want to login in app, and I want to show progress bar that indicating the API is hitting, and when API will hit successfully , it will move to next screen. So for now, I just need callback for progress bar and success data like User object.
@Tech1st
@Tech1st 3 жыл бұрын
can you create a video using getX, pagination API?
@zeljkosh
@zeljkosh 3 жыл бұрын
Just a small question (i dont know if i saw this in some part of tutorial,i did watch all of the ones regarding get). Simple example, lets say you have MainScreen with scaffold,app bar and drawer, MainController, and lets say we have TestScreen with its own widget tree. Now when i choose test screen in drawer i want that body of MainScreen scaffold be replaced with TestScreen. Should we make observable boolean in MainController, and when its false MainScreen scaffold shows empty container, then on drawer click we set it to true, and we get TestScreen in our MainScreen scaffold. is this proper way to do it, i think i saw this somewhere but i dont know if it was navigation part or the observable part. just curious if its ok to do this. Thanks!
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
Based on how you worded your question, this has nothing to do with state management and it's a bit confusing. Don't overthink things. You can show different options in your drawer based on different conditions. Those bools can be stored in a state controller
@zeljkosh
@zeljkosh 3 жыл бұрын
@@TheFlutterFactory for some reason my comment gets removed when i past some code link. lets say we have MainScreen and TestScreen, main screen has scaffold, app bar and drawer. when i click on drawer item, i want MainScreen scaffold body to be populated with TestScreen widgets, i dont want to go to new page, or new screen, i want to replace scaffold body in existing view with different widgets
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
@@zeljkosh you would set some bool value in your controller to represent each that state. For the widgets that you want to hide/show/switch, you can just check that value. You'll probably want to use GetBuilder (part 2) instead of obs values around those widgets since it's probably not a value that will change very often, but it's your choice. So you would have something like: GetBuilder( builder: (controller) => controller.showTestWidgets? YourTestWidget(): YourMainWidget() ) and you would do that for all the different widgets you want to show based on that bool value. in the onPress of your drawer item you just set that value with something like: controller.setTestWidgets(true | false)
@zeljkosh
@zeljkosh 3 жыл бұрын
@@TheFlutterFactory Thank you for reply, yes i did exactly like you described, i was just wondering if that is good practice. Cheers
@zeljkosh
@zeljkosh 3 жыл бұрын
@@TheFlutterFactory Thank you for reply, yes i did exactly like you described, i was just wondering if that is good practice. Cheers
@JuniorIqfar
@JuniorIqfar 3 жыл бұрын
If i close the apps, and i want the value are store in local data. How to implement this??...
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
Persistent storage is a completely separate topic. You cans use AsyncStorage to store key value pairs (similar to SharedPreferences in native Android). And there Sqflite which is a persistent local Sqlite database for flutter. I've already created videos for both of those on the channel.
@JuniorIqfar
@JuniorIqfar 3 жыл бұрын
i was try with get_storage in controller i write this code getName() { return (storage.read('name') != null) ? storage.read('name') : name; } but it cannot load automatically please help me
@setyatama8256
@setyatama8256 3 жыл бұрын
Im waiting for a more video about GetX, crud API with GetXstate management. thanks
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
I will do one more video about GetX. Networking is not part of the GetX library. REST APIs would be handled the same way with or without it.
@fantabarack
@fantabarack 3 жыл бұрын
obs cannot be used anymore, it's deprecated. But I don't see any example code what can be used instead...
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
Where did you see that obs is deprecated?
@TechWithDnes
@TechWithDnes 3 жыл бұрын
Wow.. GetX
@rabiasharma8575
@rabiasharma8575 2 жыл бұрын
rounded input are not show
@flutterdarkmode
@flutterdarkmode 3 жыл бұрын
what name of this theme vscode
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
DeepDark Material Theme. just search for it in the extensions panel.
@shogi23
@shogi23 3 жыл бұрын
.add and addIf( don't work, I don't know what to do next, I found nothing in google pleas hepp addReview (String name, String review ){ reviews.add(name, review); } The method 'add' isn't defined for the type 'Map'.
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
That should be a pretty easy to debug. Did you define your Map variable? {}
@francescofreddi4374
@francescofreddi4374 3 жыл бұрын
now reviews.add(name, review). isnt define add for type ''Rxmap' need to write: reviews.addIf( true, name, review, ); instead
@shogi23
@shogi23 3 жыл бұрын
.add and addIf( don't work, I don't know what to do next, I found nothing in google pleas hepp
@francescofreddi4374
@francescofreddi4374 3 жыл бұрын
@@shogi23 use Rxmap... like a type
GetX - Flutter Internationalization (Switch languages) - Part 4
23:30
The Flutter Factory
Рет қаралды 8 М.
GetX - Part 2 (GetBuilder & Workers)
25:58
The Flutter Factory
Рет қаралды 6 М.
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 37 МЛН
Каха заблудился в горах
00:57
К-Media
Рет қаралды 10 МЛН
Flutter State Management with Provider 5
43:08
The Flutter Factory
Рет қаралды 25 М.
Using Redux in React Native - Part 2 (Hooks)
12:13
The Flutter Factory
Рет қаралды 8 М.
Moving from setState to Riverpod in Flutter Part 1
36:00
The Flutter Factory
Рет қаралды 18 М.
Complete GetX State Management | Flutter
18:16
Tadas Petra
Рет қаралды 69 М.
GetX Powerful Framework in Flutter in Detail (2021)
40:16
Easy Approach
Рет қаралды 88 М.
No Code App Development is a Trap
9:31
Coding with Dee
Рет қаралды 186 М.
Flutter Provider EASY Tutorial
9:43
Flutter Mapp
Рет қаралды 46 М.
GetX State Management tutorial with Flutter 😍
38:13
CodeX
Рет қаралды 135 М.
Using tkinter with classes
28:23
Atlas
Рет қаралды 58 М.
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 37 МЛН