I noticed the style error warning pop up in some of my code but also in the some of the official Flutter/Dart documentation/cookbook examples; e.g. at for

... class AnimatedContainerApp extends StatefulWidget { const AnimatedContainerApp({super.key}); @override _AnimatedContainerAppState createState() => _AnimatedContainerAppState(); } class _AnimatedContainerAppState extends State<AnimatedContainerApp> { ... 

example of warning

My understanding of OOP and its nomenclature is sketchy at best and I don't quite understand the warning, but my actual question is, are the examples with this warning wrong, or sub-ideal - or does that style issue only apply in certain contexts that is perhaps not relevant to the examples and or I should ignore it, or is it an result of flutter/dart versions or some such or other?

1 Answer

From the latest docs:

Subclasses should override this method to return a newly created instance of their associated [State] subclass: @override State<MyWidget> createState() => _MyWidgetState(); 

So you should replace

@override _AnimatedContainerAppState createState() => _AnimatedContainerAppState(); 

with

@override State<AnimatedContainerApp> createState() => _AnimatedContainerAppState(); 
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.