Skip to content

Commit a4c4f04

Browse files
committed
add migrate doc:3.x migrate 4.0
1 parent f090460 commit a4c4f04

File tree

10 files changed

+1114
-551
lines changed

10 files changed

+1114
-551
lines changed

README.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ SmartDialog's showLoading and showToast provide a default style. Of course, cust
6464

6565
- SmartDialog custom Loading or Toast is very simple: However, when using it, it may make you feel a little troublesome
6666
- for example
67-
- Use custom Loading: `SmartDialog.showLoading(widget: CustomLoadingWidget);`
67+
- Use custom Loading: `SmartDialog.showLoading(builder: () => CustomLoadingWidget);`
6868
- The effect we want must be like this: `SmartDialog.showLoading();`
6969
- In view of the above considerations, I added the function of setting custom default Loading and Toast styles at the entrance
7070

@@ -86,13 +86,9 @@ class MyApp extends StatelessWidget {
8686
// here
8787
builder: FlutterSmartDialog.init(
8888
//default toast widget
89-
toastBuilder: (String msg, AlignmentGeometry alignment) {
90-
return CustomToastWidget(msg: msg, alignment: alignment);
91-
},
89+
toastBuilder: (String msg) => CustomToastWidget(msg: msg),
9290
//default loading widget
93-
loadingBuilder: (String msg, Color background) {
94-
return CustomLoadingWidget(msg: msg, background: background);
95-
},
91+
loadingBuilder: (String msg) => CustomLoadingWidget(msg: msg),
9692
),
9793
);
9894
}
@@ -122,18 +118,19 @@ SmartDialog.dismiss();
122118
- **dialog usage**🎨
123119

124120
```dart
125-
var custom = Container(
121+
SmartDialog.show(builder: (context) {
122+
return Container(
126123
height: 80,
127124
width: 180,
128125
decoration: BoxDecoration(
129-
color: Colors.black,
130-
borderRadius: BorderRadius.circular(20),
126+
color: Colors.black,
127+
borderRadius: BorderRadius.circular(10),
131128
),
132129
alignment: Alignment.center,
133-
child: Text('easy custom dialog', style: TextStyle(color: Colors.white)),
134-
);
135-
// here
136-
SmartDialog.show(widget: custom, isLoadingTemp: false);
130+
child:
131+
Text('easy custom dialog', style: TextStyle(color: Colors.white)),
132+
);
133+
});
137134
```
138135

139136
![dialogEasy](https://cdn.jsdelivr.net/gh/xdd666t/MyData@master/pic/flutter/blog/20211102232821.gif)
@@ -243,33 +240,36 @@ class _OtherTrickState extends State<OtherTrick> {
243240
- Show this component and then trigger it externally
244241

245242
```dart
246-
VoidCallback? callback;
247-
248-
// display
249-
SmartDialog.show(
250-
alignmentTemp: Alignment.center,
251-
widget: OtherTrick(
252-
onUpdate: (VoidCallback onInvoke) => callback = onInvoke,
253-
),
254-
);
255-
256-
await Future.delayed(Duration(milliseconds: 500));
257-
258-
// handler
259-
SmartDialog.show(
260-
alignmentTemp: Alignment.centerRight,
261-
maskColorTemp: Colors.transparent,
262-
widget: Container(
263-
height: double.infinity,
264-
width: 150,
265-
color: Colors.white,
243+
void _otherTrick() async {
244+
VoidCallback? callback;
245+
246+
// display
247+
SmartDialog.show(
266248
alignment: Alignment.center,
267-
child: ElevatedButton(
268-
child: Text('add'),
269-
onPressed: () => callback?.call(),
270-
),
271-
),
272-
);
249+
builder: (_) =>
250+
OtherTrick(onUpdate: (VoidCallback onInvoke) => callback = onInvoke),
251+
);
252+
253+
await Future.delayed(const Duration(milliseconds: 500));
254+
255+
// handler
256+
SmartDialog.show(
257+
alignment: Alignment.centerRight,
258+
maskColor: Colors.transparent,
259+
builder: (_) {
260+
return Container(
261+
height: double.infinity,
262+
width: 150,
263+
color: Colors.white,
264+
alignment: Alignment.center,
265+
child: ElevatedButton(
266+
child: const Text('add'),
267+
onPressed: () => callback?.call(),
268+
),
269+
);
270+
},
271+
);
272+
}
273273
```
274274

275275
- Let's see the effect

0 commit comments

Comments
 (0)