popover_demo.dart 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. _buildPopoverButton("右上角","右上角内容")
  30. ],
  31. ),
  32. Row(
  33. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  34. mainAxisSize: MainAxisSize.max,
  35. children:<Widget>[
  36. _buildPopoverButton("中间左方","中间左方内容"),
  37. _buildPopoverButton("正中间","正中间内容"),
  38. _buildPopoverButton("中间左方","中间左方内容")
  39. ]
  40. ),
  41. Row(
  42. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  43. mainAxisSize: MainAxisSize.max,
  44. children: <Widget>[
  45. _buildPopoverButton("左下角","左下角内容"),
  46. _buildPopoverButton("中间下方","中间下方内容"),
  47. _buildPopoverButton("右下角","右下角内容")
  48. ],
  49. )
  50. ],
  51. ),
  52. );
  53. }
  54. Widget _buildPopoverButton(String btnTitle,String bodyMessage){
  55. return Padding(
  56. padding: EdgeInsets.all(20.0),
  57. child:CupertinoPopoverButton(
  58. child: Container(
  59. width: 80.0,
  60. height: 40.0,
  61. decoration: BoxDecoration(
  62. color: Colors.white,
  63. borderRadius: BorderRadius.all(Radius.circular(5.0)),
  64. boxShadow: [BoxShadow(color: Colors.black12,blurRadius: 5.0)]
  65. ),
  66. child: Center(child:Text(btnTitle)),
  67. ),
  68. popoverBuild: (context) {
  69. return CupertinoPopoverMenuList(
  70. children: <Widget>[
  71. CupertinoPopoverMenuItem(leading: Icon(Icons.add),child: Text("新增"),),
  72. CupertinoPopoverMenuItem(leading: Icon(Icons.edit),child: Text("修改"),),
  73. CupertinoPopoverMenuItem(leading: Icon(Icons.delete),child: Text("删除"),)
  74. ],
  75. );
  76. },
  77. popoverWidth: 150.0,
  78. popoverHeight: 123.0)
  79. );
  80. }
  81. }