diff --git a/example/lib/example_pop_up_menu.dart b/example/lib/example_pop_up_menu.dart index a632f0f..807b1f9 100644 --- a/example/lib/example_pop_up_menu.dart +++ b/example/lib/example_pop_up_menu.dart @@ -24,8 +24,12 @@ class _ExamplePopUpMenuState extends State { onPressed: () { showASPopUpMenu( context: context, + initValue: 3, items: [ PopupMenuItem(child: 'test'.text, value: 1), + PopupMenuItem(child: 'test'.text, value: 2), + PopupMenuItem(child: 'test'.text, value: 3), + PopupMenuItem(child: 'test'.text, value: 4), ], ).then((value) {}); }, diff --git a/lib/extension/num_extension.dart b/lib/extension/num_extension.dart index 5e0533b..d08d602 100644 --- a/lib/extension/num_extension.dart +++ b/lib/extension/num_extension.dart @@ -14,6 +14,19 @@ extension NumExt on num { ///圆角 BorderRadius get radius => BorderRadius.circular(this.w); + BorderRadius get topRadius => BorderRadius.vertical( + top: Radius.circular(this.w), + ); + BorderRadius get bottomRadius => BorderRadius.vertical( + bottom: Radius.circular(this.w), + ); + BorderRadius get leftRadius => BorderRadius.horizontal( + left: Radius.circular(this.w), + ); + BorderRadius get rightRadius => BorderRadius.horizontal( + right: Radius.circular(this.w), + ); + ///每三位数加逗号 String comma({int fixed = 2}) { bool notUseFixedFlag = fixed == -1; diff --git a/lib/pop_up_menu/pop_up_menu.dart b/lib/pop_up_menu/pop_up_menu.dart index 67c3f77..8e13a4c 100644 --- a/lib/pop_up_menu/pop_up_menu.dart +++ b/lib/pop_up_menu/pop_up_menu.dart @@ -14,11 +14,13 @@ import 'package:flutter/material.dart'; Future showASPopUpMenu({ @required BuildContext context, @required List> items, + T initValue, }) async { final RenderBox renderBox = context.findRenderObject(); Offset offset = renderBox.localToGlobal(Offset.zero); return await showMenu( context: context, + initialValue: initValue, position: RelativeRect.fromLTRB( offset.dx, offset.dy,