flutterflutter-getx

Is it possible to create a separate Getx Controller for a reusable widget?


Is it possible to use getx controller to manage state for reusable widget type? I want to create a small widget such as an elegant number button widget for the shopping cart section with each widget having a separate controller that does not share data with each other. Is it possible to do so and should it be done? Please advise me. Sorry for my bad English


Solution

  • No you cannot. It is always recommended to keep the the reusable widget a stateless widget that takes data to show in widget view. Then on top of that reusable widget you can wrap with GetBuilder and give its own controller that can have its own data separate.