Skip to content

Commit 8e09d9b

Browse files
show two widget at one
1 parent 22aa987 commit 8e09d9b

8 files changed

+389
-245
lines changed

example/ios/Runner.xcodeproj/project.pbxproj

+1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
files = (
187187
);
188188
inputPaths = (
189+
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
189190
);
190191
name = "Thin Binary";
191192
outputPaths = (

example/lib/main.dart

+196-188
Large diffs are not rendered by default.

lib/src/get_position.dart

+7-10
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@
2323
import 'package:flutter/material.dart';
2424

2525
class GetPosition {
26-
final GlobalKey? key;
26+
final GlobalKey key;
2727
final EdgeInsets padding;
2828
final double? screenWidth;
2929
final double? screenHeight;
3030

3131
GetPosition({
32-
this.key,
32+
required this.key,
3333
this.padding = EdgeInsets.zero,
3434
this.screenWidth,
3535
this.screenHeight,
3636
});
3737

3838
Rect getRect() {
39-
final box = key!.currentContext!.findRenderObject() as RenderBox;
39+
late final box = key.currentContext?.findRenderObject() as RenderBox;
4040

4141
var boxOffset = box.localToGlobal(const Offset(0.0, 0.0));
4242
if (boxOffset.dx.isNaN || boxOffset.dy.isNaN) {
@@ -48,9 +48,7 @@ class GetPosition {
4848
final rect = Rect.fromLTRB(
4949
topLeft.dx - padding.left < 0 ? 0 : topLeft.dx - padding.left,
5050
topLeft.dy - padding.top < 0 ? 0 : topLeft.dy - padding.top,
51-
bottomRight.dx + padding.right > screenWidth!
52-
? screenWidth!
53-
: bottomRight.dx + padding.right,
51+
bottomRight.dx + padding.right > screenWidth! ? screenWidth! : bottomRight.dx + padding.right,
5452
bottomRight.dy + padding.bottom > screenHeight!
5553
? screenHeight!
5654
: bottomRight.dy + padding.bottom,
@@ -60,7 +58,7 @@ class GetPosition {
6058

6159
///Get the bottom position of the widget
6260
double getBottom() {
63-
final box = key!.currentContext!.findRenderObject() as RenderBox;
61+
final box = key.currentContext?.findRenderObject() as RenderBox;
6462
final boxOffset = box.localToGlobal(const Offset(0.0, 0.0));
6563
if (boxOffset.dy.isNaN) return padding.bottom;
6664
final bottomRight = box.size.bottomRight(boxOffset);
@@ -69,7 +67,7 @@ class GetPosition {
6967

7068
///Get the top position of the widget
7169
double getTop() {
72-
final box = key!.currentContext!.findRenderObject() as RenderBox;
70+
final box = key.currentContext!.findRenderObject() as RenderBox;
7371
final boxOffset = box.localToGlobal(const Offset(0.0, 0.0));
7472
if (boxOffset.dy.isNaN) return 0 - padding.top;
7573
final topLeft = box.size.topLeft(boxOffset);
@@ -90,8 +88,7 @@ class GetPosition {
9088
final box = key!.currentContext!.findRenderObject() as RenderBox;
9189
final boxOffset = box.localToGlobal(const Offset(0.0, 0.0));
9290
if (boxOffset.dx.isNaN) return padding.right;
93-
final bottomRight =
94-
box.size.bottomRight(box.localToGlobal(const Offset(0.0, 0.0)));
91+
final bottomRight = box.size.bottomRight(box.localToGlobal(const Offset(0.0, 0.0)));
9592
return bottomRight.dx + padding.right;
9693
}
9794

lib/src/shape_clipper.dart

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
*/
2222

2323
import 'dart:ui' as ui;
24-
2524
import 'package:flutter/material.dart';
2625

2726
class RRectClipper extends CustomClipper<ui.Path> {

0 commit comments

Comments
 (0)