Flutter2.2中提示 The parameter 'key' can't have a value of 'null' because of its type

Flutter2.2中提示 The parameter ‘key’ can’t have a value of ‘null’ because of its type, but the implicit default value is ‘null’. Try adding either an explicit non-‘null’ default value or the ‘required’ 解决方案

22.jpg

解决办法:

实例化的时候把Key配置成可选参数

class PayPage extends StatefulWidget {
  PayPage({Key? key}) : super(key: key);

  _PayPageState createState() => _PayPageState();
}

3333.jpg


更多关于Flutter2.2中提示 The parameter 'key' can't have a value of 'null' because of its type的实战教程也可以访问 https://www.itying.com/category-92-b0.html

回到顶部