bottom_modal.dart 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * @Author : WuWei
  3. * @LastEditors : WuWei
  4. * @Date : 2022-11-02 10:26:39
  5. * @LastEditTime : 2023-10-26 19:14:34
  6. * @Description : Do not edit
  7. */
  8. import 'package:flutter/material.dart';
  9. import 'package:wisdom_cli/wisdom_cli.dart';
  10. final _shape = RoundedRectangleBorder(
  11. borderRadius: BorderRadius.only(
  12. topLeft: Radius.circular(20.pt),
  13. topRight: Radius.circular(20.pt),
  14. ),
  15. );
  16. class WBottomModalUtil {
  17. WBottomModalUtil._();
  18. ///弹层
  19. static Future<T?> show<T>(
  20. BuildContext context, {
  21. bool? disabledConfirm,
  22. ///是否只显示关闭按钮
  23. bool? plain = true,
  24. BoxConstraints bodyConstraints = const BoxConstraints(
  25. maxHeight: 500,
  26. minHeight: 400,
  27. ),
  28. Widget? title,
  29. String? confirmText = '确定',
  30. String? cancelText = '取消',
  31. void Function(BuildContext)? onConfirm,
  32. void Function(BuildContext)? onCancel,
  33. Widget? body,
  34. }) {
  35. return showModalBottomSheet<T>(
  36. isScrollControlled: true,
  37. context: context,
  38. builder: (_) => AnimatedPadding(
  39. padding: EdgeInsets.only(
  40. bottom: MediaQuery.of(context).viewInsets.bottom, //软键盘高度
  41. ),
  42. duration: Duration(milliseconds: 100),
  43. child: WBottomModal(
  44. plain: plain!,
  45. bodyConstraints: bodyConstraints,
  46. title: title,
  47. onConfirm: onConfirm,
  48. onCancel: onCancel,
  49. confirmText: confirmText,
  50. cancelText: cancelText,
  51. body: body,
  52. ),
  53. ),
  54. );
  55. }
  56. }