r/FlutterDev • • May 13 '20

Discussion Get? Get!

So, I'm new to Flutter. I've only been learning it over the past month — only been coding for the past six months or so. State management has been really tough to come to grips with. I've been trying out a few different approaches and Provider, or the Stacked ... uhm, stack, have seemed the simplest approach to get started.

But then I started reading up on how Stacked uses a library called Get for routing. So I read-up on Get's pub page and see that the library has its own stupidly simple approach to managing state. Like, it's too easy.

Has anyone else had a chance to play around with it? I'd like to know if there's a reason not to ditch all of the other approaches in favor of this total simplicity.

19 Upvotes

32 comments sorted by

12

u/jonataborges May 18 '20

As a developer, and in the face of some biased or even false comments, I need to speak up about it.

1- Get is highly tested. Get is highly Stable (look at the number of issues, and the number of people using Get, and draw your conclusions). Get is used by large multinationals, and some apps that will be launched in the coming months by one of the largest film producers in the world use Get.

2- Get has two state managements, one extremely simple, and the other reactive. The reactive uses Streams under the hood, that's exactly how BLoC works, with an easier approach than MobX / Provider. I don't need to advertise about it, just insert the library and test it yourself.

3- Get greatly facilitates navigation, and will continue to facilitate it. When Navigator 2.0 arrives, anyone using Get will not suffer any code breaks, anyone who does not use it will have to relearn dealing with Flutter navigation, so one of the comments in which Remi said that half the library would be deprecated with Navigator 2.0, is a lie , and even if Get had no navigation, just through the state and instance manager, dialogs and snackbars, high-level APIs, it would be worth it. You have no way of knowing if you have an open snackbar using Flutter, this is 100% impossible, and you have no way of creating a solution for this without replicating the entire Get code. With Get, a simple Get.isSnackbarOpen lets you know if there are any snack bars open at that moment. To change the theme, a "Get.setTheme (Theme.dark ())" solves your problem. Dynamic routes as well as web routes.

4- Get has a state manager (GEM) that uses very little RAM, because it does not store classes and variables in memory like all the others. It has only a single StreamController, which triggers events for the entire App. Each GetX has a StreamSubscription, which listens for events addressed to it. In addition, Get is the only intelligent state manager that exists. With MobX, for example, you have something almost magical, like the Observer that is only rebuild if any variable within it receives a set, however, MobX does not have Flow control, if you change a variable that contains "3" to " 3 ", it will rebuild the Observer in the same way. In addition to having this "magic" from MobX, Get only reconstructs something that will really imply a change of state, so if you machine-gun Get with 300,000 equal entries, it will filter this and update the screen only once.

Get is a new approach, and you should not antagonize it with Provider/MobX, because these are state managers, Get is a microframework for Flutter, which besides being very light, has a ready solution for you to create the structure of your application, and you can also use Get together with these others, without any problem, antagonizing them is illogical, because they are not opposites.

5- Get is not for everyone. Get is for those who want to completely decouple the View from the business logic, from the navigation logic, and when I say it completely, I am saying that even controllers should not be in the view. Obviously, Get doesn't use context for anything, and it doesn't use InheritedWidget for anything either. The view should only have pure widgets, preferably Stateless, and only if a widget needs to be changed, will you embed it in a GetX, and as soon as the variable it uses is changed, it will change the variable AUTOMATICALLY.

Get also abstract the use of InheritedWidget. If you need the width of your screen, for example, instead of MediaQuery.of (context) .width, you can use a Get.width. All other functions that depend on InheritedWidget, are abstracted so you don't need or use the context, and if you really need a context, you can use Get.context for that. And it depends on your project structure.

6- At some point in time, Get will become one of the most used packages in the world with Flutter (it already is, but I say something about top 3), because it is a package built by a developer, to help other developers. Get was a business solution, I decided to open it opensource because I wanted to help the community. Being simple does not mean that it is not complete, but that it is accessible, and from the senior developer, to the guy who started Flutter today, everyone will feel more productive using Get, and obviously you will hear a lot of hate, especially from people who already has a package that does one of the functions that Get does, which should not happen, there is a lot of space in the opensource world, and Get is not for everyone, there will still be people who prefer to work differently, who think differently , and there is nothing wrong with that. I hope we grow together as a community, without fights and without rivalries, after all, you can use whatever you want, after all, it is your project, your life, your work, and nobody should impose how you should work. But, if you want to know a new way of working with Flutter, I invite you to get to know Get

