PopoverDemo.dart 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import 'package:cool_ui_example/cool_u_i_example_icons.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:cool_ui/cool_ui.dart';
  5. class PopoverDemo extends StatefulWidget{
  6. @override
  7. State<StatefulWidget> createState() {
  8. // TODO: implement createState
  9. return PopoverDemoState();
  10. }
  11. }
  12. class PopoverDemoState extends State<PopoverDemo>{
  13. @override
  14. Widget build(BuildContext context) {
  15. // TODO: implement build
  16. return Scaffold(
  17. appBar: AppBar(
  18. title: Text("Popover Demo"),
  19. ),
  20. body: Column(
  21. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  22. mainAxisSize: MainAxisSize.max,
  23. children: <Widget>[
  24. Row(
  25. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  26. mainAxisSize: MainAxisSize.max,
  27. children: <Widget>[
  28. _buildPopoverButton("左上角","左上角内容"),
  29. _buildPopoverButton("右上角","右上角内容")
  30. ],
  31. ),
  32. Center(
  33. child:_buildPopoverButton("中间","中间内容")
  34. ),
  35. Row(
  36. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  37. mainAxisSize: MainAxisSize.max,
  38. children: <Widget>[
  39. _buildPopoverButton("左下角","左下角内容"),
  40. _buildPopoverButton("右下角","右下角内容")
  41. ],
  42. )
  43. ],
  44. ),
  45. );
  46. }
  47. Widget _buildPopoverButton(String btnTitle,String bodyMessage){
  48. return CupertinoPopoverButton(
  49. child: Container(
  50. margin: EdgeInsets.all(20.0),
  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. popoverBody:Container(
  61. // color: Colors.lightBlue,
  62. width: 100.0,
  63. height: 100.0,
  64. child: Text(bodyMessage),
  65. ),
  66. popoverWidth: 100.0,
  67. popoverHeight: 100.0);
  68. }
  69. }