common_popup.dart 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import 'dart:ui';
  2. import 'package:electronic_assistant/utils/expand.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_screenutil/flutter_screenutil.dart';
  6. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  7. void showCommonPopup(
  8. Offset offset, Alignment alignment, List<Widget> childWidget,
  9. {String? tag, BuildContext? context}) {
  10. SmartDialog.showAttach(
  11. targetContext: null,
  12. targetBuilder: (_, __) => offset,
  13. animationType: SmartAnimationType.fade,
  14. clickMaskDismiss: true,
  15. alignment: alignment,
  16. bindWidget: context,
  17. tag: tag,
  18. maskColor: Colors.transparent,
  19. builder: (_) {
  20. return IntrinsicWidth(
  21. child: Container(
  22. constraints: BoxConstraints(
  23. minWidth: 128.w,
  24. ),
  25. decoration: BoxDecoration(
  26. color: Colors.white,
  27. border: Border.all(color: '#D8D8D8'.toColor(), width: 1), // 边框
  28. borderRadius: BorderRadius.circular(8), // 圆角
  29. boxShadow: [
  30. BoxShadow(
  31. color: Colors.black.withOpacity(0.1), // 阴影颜色
  32. spreadRadius: 2, // 阴影扩散半径
  33. blurRadius: 6, // 阴影模糊半径
  34. offset: const Offset(0, 3), // 阴影偏移量
  35. ),
  36. ],
  37. ),
  38. child: Column(
  39. children: childWidget,
  40. ),
  41. ),
  42. );
  43. },
  44. );
  45. }