update pop menu

null_safety
小赖 4 years ago
parent c8454d4ecc
commit 5c710f5019

@ -15,6 +15,7 @@ class _ExamplePopUpMenuState extends State<ExamplePopUpMenu> {
title: 'PopUpMenu', title: 'PopUpMenu',
body: ListView( body: ListView(
children: [ children: [
SizedBox(height: 500),
ListTile( ListTile(
title: 'PopUpMenu'.text, title: 'PopUpMenu'.text,
trailing: Builder( trailing: Builder(

@ -1,4 +1,3 @@
import 'package:ansu_ui/utils/screen_adapter.dart';
import 'package:ansu_ui/extension/num_extension.dart'; import 'package:ansu_ui/extension/num_extension.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -17,15 +16,17 @@ Future<T> showASPopUpMenu<T>({
T initValue, T initValue,
}) async { }) async {
final RenderBox renderBox = context.findRenderObject(); final RenderBox renderBox = context.findRenderObject();
Offset offset = renderBox.localToGlobal(Offset.zero); Size size = renderBox.size;
return await showMenu( return await showMenu(
context: context, context: context,
initialValue: initValue, initialValue: initValue,
position: RelativeRect.fromLTRB( position: RelativeRect.fromRect(
offset.dx, Rect.fromPoints(
offset.dy, renderBox.localToGlobal(Offset.zero,
screenWidth, ancestor: Overlay.of(context).context.findRenderObject()),
screenHeight, renderBox.localToGlobal(size.bottomRight(Offset.zero)),
),
Offset.zero & Overlay.of(context).context.size,
), ),
items: items, items: items,
shape: RoundedRectangleBorder(borderRadius: 10.radius), shape: RoundedRectangleBorder(borderRadius: 10.radius),

Loading…
Cancel
Save