I have a problem with a code snippet I tried to play with, and since I am new to dart I don't really understand the error message. Can somebody explain to me why the error message says
The constructor returns type 'dynamic' that isn't of expected type 'widget'.
and how to fix it?
Constructor is a special method of Dart class which is automatically called when the object is created. The constructor is like a function with/without parameter but it doesn't have a return type.
By using the covariant keyword, you disable the type-check and take responsibility for ensuring that you do not violate the contract in practice. As you can see in the example, if you are overriding a method, its params should also be the same.
Private Constructor – is an exclusive instance constructor that restricts this class from being instantiated in other classes. This class is mainly used when you need to have static members only e.g static variables or static methods.
The class MaterialList
doesn't exist. It looks like maybe you meant TwoLevelList
, which is deprecated. You should try ListView
instead.
If you have other import statements try to use alias as some libraries may be the reason for conflict.
Example: import 'package:html/parser.dart' as parser;
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