Move from ProviderListener to ref.listen #562
Answered
by
julienlebren
julienlebren
asked this question in
Q&A
-
👋 I was using the following code to listen a provider with class SettingsPhonePage extends ConsumerWidget {
const SettingsPhonePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
return ProviderListener<SettingsPhoneState>(
provider: settingsPhoneControllerProvider,
onChange: (context, state) async {
if (state.errorText != null) {
showFirestoreErrorDialog(context, ref);
} else if (state.verificationId != null) {
Navigator.of(context).pushNamed(SettingsRoutes.verificationPage);
}
},
child: const _PageContents(),
);
}
} I did not find any examples of the new class SettingsPhonePage extends ConsumerWidget {
const SettingsPhonePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
ref.listen<SettingsPhoneState>(settingsPhoneControllerProvider, (state) {
if (state.errorText != null) {
showFirestoreErrorDialog(context, ref);
} else if (state.verificationId != null) {
Navigator.of(context).pushNamed(SettingsRoutes.verificationPage);
}
});
return const _PageContents();
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
julienlebren
Jul 2, 2021
Replies: 1 comment 8 replies
-
@rrousselGit can I get your confirmation to rewrite all my |
Beta Was this translation helpful? Give feedback.
8 replies
Answer selected by
julienlebren
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@rrousselGit can I get your confirmation to rewrite all my
ProviderListener
? 🙏🏻