【发布时间】:2022-01-12 23:13:28
【问题描述】:
我正在尝试使用 firebase 修改旧的基本购物应用程序,但它的旧版本代码无法准确获得 null 安全性。任何人都可以帮助我。在这里我得到“不可为空的实例字段'_selectedParam'必须被初始化”对于'数据库'我也得到同样的错误。对于“列表”,我得到“启用空安全性时,默认的“列表”构造函数不可用。”错误。
class MyApp extends StatefulWidget {
MyApp(this.k);
final int k;
@override
_MyAppState createState() => _MyAppState(k);
}
class _MyAppState extends State<MyApp> {
CollectionReference games= FirebaseFirestore.instance.collection("games");
_MyAppState(this.k);
final int k ;
static Future<Database> database ;
var receivePort = ReceivePort();
Isolate _isolate;
final String url = "https://www.freetogame.com/api/games";
List data ;
static List listpvp= new List(); static List listmmorpg= new List(); static List listmmofps= new List(); static List listshooter = new List();
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
String _selectedParam;
int val;
String task;
static String _col="mmofps"; //initially
【问题讨论】: