PopoverDemo.dart 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:cool_ui/cool_ui.dart';
  4. class PopoverDemo extends StatefulWidget{
  5. @override
  6. State<StatefulWidget> createState() {
  7. // TODO: implement createState
  8. return PopoverDemoState();
  9. }
  10. }
  11. class PopoverDemoState extends State<PopoverDemo>{
  12. @override
  13. Widget build(BuildContext context) {
  14. // TODO: implement build
  15. return Scaffold(
  16. appBar: AppBar(
  17. title: Text("Popover Demo"),
  18. ),
  19. body: Column(
  20. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  21. mainAxisSize: MainAxisSize.max,
  22. children: <Widget>[
  23. Row(
  24. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  25. mainAxisSize: MainAxisSize.max,
  26. children: <Widget>[
  27. _buildPopoverButton("左上角","左上角内容"),
  28. _buildPopoverButton("右上角","右上角内容")
  29. ],
  30. ),
  31. Center(
  32. child:_buildPopoverButton("中间","中间内容")
  33. ),
  34. Row(
  35. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  36. mainAxisSize: MainAxisSize.max,
  37. children: <Widget>[
  38. _buildPopoverButton("左下角","左下角内容"),
  39. _buildPopoverButton("右下角","右下角内容")
  40. ],
  41. )
  42. ],
  43. ),
  44. );
  45. }
  46. Widget _buildPopoverButton(String btnTitle,String bodyMessage){
  47. return Padding(
  48. padding: EdgeInsets.all(20.0),
  49. child:CupertinoPopoverButton(
  50. child: Container(
  51. width: 80.0,
  52. height: 40.0,
  53. decoration: BoxDecoration(
  54. color: Colors.white,
  55. borderRadius: BorderRadius.all(Radius.circular(5.0)),
  56. boxShadow: [BoxShadow(color: Colors.black12,blurRadius: 5.0)]
  57. ),
  58. child: Center(child:Text(btnTitle)),
  59. ),
  60. popoverBuild: (context) {
  61. return CupertinoPopoverMenuList(
  62. children: <Widget>[
  63. CupertinoPopoverMenuItem(leading: Icon(Icons.add),child: Text("新增"),),
  64. CupertinoPopoverMenuItem(leading: Icon(Icons.edit),child: Text("修改"),),
  65. CupertinoPopoverMenuItem(leading: Icon(Icons.delete),child: Text("删除"),)
  66. ],
  67. );
  68. },
  69. popoverWidth: 150.0,
  70. popoverHeight: 123.0)
  71. );
  72. }
  73. }