Skip to content

Commit

Permalink
create #251 demo
Browse files Browse the repository at this point in the history
  • Loading branch information
xdd666t committed Feb 15, 2025
1 parent 8faf0c6 commit e95ccd5
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 2 deletions.
61 changes: 61 additions & 0 deletions example/lib/demo/issue251_tag.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

void main() {
runApp(MaterialApp(
navigatorObservers: [FlutterSmartDialog.observer],
builder: FlutterSmartDialog.init(),
home: const MyApp(),
));
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Test"),
),
body: Center(
child: Builder(builder: (ctx) {
return ElevatedButton(
onPressed: () => show(ctx),
child: const Text("Click"),
);
}),
),
);
}

show(BuildContext context) {
SmartDialog.showAttach(
targetContext: context,
alignment: Alignment.topCenter,
maskColor: Colors.transparent,
usePenetrate: true,
keepSingle: true,
tag: "tag2",
animationType: SmartAnimationType.scale,
builder: (_) {
return Container(
height: 300,
width: 500,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.white,
),
alignment: Alignment.center,
child: ElevatedButton(
onPressed: () {
final checkMsg = SmartDialog.checkExist(tag: "tag2").toString();
SmartDialog.showToast(checkMsg);
},
child: const Text('check tag status'),
),
);
},
);
}
}
4 changes: 3 additions & 1 deletion lib/src/widget/attach_dialog_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ class _AttachDialogWidgetState extends State<AttachDialogWidget>
void didUpdateWidget(covariant AttachDialogWidget oldWidget) {
if (oldWidget.child != _child ||
oldWidget.targetContext != widget.targetContext ||
oldWidget.targetBuilder != widget.targetBuilder) _resetState();
oldWidget.targetBuilder != widget.targetBuilder) {
_resetState();
}
super.didUpdateWidget(oldWidget);
}

Expand Down
4 changes: 3 additions & 1 deletion lib/src/widget/helper/attach_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class _AttachWidgetState extends State<AttachWidget>
super.didUpdateWidget(oldWidget);
if (oldWidget.originChild != widget.originChild ||
oldWidget.targetContext != widget.targetContext ||
oldWidget.targetBuilder != widget.targetBuilder) _resetState();
oldWidget.targetBuilder != widget.targetBuilder) {
_resetState();
}
}

@override
Expand Down

0 comments on commit e95ccd5

Please sign in to comment.