Since the release of Flutter 1.12 my following code for restarting the app:
final MyAppState state = context.ancestorStateOfType(const TypeMatcher<MyAppState>()):
warns with the following:
'ancestorStateOfType' is deprecated and shouldn't be used. Use findAncestorStateOfType instead. This feature was deprecated after v1.12.1.. Try replacing the use of the deprecated member with the replacement.
and with
'TypeMatcher' is deprecated and shouldn't be used. TypeMatcher has been deprecated because it is no longer used in framework(only in deprecated methods). This feature was deprecated after v1.12.1.. Try replacing the use of the deprecated member with the replacement.
For some reason I can't seem to figure out how to refactor this code to get it working. Anyone to the rescue?
All you have to do is just put the widget that extends State<StatefulWidget>
so for your example, since the class is called MyAppState
, I'm assuming it extends State<MyApp>
so, therefore:
final MyAppState state = context.findAncestorStateOfType<MyAppState>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With