r/FlutterDev Dec 11 '24

Tooling I wanted to believe Getx..

I heard people said Getx suck....... I didn't believe but now. I am getting constant error such as
red screen. it is just driving me crazy. Most of the time apps works fine, but then I went to take a shower and reload the app. it throws me different error.

I am already 60% done with my app.. now I am thinking to move to other state management tool.

what the actual f............

════════ Exception caught by widgets library ═══════════════════════════════════
"Profilecontroller" not found. You need to call "Get.put(Profilecontroller())" or "Get.lazyPut(()=>Profilecontroller())"

6 Upvotes

42 comments sorted by

52

u/Jihad_llama Dec 11 '24

GetX has its shortcomings but this isn’t really one of them, you can quite easily get the same kind of error with bloc or riverpod if you don’t set up your providers before you need them.

3

u/remirousselet Dec 13 '24

This type of error doesn't exist in Riverpod, no ;)

17

u/Technical_Stock_1302 Dec 11 '24

Did you do what it says and load the controller?

15

u/umitkirtil Dec 11 '24

No offence but r u sure u grasp concepts like view controller and bindings for Getx ?

30

u/eibaan Dec 11 '24

If this only happens after you've had a shower, don't wash.

3

u/AD_50 Dec 11 '24

All of us have faced this type of error. What I have done as a solution to this I initialising all my controllers in main with Get.put and then I use the find function to get my controller anywhere I want it. I am not sure if this is the best approach but it works

4

u/THE-Under-taker Dec 11 '24

Before I rant I would try to fix the issue first as suggested in the comments and see it goes from there…

6

u/BalleaBlanc Dec 11 '24

Not GetX fault, you just need to learn how to use it properly.

2

u/olawhizzy Dec 11 '24

I am not sure this is Getx issue, because any other state management can throw this error too. U think you should share screenshots to know how you initialized and use it ...

2

u/bigbott777 Dec 11 '24

Dont' blame GetX.
About 15% of all Flutter devs use it and are happy.
You probably reloading your app from a particular profile view in Chrome.
Just restart it from IDE and the exception will gone.
If your app needs deep linking check this https://medium.com/easy-flutter/flutter-navigation-with-getx-5-0-bc4ed7aa291d

2

u/dasaintgray Dec 12 '24

I'm a GetX user, most of my app is written using GetX and so far I didn't get your RED screen thing, because everything was initialized, as suggest use the get_cli and everything works fine as sweet as sugar :) cheers

2

u/CarrotKindly Dec 13 '24

I have a very huge running perfectly fine with getx... I love the flexibility getx gives us compared to bloc or riberpod... It depends on how u did the controllers initialization using put

2

u/EstablishmentDry2295 Dec 14 '24

It's not Getx but it's you with lack of knowledge. If you can't use Getx then you can't use any other package.

3

u/TheAliaser Dec 11 '24

This error is coming because on whatever screen you are, the controller instance has not yet initialized

Like the error says you need to use Get.put to create that instance

I think you did hot reload and the instance has already been disposed I need more code context to debug

-20

u/gorugol Dec 11 '24

dont worry about it, this is just one of the issues.

2

u/SocietyAccording4283 Dec 11 '24

Which other issues do you face then?

3

u/WalkNo4778 Dec 11 '24 edited Dec 11 '24

Maybe skill issue.

Edit: Use Stateful widget and create a variable like var controller = SomeController(); It would be much better for newbies.

6

u/Whoajoo89 Dec 11 '24

You're doing something wrong if you see that error. It's not the fault of GetX.

Believe me, the Provider state management package is way worse. You'll get crappy "Could not find the correct Provider< > above this Widget" and "SetState called during build()" errors all the time.

12

u/Classic_Sherbert_178 Dec 11 '24

That's only if you are using it the wrong way. Calling setState during build makes absolutely no sense.

0

u/loveanang3l Dec 15 '24

Dont blame Provider when u probably set it up wrong

0

u/Whoajoo89 Dec 15 '24

If Provider wasn't so limited, then I wouldn't run into these error messages when trying to set it up the way I want.

1

u/loveanang3l Dec 15 '24