4

u/jdc123 May 19 '20

I wish I was experienced enough in Flutter development, (or development in general), to contribute more to this discussion. As it is, I can only defer to people who know much, much more than I do. I'll say this, though, finding your library was a great relief to me as a new developer. Moving data between parts of the application can feel challenging and your approach is just so much more intuitive than others. Thank you for making it available.

2

u/jrheisler May 21 '20

Big ditto there!!!

2

u/jrheisler May 21 '20

Coming from decades of the client server world I have been stumbling through state management. This morning I ran across Get. Very cool!!! I'm sure it's not for everyone, but I'm deep diving into it!

4

u/READMEtxt_ May 13 '20

As a newcomer to Flutter, wow this looks amazing, saved this. Thank you!

3

u/jdc123 May 13 '20

It does, right? I'm hoping that some people with more experience and understanding can take a look at it. After trying to understand the other solutions this seems almost too good to be true, but it works on the super-basic todo app I've been recreating to try out different state-management approaches.

The state-management and routing together, along with being able to pass/await values easily has me hoping this library gets a whole lot of attention. It feels the way the rest of the framework feels — simple and straightforward.

5

u/A-PRYME May 13 '20

unfortunately the people whose opinions you seek either uses Bloc, MobX, RxDart or Redux. What this means is that if get works for you... stick with it.

16

u/chrabeusz May 14 '20
  1. Pushing without context only works if you have one navigator. You may need multiple navigators to implement more advanced UI like tablet menu.

  2. The general advice is to avoid global mutable state and this package goes directly against it.

  3. It's true that ChangeNotifier is kinda slow, but it's not a problem for Provider because it needs only one listener.

  4. Not sure how this state management is easier than Provider. Instead of calling context.read / context.watch / context.select, you now have to use GetBuilder everywhere.

  5. Overall it feels like https://xkcd.com/927/

9

u/remirousselet May 14 '20

Not to mention that Navigator is getting reworked to be declarative. So half the library is getting deprecated

The library is also untested, and the Readme contains multiple false informations.

6

u/jonataborges May 18 '20

1- Get will not be deprecated with Navigator 2.0, on the contrary, those who use Get will continue with the same syntax, unlike all others who will have a painful change.

2- The Library, in addition to being tested on a large scale, to head projects of multinationals such as Warner, is used in applications with more than 1 million downloads for at least 1 year.

3- Everything that is written there is 100% proven.

6

u/remirousselet May 18 '20
  • The Navigator reword is to make it declarative. Get being imperative, is getting deprecated.

  • The test folder is empty

  • There are multiple people here and on Twitter with a lot of knowledge on Flutter that have pointed out multiple misinformations

5

u/esDotDev Jun 22 '20 edited Jun 22 '20

Saying a library is not tested, and that it does not have unit-tests is two entirely different things. I've seen countless libs from google, that have unit tests, and are broken in obvious ways, cause a human did not actually just test the thing robustly.

This author has clearly tested his framework more robustly than most in terms of real world benchmarking and measurments. Which, tbh, I will take any day over something with 40 unit tests but no attention to realworld performance (How the heck did we end up with a ChangeNotifier that is O(N ²) for dispatch, seriously?)

Man this community has some weird hate on sometimes if you don't want to do things a React-derived way. We saw it with GetIt, where everyone just comes out of the woodwork to piss all over it, despite it having 380 likes, (more than Redux or Bloc with zero boostering from Google).

Now with Get, which is an amazingly efficient and clean API, clearly built by a app-developer for app-developers. It's rocketed to 480 liked, and all I hear here is moaning and groaning. No thx for the hundreds of hrs of work, or kudos for the remarkably focused and well-thought out API. Really sad to see this reaction. I get that the author is a little provocative, but English is not his first language, I think we can all be a little less hostile here.

IMO Get is what Flutter always should have been, it addresses dozens of common use cases out of the box that somehow the Flutter engineers did not spec out. It actually feels like it's own cohesive thing rather than some monstrous derivation of React with warts and bumps all over.

2

u/chrabeusz May 14 '20

Not to mention that Navigator is getting reworked to be declarative.

Sounds interesting, can you link to github ticket?

4

u/remirousselet May 14 '20

https://github.com/flutter/flutter/issues/45938

TL;DR, no more "push/pop", with no context involved Instead routes are widgets.

This allows routes to be restored easily

4

u/chrabeusz May 14 '20

Interesting... migration will be painful.

1

u/Achtelnote May 18 '20

