Summary of Flutter self-study problems (long-term update)

1.The argument type 'Color?' can't be assigned to the parameter type 'Color'

just change it

 color: (Colors.blue[300])!,

This is Null saftya feature in dart. For more information check out this link

https://medium.com/flutter/null-safety-flutter-tech-preview-cb5c98aba187

 2.Try adding either an explicit non-‘null‘ default value or the ‘required‘ modifier.

The higher version dart syntax requires that it cannot be empty,

If you report this error or add the Require keyword to emphasize that it cannot be empty,

Either add a non-empty identifier "?" For example :

3. Writing method of singleton after dart2.0 (dart singleton mode of flutter2.12.0 version)

class Singleton{

  Singleton._privateConstructor();

  static final Singleton _instance = Singleton._privateConstructor();

  static Singleton get instance { return _instance;}

}

or it can be written like this

 

Guess you like

Origin blog.csdn.net/iblue007/article/details/124376996