小心!!这适用于谷歌像素模拟器和我的个人安卓手机
所以我正在为身份验证屏幕创建一个表单。我在 android studio 中设置 UI,只是想在遇到这个障碍时创建一个简单的表单。出于某种原因,iPhone TextFormField 被渲染了,它的验证器也可以工作,但是表单本身会产生这个错误:
======== Exception caught by services library ======================================================
The following StackOverflowError 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 StackOverflowError 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'),
),
),
],
),
)
);
}