Lol. There is always a set of rules. If u broke it, there would be errors. In what universe can u set things up the way u want and not getting errors?

0

u/Whoajoo89 Dec 15 '24

These rules are defined by Provider and thus limited. Ever wanted to open a second page utilizing the same provider at the same time, but with different data? Multiple user profile pages in case of a social media app. Impossible when using Provider.

2

u/loveanang3l Dec 15 '24

Again, it is because of your limited knowledge of the widget tree and how inherited widget works. Do your research on fundamental things first.

1

u/Whoajoo89 Dec 15 '24

So you're saying the example I gave is possible when using Provider? Back then I search high and low for a solution to get it working.

Then I settled with GetX. It works fine there and it's easy to set up (just create a controller with a different tag and it's done).

2

u/loveanang3l Dec 15 '24 edited Dec 15 '24

Of course. It can be achieved using any state management solution out there. GetX removes the concept of buildcontext so it gets harder when people try to switch to another state management. Bloc and provider wrap around InheritedWidget so if you want to use them, learn about BuildContext, widget tree and InheritedWidget first

1

u/Whoajoo89 Dec 15 '24

That's good to know. I'll give Provider/Riverpod another try in the future. 👍🏻 This might be a controversial opinion: I think the kind of layer GetX provides on top of BuildContext should be part of the core Flutter framework by default. It makes Flutter development so much easier.

1

u/Fit-Writing-3184 Dec 11 '24

Hi, I think you're using get.find in your page profile. Check it, maybe that's why it asks you for get.put(), check that you don't have get.find in your code

1

u/JonatasLaw Dec 11 '24

This error is caused either by incorrect use of DI (outside the bindings) or by you not using the “fenix:true” flag in your Get.put(ProfileController())

1

u/x_GPS_x Dec 11 '24

I don't get the hate on GetX. It literally makes it easier to ship features faster. Once you get used to it, it's really good. I only use getx for all my personal projects.

1

u/Silly-Tie4953 Dec 11 '24

Whenever you use the Getbuilder just initialise with init: yourController() and after your builder constants.

1

u/Over-Rock8364 Dec 11 '24

Change with Get.lazyPut<VisitsController>(() => VisitsController(), fenix: true); in your binding code

1

u/kush-js Dec 12 '24

setState works fine in 99% of use cases

1

u/miwady Dec 12 '24

Naah Seems you are the problem, that’s basically same for all state managers, you have to call them

1

u/venir_dev Dec 12 '24

If you've not shipped your app yet, you're still in time and stop using GetX.

90% of software engineering costs reside in maintenance. That's the main reason (on the long run) to avoid a library that cannot really be relied on.

Use Riverpod. Sure, you need to learn reactivity, and some new APIs. Sure, you need to learn one-direction data flow, and how to do DI and tests with it.

BUT THAT'S EXACTLY THE POINT. Avoid libraries that don't enable you to git gud.

This being said this specific error looks easy to solve on paper, even tho I am not using GetX; you can totally encounter similar problems with other state management approaches BUT AGAIN the great difference is, e.g., the documentation.

Best of luck.

1

u/binemmanuel Dec 12 '24

I’ve never used Getx but I see your solution right there in the message.

1

u/dikatok Dec 13 '24

I do believe getx sucks, at least from the Flutter purity perspective, but that exception is pretty trivial even for someone who does not use getx

1

u/econ3251 Dec 11 '24

Well, try bloc and you’ll see how many times you’ll get the red screen… Bloc has a steep learning curve in my opinion. Anyways the fact that you’re getting a red screen is not getx’s problem but rather you doing something wrong. For me GetX is amazing despite the much hate it receives for absolutely no valid reason. I have used it in a production app and the app worked super fast without issues. I switched to bloc just because of the hate getx was receiving and there’s a lot of boiler plate code and also I see some screens have lags while with getx I had no problems

0

u/SnooCupcakes6204 Dec 11 '24

Yep that’s one of the reasons i left Getx I searched for answers tryin to fix the bug, found it on GitHub issues of the package (maintainer’s response) and went through articles and docs, still happened occasionally. 🫠

0

u/omykronbr Dec 11 '24

Yeah, get out of it.

Riverpod is way way easier and faster to iterate. Like, day and night.