Skip to content

Commit e95ccd5

Browse files
committed
create #251 demo
1 parent 8faf0c6 commit e95ccd5

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

example/lib/demo/issue251_tag.dart

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
3+
4+
void main() {
5+
runApp(MaterialApp(
6+
navigatorObservers: [FlutterSmartDialog.observer],
7+
builder: FlutterSmartDialog.init(),
8+
home: const MyApp(),
9+
));
10+
}
11+
12+
class MyApp extends StatelessWidget {
13+
const MyApp({super.key});
14+
15+
@override
16+
Widget build(BuildContext context) {
17+
return Scaffold(
18+
appBar: AppBar(
19+
title: const Text("Test"),
20+
),
21+
body: Center(
22+
child: Builder(builder: (ctx) {
23+
return ElevatedButton(
24+
onPressed: () => show(ctx),
25+
child: const Text("Click"),
26+
);
27+
}),
28+
),
29+
);
30+
}
31+
32+
show(BuildContext context) {
33+
SmartDialog.showAttach(
34+
targetContext: context,
35+
alignment: Alignment.topCenter,
36+
maskColor: Colors.transparent,
37+
usePenetrate: true,
38+
keepSingle: true,
39+
tag: "tag2",
40+
animationType: SmartAnimationType.scale,
41+
builder: (_) {
42+
return Container(
43+
height: 300,
44+
width: 500,
45+
decoration: BoxDecoration(
46+
borderRadius: BorderRadius.circular(20),
47+
color: Colors.white,
48+
),
49+
alignment: Alignment.center,
50+
child: ElevatedButton(
51+
onPressed: () {
52+
final checkMsg = SmartDialog.checkExist(tag: "tag2").toString();
53+
SmartDialog.showToast(checkMsg);
54+
},
55+
child: const Text('check tag status'),
56+
),
57+
);
58+
},
59+
);
60+
}
61+
}

lib/src/widget/attach_dialog_widget.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ class _AttachDialogWidgetState extends State<AttachDialogWidget>
179179
void didUpdateWidget(covariant AttachDialogWidget oldWidget) {
180180
if (oldWidget.child != _child ||
181181
oldWidget.targetContext != widget.targetContext ||
182-
oldWidget.targetBuilder != widget.targetBuilder) _resetState();
182+
oldWidget.targetBuilder != widget.targetBuilder) {
183+
_resetState();
184+
}
183185
super.didUpdateWidget(oldWidget);
184186
}
185187

lib/src/widget/helper/attach_widget.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ class _AttachWidgetState extends State<AttachWidget>
8989
super.didUpdateWidget(oldWidget);
9090
if (oldWidget.originChild != widget.originChild ||
9191
oldWidget.targetContext != widget.targetContext ||
92-
oldWidget.targetBuilder != widget.targetBuilder) _resetState();
92+
oldWidget.targetBuilder != widget.targetBuilder) {
93+
_resetState();
94+
}
9395
}
9496

9597
@override

0 commit comments

Comments
 (0)