cupertino_popover_menu_item.dart 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. part of cool_ui;
  2. class CupertinoPopoverMenuList extends StatelessWidget{
  3. final List<Widget> children;
  4. const CupertinoPopoverMenuList({this.children});
  5. @override
  6. Widget build(BuildContext context) {
  7. return ListView.builder(
  8. itemCount: children.length * 2 - 1,
  9. itemBuilder: (context,int i){
  10. if(i.isOdd){
  11. // 在每一列之前,添加一个1像素高的分隔线widget
  12. return const Divider(height: 1.0,);
  13. }
  14. final int index=i ~/2;
  15. return children[index];
  16. },
  17. padding: EdgeInsets.all(0.0),
  18. );
  19. }
  20. }
  21. class CupertinoPopoverMenuItem extends StatelessWidget{
  22. final Widget leading;
  23. final Widget child;
  24. const CupertinoPopoverMenuItem({this.leading,this.child});
  25. @override
  26. Widget build(BuildContext context) {
  27. List<Widget> widgets = [];
  28. if(leading != null){
  29. widgets.add(Container(
  30. padding: EdgeInsets.only(left:5.0,right: 5.0),
  31. width: 35.0,
  32. height: 35.0,
  33. child: IconTheme(
  34. data:IconThemeData(color: Color(0xff007aff),size: 20.0),
  35. child: leading
  36. ),
  37. ));
  38. }
  39. widgets.add(Expanded(child: DefaultTextStyle(style: TextStyle(
  40. color: Color(0xff007aff),
  41. fontSize: 17.0
  42. ), child: child)));
  43. return Padding(
  44. padding: EdgeInsets.only(top:2.5,bottom: 2.5),
  45. child: Row(
  46. children: widgets
  47. ),
  48. );
  49. }
  50. }