So half the library is getting deprecated

Oof.. When??

12

u/ajinasokan May 14 '20

It looks very simple. But the following line from readme threw me off:

Using StatefulWidgets means storing the state of entire screens unnecessarily. With Get the use of StatefulWidget is optional. Avoid them and save your users' RAM.

Who is teaching these?!

9

u/Fienases May 14 '20

That readme spread so many false information

1

u/JoeJoe_Nguyen May 14 '20

Holy moly! Is StatefulWidgets really that scary?

7

u/dancovich May 14 '20

Not even close. This information is very inaccurate.

Widgets in Flutter are only configurations. They tell how to render an element, they are not the element themselves.

StatefulWidgets store only what you want. A stateful widget with a single field "String name" will keep in memory just that.

2

u/jonataborges May 18 '20

It is okay to use StatefulWidget, even GetBuilder is a StatefulWidget. What the documentation makes clear is that saving an entire stateless class inside a statefulWidget will consume more RAM, you don't need to create a theory of the beyond for that, the documentation is clear in saying that statefulwidgets are more expensive than statelesswidget, not much more expensive, but it is a larger class, with functions that will be totally unnecessary in a widget that has no change of state. On the desktop Flutter, I am right now with a StatelessWidget class with nothing inside but a Scaffold, and a StatefulWidget with nothing inside but a Scaffold, and the difference between them is 1mb. Obviously this does not resonate in all cases, the difference in mobile in release with AOT should be at most 500kb, but definitely, creating a Stateful class for everything will spend more RAM, in addition to being bad practice. And you don't need to theorize that, just open the Dart inspect and see for yourself.

5

u/remirousselet May 21 '20

This is wrong information.

The difference between a Stateless and Stateful RAM wise can be measured in bytes. It is by no mean close to 1mb.

And even then, a tree that looks like this:

StatefulWidget > Scaffold > Text

will still consume less memory than:

StatelessWidget > Scaffold > WhateverBuilder > Text

0

u/jonataborges May 23 '20

Your comment doesn't make any sense! We are not talking about ephemeral state management, but application state management!

StatefulWidget > Scaffold > WhateverBuilder > Text is more expensive of StatelessWidget > Scaffold > WhateverBuilder > Text

Creating a StatefulWidget will not prevent you from using the Provider's Consumer, for example, so honestly, I couldn't find any sense in your comment.

3

u/remirousselet May 23 '20

Your Readme arguments that StatefulWidgets consumes a lot of memory, and that get fix it by changing:

StatefulWidget > Scaffold > Text

Into

StatelessWidget > Scaffold > GetBuilder > Text

Which is supposed to consume less memory.

I pointed out how argumenting that doesn't make sense.

And if we'll mention provider, then people mostly use Provider.of/context.watch instead of Consumer.

So we'd have:

StatelessWidget > Scaffold > Text

So there's no StatefulWidget involved at all. Not even a builder.

But that doesn't matter. Because the premise that StatefulWidgets consume a lot of memory is wrong, so provider won't argue that it's architecture saves memory.

7

u/remirousselet May 14 '20

This library seems to focus on easiness for simple apps Other state management approaches focus on scalability for large applications.

Get relies heavily on global variables. This is bad for large apps and tests.

7

u/JoeJoe_Nguyen May 15 '20

I'm sorry but the ReadMe doesn't sell me, a lot of bold and inaccurate statements.

4

u/JoeJoe_Nguyen May 15 '20

If you are a newbie, I encourage you to stay away from this sort of packages since when you used to using these, you are tied into them. And don't know how to implement on your own without them.

4

u/darkziosj May 13 '20

After working with react native, state management has been a nightmare with flutter, this sounds pretty awesome thanks.

4

u/nneck1t May 14 '20

What the problem did you face? I'm also from RN, but I do not see "nightmare"

3

u/JoRoCoBo May 22 '20

I've replaced a number of packages with Get, and it's working really well for me - wish I'd found it sooner. One of the great things about Get is that it removes the reliance on context which requires workarounds otherwise.

Since there wasn't much out there in the way of info, I did a first article on Medium to start filling in the gaps. Get is such a comprehensive package though, so my article only scratches the surface.

You can find it here.

2

u/rivendell_elf May 14 '20

Thanks for posting this. I was about to post the same package here. It looks too good to be true, honestly. Let's see what experienced devs have to say about this.

1

u/a-rns May 22 '20

For me is flutter_super_state simplest state manager easier than Provider.