gpt4 book ai didi

Flutter断言失败: line 3105 pos 16: 'node.parent == null || !node.parent!.isPartOfNodeMerging || node.isMergedIntoParent' : is not true

转载 作者:行者123 更新时间:2023-12-03 07:57:57 24 4
gpt4 key购买 nike

我在 Flutter 中有代码:

  Widget build(BuildContext context) {
return ListView(
children: [
Container(
margin: EdgeInsets.only(left: 15, right: 15, top: 30),
child: Text("Enter your phone",
style: TextStyle(fontSize: 16)),
),
Container(
margin: EdgeInsets.only(left: 15, right: 15),
child: TextField(
controller: phoneNumber,
keyboardType: TextInputType.number,
autofillHints: [AutofillHints.telephoneNumberNational],
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly,
],
decoration: InputDecoration(
border: UnderlineInputBorder(),
labelText: "Phone",
labelStyle: TextStyle(color: Colors.black),
icon: Icon(Icons.phone_outlined),
),
),
),

Container(
margin: EdgeInsets.only(left: 15, right: 15, top: 20),
child: Text("You will receive code in SMS",
style: TextStyle(fontSize: 16)),
),
Container(
margin: EdgeInsets.only(right: 15, top: 20),
child:
CheckboxListTile(
title: RichText(
text: TextSpan(
children: [
TextSpan(
text: 'I agree GDPR',
style: TextStyle(color: Colors.black),
),
TextSpan(
text: ' available HERE',
style: TextStyle(color: mainAppColor),
recognizer: TapGestureRecognizer()..onTap = () async{
await launchUrl(Uri.parse('https://xy.com/gdpr.pdf'), mode: LaunchMode.externalApplication);
},
)
],
),
),
value: acceptedGDPR,
onChanged: (newValue) {
setState(() {
acceptedGDPR = newValue!;
});
},
controlAffinity: ListTileControlAffinity.leading,
)
),

Container(
margin: EdgeInsets.only(left: 15, right: 15, top: 20),
child: RichText(
text: TextSpan(
children: [
TextSpan(
text: 'gdpr',
style: TextStyle(color: Colors.black, fontSize: 16),
),
TextSpan(
text: ' read more here',
recognizer: TapGestureRecognizer()..onTap = () async{
await launchUrl(Uri.parse('https://xy.com/gdpr.pdf'), mode: LaunchMode.externalApplication);
},
style: TextStyle(color: mainAppColor, fontSize: 16),
)
],
),
),
),
],
);
}

一切都运行得很好。但每次当我打开这个 Stateful Widget 时,我都会收到以下错误消息:

The following assertion was thrown during a scheduler callback:
'package:flutter/src/semantics/semantics.dart': Failed assertion: line 3105 pos 16: 'node.parent == null || !node.parent!.isPartOfNodeMerging || node.isMergedIntoParent': is not true.


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.md

When the exception was thrown, this was the stack:
#2 SemanticsOwner.sendSemanticsUpdate (package:flutter/src/semantics/semantics.dart:3105:16)
#3 PipelineOwner.flushSemantics (package:flutter/src/rendering/object.dart:1246:24)
#4 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:521:21)
#5 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:865:13)
#6 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:381:5)
#7 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1289:15)
#8 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1218:9)
#9 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:942:7)
#13 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)
(elided 5 frames from class _AssertionError, class _Timer, and dart:async-patch)

经过一番调查,我发现了此错误的根源(在 CheckboxListTile 中,而不是在最后一个容器中):

recognizer: TapGestureRecognizer()..onTap = () async{
//await launchUrl... this line is not causing the error
},

当我从 TextSpan 中删除此识别器时,错误不再显示。但我需要它在那里。那么,当一切正常时,为什么会出现此错误以及如何修复它?感谢您的所有建议:)

最佳答案

自 2020 年以来,这是一个悬而未决的问题:https://github.com/flutter/flutter/issues/54665

在线程中有一些解决方法,例如将 RichText 包装在 ExcludeSemantics 中,这也应该适用于您的情况。

希望这有帮助。

关于Flutter断言失败: line 3105 pos 16: 'node.parent == null || !node.parent!.isPartOfNodeMerging || node.isMergedIntoParent' : is not true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75547986/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com