popover_demo.dart 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 Text("satatastas");
  70. return CupertinoPopoverMenuList(
  71. children: <Widget>[
  72. CupertinoPopoverMenuItem(leading: Icon(Icons.add),child: Text("新增"),),
  73. CupertinoPopoverMenuItem(leading: Icon(Icons.edit),child: Text("修改"),),
  74. CupertinoPopoverMenuItem(leading: Icon(Icons.delete),child: Text("删除"),)
  75. ],
  76. );
  77. })
  78. );
  79. }
  80. }