Edited: This error only accures on IOS-devices, there is no problem on android.
When I am scrolling my AlertDialog, a RangeError gets caught. I've more AlertDialogs with a plain text and there is no such problem.
While scrolling, the error gets thrown all the time. I know there are similar questions, but they all use a builder and can define a Itemcount.
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
elevation: 20,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
content: Container(
width: double.maxFinite,
height: 130,
child: ListView(children: <Widget>[
RichText(
text: TextSpan(children: [
TextSpan(
text: 'Feedback:',
style: TextStyle(color: Colors.black)),
TextSpan(
text: "
",
style: TextStyle(color: Colors.black)),
WidgetSpan(
child: Icon(
Icons.email,
size: 15,
)),
TextSpan(
text:
' [email protected]' + "
",
style: TextStyle(color: Colors.black)),
TextSpan(
text: "
",
style: TextStyle(color: Colors.black)),
TextSpan(
text: 'Updates:',
style: TextStyle(color: Colors.black)),
TextSpan(
text: "
",
style: TextStyle(color: Colors.black)),
WidgetSpan(
child: Icon(
Icons.link,
size: 15,
)),
TextSpan(
text: ' ',
style: TextStyle(color: Colors.black)),
TextSpan(
style: TextStyle(
color: Colors.blue,
decoration: TextDecoration.underline,
),
text: 'Instagram' + "
",
recognizer: TapGestureRecognizer()
..onTap = () async {
var url =
"https://www.instagram.com/";
if (await canLaunch(url)) {
await launch(url);
} else {
throw "Cannot load Url";
}
}),
TextSpan(
text: "
",
style: TextStyle(color: Colors.black)),
TextSpan(
text: 'Support',
style: TextStyle(color: Colors.black)),
TextSpan(
text: "
",
style: TextStyle(color: Colors.black)),
WidgetSpan(
child: Icon(
Icons.payment,
size: 15,
)),
TextSpan(
text: ' ',
style: TextStyle(color: Colors.black)),
TextSpan(
style: TextStyle(
color: Colors.blue,
decoration: TextDecoration.underline,
),
text: 'Paypal',
recognizer: TapGestureRecognizer()
..onTap = () async {
var url =
"https://www.paypal.me/";
if (await canLaunch(url)) {
await launch(url);
} else {
throw "Cannot load Url";
}
}),
]))
]),
),
);
});
Following the error and the stacktrace:
======== Exception caught by scheduler library =====================================================
The following RangeError was thrown during a scheduler callback:
RangeError (index): Invalid value: Valid value range is empty: 0
When the exception was thrown, this was the stack:
#0 List.[] (dart:core-patch/growable_array.dart:177:60)
#1 List.elementAt (dart:core-patch/growable_array.dart:386:16)
#2 RenderParagraph.assembleSemanticsNode (package:flutter/src/rendering/paragraph.dart:921:50)
#3 _SwitchableSemanticsFragment.compileChildren (package:flutter/src/rendering/object.dart:3717:13)
#4 _SwitchableSemanticsFragment.compileChildren (package:flutter/src/rendering/object.dart:3709:16)
...
Everything else works just fine.Thanks for help!
question from:
https://stackoverflow.com/questions/65648145/listview-throws-error-when-i-am-scrolling