iOS风格的弹出选择结构,可放多的按钮,一般与CupertinoActionSheetAction联用。

相关组件

CupertinoActionSheetAction

CupertinoActionSheet基本使用

【title】 : 第一行组件 【Widget】
【message】 : 第二行组件 【Widget】
【cancelButton】 : 取消按钮处组件 【Widget】
【actions】 : 中间组件列表 【List
49.gif

  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. class CustomCupertinoActionSheet extends StatelessWidget {
  4. @override
  5. Widget build(BuildContext context) {
  6. return Column(
  7. mainAxisSize: MainAxisSize.min,
  8. children: <Widget>[
  9. _buildRaisedButton(context),
  10. _buildCupertinoActionSheet(context),
  11. ],
  12. );
  13. }
  14. Widget _buildCupertinoActionSheet(BuildContext context) =>
  15. Container(
  16. alignment: Alignment.bottomCenter,
  17. child: CupertinoActionSheet(
  18. title: Text("Please chose a language"),
  19. message: Text('the language you use in this application.'),
  20. cancelButton: CupertinoActionSheetAction(
  21. onPressed: () => Navigator.pop(context), child: Text("Cancel")),
  22. actions: <Widget>[
  23. CupertinoActionSheetAction(
  24. onPressed: () => Navigator.pop(context), child: Text('Dart')),
  25. CupertinoActionSheetAction(
  26. onPressed: () => Navigator.pop(context), child: Text('Java')),
  27. CupertinoActionSheetAction(
  28. onPressed: () => Navigator.pop(context), child: Text('Kotlin')),
  29. ],
  30. ),
  31. );
  32. Widget _buildRaisedButton(BuildContext context) => RaisedButton(
  33. shape: RoundedRectangleBorder(
  34. borderRadius: BorderRadius.all(Radius.circular(10))),
  35. color: Colors.blue,
  36. onPressed: () => showDialog(
  37. context: context,
  38. builder: (ctx) => _buildCupertinoActionSheet(context)),
  39. child: Text(
  40. 'Just Show It !',
  41. style: TextStyle(color: Colors.white),
  42. ),
  43. );
  44. }