Skip to content

Commit 1b7780f

Browse files
author
xuyingjun
committed
无Context也能使用[v1.0.4]
1 parent bc8b3d8 commit 1b7780f

File tree

4 files changed

+78
-2
lines changed

4 files changed

+78
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@
1313

1414
## 1.0.3
1515

16-
* add gravityAnimationEnable property
16+
* add gravityAnimationEnable property
17+
18+
## 1.0.4
19+
20+
* Without the Context to invoke

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Global dialog function encapsulation, with a semantic way to fill the content in
99
1. Support for a few semantic component methods to populate the component content inside dialog
1010
2. Support for customizing semantic components for developers to freely populate component content inside dialog
1111
3. Support setting dialog background color, foreground color, position, animation, click the external disappear and other functions, see the details below
12+
4. Support no Context call dialog, see below
1213

1314
## 🎖 Installing
1415

@@ -331,6 +332,41 @@ YYDialog YYDialogDemo(BuildContext context) {
331332
}
332333
```
333334

335+
## Without the Context to invoke
336+
337+
* Application scenario: after the network request comes back, there is no Context to refer to in the callback, at this time, the Context needs to be initialized in advance, and then the dialog can be called without the Context
338+
339+
**1、init**
340+
341+
Call static methods before show dialog `YYDialog.init(context);`
342+
343+
```dart
344+
class AppHome extends StatelessWidget {
345+
Widget build(BuildContext context) {
346+
//1、初始化context
347+
YYDialog.init(context);
348+
//2、后续使用可以不需要context
349+
......
350+
}
351+
}
352+
```
353+
354+
**2、use**
355+
356+
direct use `YYDialog`,Note that it must be called `build()`
357+
358+
```dart
359+
YYDialog YYAlertDialogBody() {
360+
return YYDialog().build()
361+
..width = 240
362+
..text(
363+
text: "Hello YYDialog",
364+
color: Colors.grey[700],
365+
)
366+
..show();
367+
}
368+
```
369+
334370
## Bugs/Requests
335371

336372
* If your application has problems, please submit your code and effect to Issue.

README_CN.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
1. 支持少数语义化组件的方法,填充弹窗内部的组件内容
88
2. 支持自定义语义化组件的方法,供开发者自由填充弹窗内部的组件内容
99
3. 支持设置弹窗背景色、前景色、位置、动画、点击外部消失等功能,具体看下文
10+
4. 支持无Context调用弹窗,具体看下文
1011

1112
## 🎖 Installing
1213

@@ -329,6 +330,41 @@ YYDialog YYDialogDemo(BuildContext context) {
329330
}
330331
```
331332

333+
## 无Context调用
334+
335+
* 应用场景:在网络请求回来后,在回调中是无Context可以引用,这时候就需要预先初始化Context,后续就可以不需要Context调用弹窗
336+
337+
**1、init**
338+
339+
在未弹窗之前先调用静态方法`YYDialog.init(context);`
340+
341+
```dart
342+
class AppHome extends StatelessWidget {
343+
Widget build(BuildContext context) {
344+
//1、初始化context
345+
YYDialog.init(context);
346+
//2、后续使用可以不需要context
347+
......
348+
}
349+
}
350+
```
351+
352+
**2、use**
353+
354+
直接使用`YYDialog`,注意必须要调用`build()`
355+
356+
```dart
357+
YYDialog YYAlertDialogBody() {
358+
return YYDialog().build()
359+
..width = 240
360+
..text(
361+
text: "Hello YYDialog",
362+
color: Colors.grey[700],
363+
)
364+
..show();
365+
}
366+
```
367+
332368
## Bugs/Requests
333369

334370
* If your application has problems, please submit your code and effect to Issue.

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_custom_dialog
22
description: Semantic dialog
3-
version: 1.0.3
3+
version: 1.0.4
44
author: AndroidHensen <[email protected]>
55
homepage: https://github.com/YYFlutter/flutter-custom-dialog.git
66

0 commit comments

Comments
 (0)