1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| import 'package:flutter/material.dart';
class AppBottomSheet extends StatelessWidget { const AppBottomSheet({Key? key}) : super(key: key);
Future<bool?> showAppAlertDialog(context) { return showDialog( context: context, builder: (context) => AlertDialog( title: const Text('确定提交'), content: const Text('提交以后无法恢复,确定提交吗?'), actions: [ TextButton( onPressed: () => Navigator.pop(context, false), child: const Text('取消'), ), TextButton( onPressed: () => Navigator.pop(context, true), child: const Text('确定'), ), ], ), ); }
void showAppSnackBar(context) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: const Text('提交成功'), action: SnackBarAction( label: '关闭', onPressed: () {}, ), duration: const Duration(seconds: 3), ), ); }
@override Widget build(BuildContext context) { return Container( height: 350, decoration: BoxDecoration( color: Theme.of(context).colorScheme.background, boxShadow: const [ BoxShadow( color: Colors.black12, offset: Offset(0, -20), blurRadius: 30, ), ], ), child: Center( child: TextButton( onPressed: () async { final result = await showAppAlertDialog(context); print('showAppAlertDialog: $result');
if (result != null && result) { showAppSnackBar(context); } }, child: const Text('提交'), ), ), ); } }
|