Skip to content

Conversation

@miDeb
Copy link

@miDeb miDeb commented Jul 18, 2020

According to the provider documentation:

If you already have an object instance and want to expose it, you should use the .value constructor of a provider.

Failing to do so may call the dispose method of your object when it is still in use.

DO use ChangeNotifierProvider.value to provide an existing ChangeNotifier.

MyChangeNotifier variable;

ChangeNotifierProvider.value(
  value: variable,
  child: ...
)

DON'T reuse an existing ChangeNotifier using the default constructor

MyChangeNotifier variable;

ChangeNotifierProvider(
  create: (_) => variable,
  child: ...
)

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

Successfully merging this pull request may close these issues.

1 participant