Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disposing provided controllers. #419

Open
dickermoshe opened this issue Jun 7, 2024 · 0 comments
Open

Disposing provided controllers. #419

dickermoshe opened this issue Jun 7, 2024 · 0 comments

Comments

@dickermoshe
Copy link

Regular flutter widgets don't typically dispose of controllers they are explicitly provided.
I was wondering why I was getting errors when disposing TextEditingControllers and the MoonCarouselScrollController.

Turns out, that MoonCarousel will dispose MoonCarouselScrollController even if it was passed explicity.

A MoonCarouselScrollController was used after being disposed.

The same is true for MoonAuthCode, where Im getting this error when disposing:

Once you have called dispose() on a TextEditingController, it can no longer be used.

I would suggest adding the following:

void _initializeTextEditingController() {
  _textEditingController = widget.textController ?? TextEditingController();
  _isPrivateTextEditingController = widget.textController == null;
//...
}
//...
@override
  void dispose() {
    if (_isPrivateTextEditingController){
     _textEditingController.dispose();
   }
   //...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant