我只是尝试了一个源代码,我已经看到网上,我想测试它,但是,它是给我多个错误,因为新的更新小部件。
我尝试运行和执行的源代码是:https://github.com/themaaz32/phone_verification
运行应用程序时显示的错误如下:
lib/screens/login_screen.dart:52:12: Error: The method 'showSnackBar' isn't defined for the class 'ScaffoldState'.
- 'ScaffoldState' is from 'package:flutter/src/material/scaffold.dart' ('/C:/src/flutter/packages/flutter/lib/src/material/scaffold.dart').
Try correcting the name to the name of an existing method, or defining a method named 'showSnackBar'.
.showSnackBar(SnackBar(content: Text(e.message)));
^^^^^^^^^^^^
lib/screens/login_screen.dart:69:9: Error: The method 'FlatButton' isn't defined for the class '_LoginScreenState'.
- '_LoginScreenState' is from 'package:phone_verification/screens/login_screen.dart' ('lib/screens/login_screen.dart').
Try correcting the name to the name of an existing method, or defining a method named 'FlatButton'.
FlatButton(
^^^^^^^^^^
lib/screens/login_screen.dart:87:43: Error: The method 'showSnackBar' isn't defined for the class 'ScaffoldState'.
- 'ScaffoldState' is from 'package:flutter/src/material/scaffold.dart' ('/C:/src/flutter/packages/flutter/lib/src/material/scaffold.dart').
Try correcting the name to the name of an existing method, or defining a method named 'showSnackBar'.
_scaffoldKey.currentState.showSnackBar(
^^^^^^^^^^^^
lib/screens/login_screen.dart:122:9: Error: The method 'FlatButton' isn't defined for the class '_LoginScreenState'.
- '_LoginScreenState' is from 'package:phone_verification/screens/login_screen.dart' ('lib/screens/login_screen.dart').
Try correcting the name to the name of an existing method, or defining a method named 'FlatButton'.
FlatButton(
^^^^^^^^^
新错误
2条答案
按热度按时间a8jjtwal1#
这是因为您的Flutter版本比库的版本新。库仍然使用
FlatButton
,例如,它作为一个破坏性的更改被删除将每个
FlatButton
替换为TextButton
,并显示您可以使用的SnackBar:qltillow2#
我忘了输入材料。