Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
487 views
in Technique[技术] by (71.8m points)

flutter - Listview throws error when I am scrolling

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...