/* * @author lsy * @date 2020/5/14 **/ import 'package:flutter/material.dart'; class WidgetUtil { static RelativeRect buttonMenuPosition(BuildContext c) { final RenderBox bar = c.findRenderObject(); final RenderBox overlay = Overlay.of(c).context.findRenderObject(); final RelativeRect position = RelativeRect.fromRect( Rect.fromPoints( bar.localToGlobal(bar.size.bottomRight(Offset.zero), ancestor: overlay), bar.localToGlobal(bar.size.bottomRight(Offset.zero), ancestor: overlay), ), Offset.zero & overlay.size, ); return position; } static RelativeRect buttonLeftMenuPosition(BuildContext c) { final RenderBox bar = c.findRenderObject(); final RenderBox overlay = Overlay.of(c).context.findRenderObject(); final RelativeRect position = RelativeRect.fromRect( Rect.fromPoints( bar.localToGlobal(bar.size.bottomLeft(Offset.zero), ancestor: overlay), bar.localToGlobal(bar.size.bottomLeft(Offset.zero), ancestor: overlay), ), Offset.zero & overlay.size, ); return position; } }