pop up menu add initValue

null_safety
小赖 4 years ago
parent d8be0a284f
commit c8454d4ecc

@ -24,8 +24,12 @@ class _ExamplePopUpMenuState extends State<ExamplePopUpMenu> {
onPressed: () {
showASPopUpMenu<int>(
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) {});
},

@ -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;

@ -14,11 +14,13 @@ import 'package:flutter/material.dart';
Future<T> showASPopUpMenu<T>({
@required BuildContext context,
@required List<PopupMenuEntry<T>> 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,

Loading…
Cancel
Save