Flutter调用AlertDialog弹窗时触发RangeError:仅允许有效索引0却取值1
功能开发与问题反馈
已完成的开发内容
- 已实现基础弹窗交互功能,对应代码仓库地址为 first
- 弹窗核心实现代码如下:
void newAlert(BuildContext context) { showDialog( context: context, builder: (BuildContext context){ return AlertDialog( title: Text('title text'), content: Text('content text'), actions: [ FlatButton( onPressed: (){ Navigator.of(context).pop(); }, child: Text('dismiss'), ), ], ); }, ); }
- 已完成弹窗函数所在文件的导入流程,在
main.dart中完成相关依赖引入,页面通过RaisedButton的点击事件触发弹窗调用,触发逻辑代码如下:
body: RaisedButton( child: Text('Alert'), onPressed: () { newAlert(context); }), ...
真机运行异常
在真机环境下点击触发按钮时,应用持续抛出手势库捕获的异常,完整异常日志如下:
======== Exception caught by gesture library ================ The following RangeError was thrown while routing a pointer event: RangeError (index): Invalid value: Only valid value is 0: 1
内容的提问来源于stack exchange,提问作者Mohammad Ali
相关产品推荐
相关产品推荐

