为什么 TextFormField 不工作并且键盘不显示在 android 工作室的 iphone 模拟器上
Why is TextFormField Not work and Keyboard not showing on iphone simulator in android studio
注意!!这适用于 google 像素模拟器和我个人的 Android phone
所以我正在为身份验证屏幕创建一个表单。我正在 android 工作室中设置 UI,当我遇到这个障碍时,只是想获得一个简单的表格。出于某种原因,呈现了 iPhone TextFormField,它的验证器也可以工作,但表单本身会产生此错误:
======== Exception caught by services library ======================================================
The following WhosebugError was thrown during a platform message callback:
Stack Overflow
When the exception was thrown, this was the stack:
#0 _StringBase._interpolate (dart:core-patch/string_patch.dart:837:3)
#1 Duration.toString (dart:core/duration.dart:275:25)
#2 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#3 Duration.toString (dart:core/duration.dart:275:25)
#4 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#5 Duration.toString (dart:core/duration.dart:275:25)
#6 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#7 Duration.toString (dart:core/duration.dart:275:25)
#8 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#9 Duration.toString (dart:core/duration.dart:275:25)
#10 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#11 Duration.toString (dart:core/duration.dart:275:25)
#12 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#13 Duration.toString (dart:core/duration.dart:275:25)
#14 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#15 Duration.toString (dart:core/duration.dart:275:25)
#16 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#17 Duration.toString (dart:core/duration.dart:275:25)
#18 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#19 Duration.toString (dart:core/duration.dart:275:25)
#20 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#21 Duration.toString (dart:core/duration.dart:275:25)
#22 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#23 Duration.toString (dart:core/duration.dart:275:25)
#24 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#25 Duration.toString (dart:core/duration.dart:275:25)
#26 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#27 Duration.toString (dart:core/duration.dart:275:25)
#28 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#29 Duration.toString (dart:core/duration.dart:275:25)
#30 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#31 Duration.toString (dart:core/duration.dart:275:25)
#32 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#33 Duration.toString (dart:core/duration.dart:275:25)
#34 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#35 Duration.toString (dart:core/duration.dart:275:25)
#36 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#37 Duration.toString (dart:core/duration.dart:275:25)
#38 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#39 Duration.toString (dart:core/duration.dart:275:25)
#40 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#41 Duration.toString (dart:core/duration.dart:275:25)
#42 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#43 Duration.toString (dart:core/duration.dart:275:25)
...
...
#4513 Duration.toString (dart:core/duration.dart:275:25)
#4514 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4515 Duration.toString (dart:core/duration.dart:275:25)
#4516 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4517 Duration.toString (dart:core/duration.dart:275:25)
#4518 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4519 Duration.toString (dart:core/duration.dart:275:25)
#4520 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4521 Duration.toString (dart:core/duration.dart:275:25)
#4522 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4523 Duration.toString (dart:core/duration.dart:275:25)
#4524 DiagnosticsProperty.valueToString (package:flutter/src/foundation/diagnostics.dart:2741:60)
#4525 DiagnosticsProperty.toDescription (package:flutter/src/foundation/diagnostics.dart:2755:21)
#4526 TextTreeRenderer._debugRender (package:flutter/src/foundation/diagnostics.dart:1194:32)
#4527 TextTreeRenderer.render (package:flutter/src/foundation/diagnostics.dart:1126:14)
#4528 TextTreeRenderer._debugRender (package:flutter/src/foundation/diagnostics.dart:1304:39)
#4529 TextTreeRenderer.render (package:flutter/src/foundation/diagnostics.dart:1126:14)
#4530 DiagnosticsNode.toStringDeep.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1744:9)
#4531 DiagnosticsNode.toStringDeep (package:flutter/src/foundation/diagnostics.dart:1751:6)
#4532 DiagnosticsNode.toString.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1661:18)
#4533 DiagnosticsNode.toString (package:flutter/src/foundation/diagnostics.dart:1673:6)
#4534 Diagnosticable.toString.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:3111:78)
#4535 Diagnosticable.toString (package:flutter/src/foundation/diagnostics.dart:3113:6)
#4536 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4537 HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:437:60)
#4538 HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:452:6)
#4539 HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:543:5)
#4540 KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:821:35)
#4541 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:73:49)
#4542 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:72:47)
#4543 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:379:35)
#4544 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:376:46)
#4545 _invoke2.<anonymous closure> (dart:ui/hooks.dart:205:15)
#4548 _invoke2 (dart:ui/hooks.dart:204:10)
#4549 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#4550 _Channel.push (dart:ui/channel_buffers.dart:132:31)
#4551 ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#4552 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:544:22)
#4553 _dispatchPlatformMessage (dart:ui/hooks.dart:92:31)
(elided 2 frames from dart:async)
====================================================================================================
======== Exception caught by services library ======================================================
The following WhosebugError was thrown during a platform message callback:
Stack Overflow
When the exception was thrown, this was the stack:
#0 _StringBase._interpolate (dart:core-patch/string_patch.dart:837:3)
#1 Duration.toString (dart:core/duration.dart:275:25)
#2 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#3 Duration.toString (dart:core/duration.dart:275:25)
#4 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#5 Duration.toString (dart:core/duration.dart:275:25)
#6 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#7 Duration.toString (dart:core/duration.dart:275:25)
#8 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#9 Duration.toString (dart:core/duration.dart:275:25)
#10 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#11 Duration.toString (dart:core/duration.dart:275:25)
#12 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#13 Duration.toString (dart:core/duration.dart:275:25)
#14 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#15 Duration.toString (dart:core/duration.dart:275:25)
#16 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#17 Duration.toString (dart:core/duration.dart:275:25)
#18 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#19 Duration.toString (dart:core/duration.dart:275:25)
#20 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#21 Duration.toString (dart:core/duration.dart:275:25)
#22 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#23 Duration.toString (dart:core/duration.dart:275:25)
#24 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#25 Duration.toString (dart:core/duration.dart:275:25)
#26 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#27 Duration.toString (dart:core/duration.dart:275:25)
#28 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#29 Duration.toString (dart:core/duration.dart:275:25)
#30 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#31 Duration.toString (dart:core/duration.dart:275:25)
#32 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#33 Duration.toString (dart:core/duration.dart:275:25)
#34 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#35 Duration.toString (dart:core/duration.dart:275:25)
#36 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#37 Duration.toString (dart:core/duration.dart:275:25)
#38 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#39 Duration.toString (dart:core/duration.dart:275:25)
#40 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#41 Duration.toString (dart:core/duration.dart:275:25)
#42 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#43 Duration.toString (dart:core/duration.dart:275:25)
...
...
#4513 Duration.toString (dart:core/duration.dart:275:25)
#4514 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4515 Duration.toString (dart:core/duration.dart:275:25)
#4516 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4517 Duration.toString (dart:core/duration.dart:275:25)
#4518 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4519 Duration.toString (dart:core/duration.dart:275:25)
#4520 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4521 Duration.toString (dart:core/duration.dart:275:25)
#4522 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4523 Duration.toString (dart:core/duration.dart:275:25)
#4524 DiagnosticsProperty.valueToString (package:flutter/src/foundation/diagnostics.dart:2741:60)
#4525 DiagnosticsProperty.toDescription (package:flutter/src/foundation/diagnostics.dart:2755:21)
#4526 TextTreeRenderer._debugRender (package:flutter/src/foundation/diagnostics.dart:1194:32)
#4527 TextTreeRenderer.render (package:flutter/src/foundation/diagnostics.dart:1126:14)
#4528 TextTreeRenderer._debugRender (package:flutter/src/foundation/diagnostics.dart:1304:39)
#4529 TextTreeRenderer.render (package:flutter/src/foundation/diagnostics.dart:1126:14)
#4530 DiagnosticsNode.toStringDeep.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1744:9)
#4531 DiagnosticsNode.toStringDeep (package:flutter/src/foundation/diagnostics.dart:1751:6)
#4532 DiagnosticsNode.toString.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1661:18)
#4533 DiagnosticsNode.toString (package:flutter/src/foundation/diagnostics.dart:1673:6)
#4534 Diagnosticable.toString.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:3111:78)
#4535 Diagnosticable.toString (package:flutter/src/foundation/diagnostics.dart:3113:6)
#4536 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4537 HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:437:60)
#4538 HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:452:6)
#4539 HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:543:5)
#4540 KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:821:35)
#4541 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:73:49)
#4542 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:72:47)
#4543 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:379:35)
#4544 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:376:46)
#4545 _invoke2.<anonymous closure> (dart:ui/hooks.dart:205:15)
#4548 _invoke2 (dart:ui/hooks.dart:204:10)
#4549 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#4550 _Channel.push (dart:ui/channel_buffers.dart:132:31)
#4551 ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#4552 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:544:22)
#4553 _dispatchPlatformMessage (dart:ui/hooks.dart:92:31)
(elided 2 frames from dart:async)
====================================================================================================
我已经多次重新启动我的项目,但错误仍然存在。有人可以帮我解决这个问题吗?
这是我的代码:
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text(
"Login",
),
),
body: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
TextFormField(
keyboardType: TextInputType.text,
decoration: const InputDecoration(
hintText: 'Enter your email',
),
validator: (String? value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';
}
return null;
},
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: ElevatedButton(
onPressed: () {
// Validate will return true if the form is valid, or false if
// the form is invalid.
if (_formKey.currentState!.validate()) {
// Process data.
}
},
child: const Text('Submit'),
),
),
],
),
)
);
}
切换到Flutter稳定版解决问题
flutter channel stable
此外,确保通过运行此命令
升级到最新版本的Flutter
flutter upgrade
谢谢
注意!!这适用于 google 像素模拟器和我个人的 Android phone
所以我正在为身份验证屏幕创建一个表单。我正在 android 工作室中设置 UI,当我遇到这个障碍时,只是想获得一个简单的表格。出于某种原因,呈现了 iPhone TextFormField,它的验证器也可以工作,但表单本身会产生此错误:
======== Exception caught by services library ======================================================
The following WhosebugError was thrown during a platform message callback:
Stack Overflow
When the exception was thrown, this was the stack:
#0 _StringBase._interpolate (dart:core-patch/string_patch.dart:837:3)
#1 Duration.toString (dart:core/duration.dart:275:25)
#2 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#3 Duration.toString (dart:core/duration.dart:275:25)
#4 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#5 Duration.toString (dart:core/duration.dart:275:25)
#6 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#7 Duration.toString (dart:core/duration.dart:275:25)
#8 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#9 Duration.toString (dart:core/duration.dart:275:25)
#10 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#11 Duration.toString (dart:core/duration.dart:275:25)
#12 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#13 Duration.toString (dart:core/duration.dart:275:25)
#14 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#15 Duration.toString (dart:core/duration.dart:275:25)
#16 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#17 Duration.toString (dart:core/duration.dart:275:25)
#18 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#19 Duration.toString (dart:core/duration.dart:275:25)
#20 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#21 Duration.toString (dart:core/duration.dart:275:25)
#22 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#23 Duration.toString (dart:core/duration.dart:275:25)
#24 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#25 Duration.toString (dart:core/duration.dart:275:25)
#26 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#27 Duration.toString (dart:core/duration.dart:275:25)
#28 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#29 Duration.toString (dart:core/duration.dart:275:25)
#30 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#31 Duration.toString (dart:core/duration.dart:275:25)
#32 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#33 Duration.toString (dart:core/duration.dart:275:25)
#34 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#35 Duration.toString (dart:core/duration.dart:275:25)
#36 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#37 Duration.toString (dart:core/duration.dart:275:25)
#38 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#39 Duration.toString (dart:core/duration.dart:275:25)
#40 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#41 Duration.toString (dart:core/duration.dart:275:25)
#42 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#43 Duration.toString (dart:core/duration.dart:275:25)
...
...
#4513 Duration.toString (dart:core/duration.dart:275:25)
#4514 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4515 Duration.toString (dart:core/duration.dart:275:25)
#4516 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4517 Duration.toString (dart:core/duration.dart:275:25)
#4518 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4519 Duration.toString (dart:core/duration.dart:275:25)
#4520 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4521 Duration.toString (dart:core/duration.dart:275:25)
#4522 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4523 Duration.toString (dart:core/duration.dart:275:25)
#4524 DiagnosticsProperty.valueToString (package:flutter/src/foundation/diagnostics.dart:2741:60)
#4525 DiagnosticsProperty.toDescription (package:flutter/src/foundation/diagnostics.dart:2755:21)
#4526 TextTreeRenderer._debugRender (package:flutter/src/foundation/diagnostics.dart:1194:32)
#4527 TextTreeRenderer.render (package:flutter/src/foundation/diagnostics.dart:1126:14)
#4528 TextTreeRenderer._debugRender (package:flutter/src/foundation/diagnostics.dart:1304:39)
#4529 TextTreeRenderer.render (package:flutter/src/foundation/diagnostics.dart:1126:14)
#4530 DiagnosticsNode.toStringDeep.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1744:9)
#4531 DiagnosticsNode.toStringDeep (package:flutter/src/foundation/diagnostics.dart:1751:6)
#4532 DiagnosticsNode.toString.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1661:18)
#4533 DiagnosticsNode.toString (package:flutter/src/foundation/diagnostics.dart:1673:6)
#4534 Diagnosticable.toString.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:3111:78)
#4535 Diagnosticable.toString (package:flutter/src/foundation/diagnostics.dart:3113:6)
#4536 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4537 HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:437:60)
#4538 HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:452:6)
#4539 HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:543:5)
#4540 KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:821:35)
#4541 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:73:49)
#4542 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:72:47)
#4543 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:379:35)
#4544 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:376:46)
#4545 _invoke2.<anonymous closure> (dart:ui/hooks.dart:205:15)
#4548 _invoke2 (dart:ui/hooks.dart:204:10)
#4549 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#4550 _Channel.push (dart:ui/channel_buffers.dart:132:31)
#4551 ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#4552 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:544:22)
#4553 _dispatchPlatformMessage (dart:ui/hooks.dart:92:31)
(elided 2 frames from dart:async)
====================================================================================================
======== Exception caught by services library ======================================================
The following WhosebugError was thrown during a platform message callback:
Stack Overflow
When the exception was thrown, this was the stack:
#0 _StringBase._interpolate (dart:core-patch/string_patch.dart:837:3)
#1 Duration.toString (dart:core/duration.dart:275:25)
#2 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#3 Duration.toString (dart:core/duration.dart:275:25)
#4 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#5 Duration.toString (dart:core/duration.dart:275:25)
#6 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#7 Duration.toString (dart:core/duration.dart:275:25)
#8 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#9 Duration.toString (dart:core/duration.dart:275:25)
#10 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#11 Duration.toString (dart:core/duration.dart:275:25)
#12 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#13 Duration.toString (dart:core/duration.dart:275:25)
#14 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#15 Duration.toString (dart:core/duration.dart:275:25)
#16 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#17 Duration.toString (dart:core/duration.dart:275:25)
#18 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#19 Duration.toString (dart:core/duration.dart:275:25)
#20 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#21 Duration.toString (dart:core/duration.dart:275:25)
#22 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#23 Duration.toString (dart:core/duration.dart:275:25)
#24 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#25 Duration.toString (dart:core/duration.dart:275:25)
#26 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#27 Duration.toString (dart:core/duration.dart:275:25)
#28 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#29 Duration.toString (dart:core/duration.dart:275:25)
#30 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#31 Duration.toString (dart:core/duration.dart:275:25)
#32 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#33 Duration.toString (dart:core/duration.dart:275:25)
#34 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#35 Duration.toString (dart:core/duration.dart:275:25)
#36 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#37 Duration.toString (dart:core/duration.dart:275:25)
#38 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#39 Duration.toString (dart:core/duration.dart:275:25)
#40 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#41 Duration.toString (dart:core/duration.dart:275:25)
#42 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#43 Duration.toString (dart:core/duration.dart:275:25)
...
...
#4513 Duration.toString (dart:core/duration.dart:275:25)
#4514 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4515 Duration.toString (dart:core/duration.dart:275:25)
#4516 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4517 Duration.toString (dart:core/duration.dart:275:25)
#4518 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4519 Duration.toString (dart:core/duration.dart:275:25)
#4520 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4521 Duration.toString (dart:core/duration.dart:275:25)
#4522 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4523 Duration.toString (dart:core/duration.dart:275:25)
#4524 DiagnosticsProperty.valueToString (package:flutter/src/foundation/diagnostics.dart:2741:60)
#4525 DiagnosticsProperty.toDescription (package:flutter/src/foundation/diagnostics.dart:2755:21)
#4526 TextTreeRenderer._debugRender (package:flutter/src/foundation/diagnostics.dart:1194:32)
#4527 TextTreeRenderer.render (package:flutter/src/foundation/diagnostics.dart:1126:14)
#4528 TextTreeRenderer._debugRender (package:flutter/src/foundation/diagnostics.dart:1304:39)
#4529 TextTreeRenderer.render (package:flutter/src/foundation/diagnostics.dart:1126:14)
#4530 DiagnosticsNode.toStringDeep.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1744:9)
#4531 DiagnosticsNode.toStringDeep (package:flutter/src/foundation/diagnostics.dart:1751:6)
#4532 DiagnosticsNode.toString.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:1661:18)
#4533 DiagnosticsNode.toString (package:flutter/src/foundation/diagnostics.dart:1673:6)
#4534 Diagnosticable.toString.<anonymous closure> (package:flutter/src/foundation/diagnostics.dart:3111:78)
#4535 Diagnosticable.toString (package:flutter/src/foundation/diagnostics.dart:3113:6)
#4536 _StringBase._interpolate (dart:core-patch/string_patch.dart:846:19)
#4537 HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:437:60)
#4538 HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:452:6)
#4539 HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:543:5)
#4540 KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:821:35)
#4541 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:73:49)
#4542 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:72:47)
#4543 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:379:35)
#4544 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:376:46)
#4545 _invoke2.<anonymous closure> (dart:ui/hooks.dart:205:15)
#4548 _invoke2 (dart:ui/hooks.dart:204:10)
#4549 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#4550 _Channel.push (dart:ui/channel_buffers.dart:132:31)
#4551 ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#4552 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:544:22)
#4553 _dispatchPlatformMessage (dart:ui/hooks.dart:92:31)
(elided 2 frames from dart:async)
====================================================================================================
我已经多次重新启动我的项目,但错误仍然存在。有人可以帮我解决这个问题吗?
这是我的代码:
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text(
"Login",
),
),
body: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
TextFormField(
keyboardType: TextInputType.text,
decoration: const InputDecoration(
hintText: 'Enter your email',
),
validator: (String? value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';
}
return null;
},
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: ElevatedButton(
onPressed: () {
// Validate will return true if the form is valid, or false if
// the form is invalid.
if (_formKey.currentState!.validate()) {
// Process data.
}
},
child: const Text('Submit'),
),
),
],
),
)
);
}
切换到Flutter稳定版解决问题
flutter channel stable
此外,确保通过运行此命令
升级到最新版本的Flutterflutter upgrade
谢谢