的数据我已经创建了一个对话框小部件.它会显示错误,当我写AlertDialog.adaptive.withour自适应小部件没有错误.有人知道如何修复这个错误.有谁知道如何修复这个错误。
vtwuwzda1#
首先你需要更新你的flutter版本到3.13或更高版本,因为AlertDialog.adaptive特性是3.13自带的。3.13框架改进-https://medium.com/@ak187429/flutter-3-13-framework-improvements-41be37e925d8。在写作上,作者提到了AlertDialog. adaptive。这里有AlertDialog.adaptive的示例代码
floatingActionButton: FloatingActionButton.extended( label: const Text('Show Alert Dialog Adaptive'), onPressed: () async { final response = await showAdaptiveDialog<bool>( context: context, builder: (context) { return AlertDialog.adaptive( content: const Text('This is an adaptive alert dialog'), actions: [ TextButton( onPressed: () => Navigator.of(context).pop(false), child: const Text('Cancel'), ), TextButton( onPressed: () => Navigator.of(context).pop(true), child: const Text('OK'), ), ], ); }, ); print(response); }, ),
字符串我的Flutter版本- 3.13.8,我的 dart 版本- 3.1.4,这段代码在我的电脑上工作:)
nbysray52#
我运行你的代码什么我没有我声明一个函数showDialoog这里是代码和结果是在截图其工作罚款
showDialoog(BuildContext context)async{ final endExam = await showDialog<bool>( context: context, builder: (context) { return AlertDialog.adaptive( title: const Text("Submit Exam"), content: Text( 'You have time left.\n' 'Are you sure you want to submit?', ), actions: [ TextButton( onPressed: () { Navigator.pop(context, false); }, child: const Text("Cancel"), ), TextButton( onPressed: () { Navigator.pop(context, true); }, child: const Text( "Submit", style: TextStyle(color: Colors.red), ), ), ], ); }, ); }```
字符串
2条答案
按热度按时间vtwuwzda1#
首先你需要更新你的flutter版本到3.13或更高版本,因为AlertDialog.adaptive特性是3.13自带的。3.13框架改进-https://medium.com/@ak187429/flutter-3-13-framework-improvements-41be37e925d8。在写作上,作者提到了AlertDialog. adaptive。这里有AlertDialog.adaptive的示例代码
字符串
我的Flutter版本- 3.13.8,我的 dart 版本- 3.1.4,这段代码在我的电脑上工作:)
nbysray52#
我运行你的代码什么我没有我声明一个函数showDialoog这里是代码和结果是在截图其工作罚款
字符串