Skip to content

Commit

Permalink
process #229
Browse files Browse the repository at this point in the history
  • Loading branch information
xdd666t committed Nov 9, 2024
1 parent cf4071c commit baa05aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 0 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ class SmartDialogPage extends StatelessWidget {
targetContext: context,
alignment: Alignment.bottomCenter,
animationType: SmartAnimationType.scale,
highlightBuilder: (_, __) {
return Positioned(child: Container());
},
scalePointBuilder: (selfSize) => Offset(selfSize.width, 0),
builder: (_) {
return Container(height: 50, width: 30, color: Colors.red);
},
Expand Down
18 changes: 16 additions & 2 deletions lib/src/widget/helper/attach_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class AttachWidget extends StatefulWidget {
State<AttachWidget> createState() => _AttachWidgetState();
}

class _AttachWidgetState extends State<AttachWidget> {
class _AttachWidgetState extends State<AttachWidget>
with WidgetsBindingObserver {
late double _postFrameOpacity;

//offset size
Expand All @@ -71,17 +72,30 @@ class _AttachWidgetState extends State<AttachWidget> {

@override
void initState() {
WidgetsBinding.instance.addObserver(this);
_alignment = widget.alignment;
_resetState();
super.initState();
}

@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

@override
void didUpdateWidget(covariant AttachWidget oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.originChild != widget.originChild ||
oldWidget.targetContext != widget.targetContext ||
oldWidget.targetBuilder != widget.targetBuilder) _resetState();
super.didUpdateWidget(oldWidget);
}

@override
void didChangeMetrics() {
super.didChangeMetrics();
_resetState();
}

@override
Expand Down

0 comments on commit baa05aa

Please sign in to comment.