我正在整理一个演示应用程序,以帮助我学习 Flutter 的各种功能,但目前,我遇到了以前从未遇到过的重复错误。
每次我在任何模拟器(Android 或 iOS)上的 Android Studio 中构建应用程序时,都会生成一个错误:
“颜色”类型不是“材料颜色”类型的子类型
这是异常和控制台输出:
Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Running Xcode build...
Xcode build done. 16.9s
flutter: ??? EXCEPTION CAUGHT BY WIDGETS LIBRARY ????????????????????????????????????????????????????????????
flutter: The following assertion was thrown building MyApp(dirty):
flutter: type 'Color' is not a subtype of type 'MaterialColor'
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help …Run Code Online (Sandbox Code Playgroud) I've got a TextField in my flutter app, for help inputting numbers for a calculator function. For this TextField, I have set the keyboard to be numbers only, using
keyboardType: TextInputType.number
Now, this works perfectly, in a sense that it ensures only the number input keyboard appears. This keyboard allows the user to input numbers from 0 to 9, as well as a decimal point. The problem is, it doesn't stop users inputting multiple decimal points. Once a user adds …