Initial commit
This commit is contained in:
25
lib/utils/position_from_build_context.dart
Normal file
25
lib/utils/position_from_build_context.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
|
||||
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
extension PositionFromBuildContext on BuildContext {
|
||||
RelativeRect get position {
|
||||
final overlay = Overlay.of(this).context.findRenderObject() as RenderBox;
|
||||
|
||||
final button = findRenderObject() as RenderBox;
|
||||
|
||||
return RelativeRect.fromRect(
|
||||
Rect.fromPoints(
|
||||
button.localToGlobal(const Offset(0, -65), ancestor: overlay),
|
||||
button.localToGlobal(
|
||||
button.size.bottomRight(Offset.zero) + const Offset(-50, 0),
|
||||
ancestor: overlay,
|
||||
),
|
||||
),
|
||||
Offset.zero & overlay.size,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user