11library flutter_custom_dialog;
22
33import 'package:flutter/material.dart' ;
4- import 'package:flutter_custom_dialog/flutter_custom_dialog.dart' ;
5- import 'package:flutter_custom_dialog/components/example/alert_dialog.dart' ;
64import 'package:flutter_custom_dialog/components/bean/dialog_gravity.dart' ;
5+ import 'package:flutter_custom_dialog/components/example/alert_dialog.dart' ;
76import 'package:flutter_custom_dialog/components/example/listview_dialog.dart' ;
87import 'package:flutter_custom_dialog/components/example/progress_dialog.dart' ;
8+ import 'package:flutter_custom_dialog/flutter_custom_dialog.dart' ;
99
1010void main () => runApp (MyApp ());
1111
@@ -23,19 +23,19 @@ class MyApp extends StatelessWidget {
2323/*
2424 * When you init App, you can Initialize YYDialog so that use YYDialog.build().show() everywhere.
2525 */
26-
2726class AppHome extends StatelessWidget {
2827 Widget build (BuildContext context) {
29- return YYDialog .init (
30- Scaffold (
31- appBar: AppBar (),
32- body: SingleChildScrollView (
33- child: Column (
34- children: < Widget > [
35- showAlertDialog (context),
36- showDevelopDialog (context),
37- ],
38- ),
28+ //1、初始化context
29+ YYDialog .init (context);
30+ //2、后续使用可以不需要context
31+ return Scaffold (
32+ appBar: AppBar (),
33+ body: SingleChildScrollView (
34+ child: Column (
35+ children: < Widget > [
36+ showAlertDialog (context),
37+ showDevelopDialog (context),
38+ ],
3939 ),
4040 ),
4141 );
@@ -53,55 +53,55 @@ showAlertDialog(BuildContext context) {
5353 Row (
5454 children: < Widget > [
5555 makeTextButton ("body" , () {
56- YYAlertDialogBody (context );
56+ YYAlertDialogBody ();
5757 }),
5858 makeTextButton ("head&body" , () {
59- YYAlertDialogHeadAndBody (context );
59+ YYAlertDialogHeadAndBody ();
6060 }),
6161 makeTextButton ("divider" , () {
62- YYAlertDialogWithDivider (context );
62+ YYAlertDialogWithDivider ();
6363 }),
6464 makeTextButton ("listTile" , () {
65- YYListViewDialogListTile (context );
65+ YYListViewDialogListTile ();
6666 }),
6767 makeTextButton ("listRadio" , () {
68- YYListViewDialogListRadio (context );
68+ YYListViewDialogListRadio ();
6969 }),
7070 ],
7171 ),
7272 Row (
7373 children: < Widget > [
7474 makeTextButton ("nobody" , () {
75- YYProgressDialogNoBody (context );
75+ YYProgressDialogNoBody ();
7676 }),
7777 makeTextButton ("body" , () {
78- YYProgressDialogBody (context );
78+ YYProgressDialogBody ();
7979 }),
8080 makeTextButton ("pop\n menu" , () {
81- YYAlertDialogPopMenu (context );
81+ YYAlertDialogPopMenu ();
8282 }),
8383 makeTextButton ("custom\n x&y" , () {
84- YYAlertDialogCustomXY (context );
84+ YYAlertDialogCustomXY ();
8585 }),
8686 ],
8787 ),
8888 Text ("2、dialog property" ),
8989 Row (
9090 children: < Widget > [
9191 makeTextButton ("duration" , () {
92- YYAlertDialogWithDuration (context );
92+ YYAlertDialogWithDuration ();
9393 }),
9494 makeTextButton ("barrier\n color" , () {
95- YYAlertDialogWithbarrierColor (context, Colors .redAccent);
95+ YYAlertDialogWithbarrierColor (Colors .redAccent);
9696 }),
9797 makeTextButton ("transparent\n color" , () {
98- YYAlertDialogWithbarrierColor (context, Colors .transparent);
98+ YYAlertDialogWithbarrierColor (Colors .transparent);
9999 }),
100100 makeTextButton ("background\n color" , () {
101- YYAlertDialogWithBackgroundColor (context );
101+ YYAlertDialogWithBackgroundColor ();
102102 }),
103103 makeTextButton ("barrier\n dismiss" , () {
104- YYAlertDialogWithBarrierDismiss (context );
104+ YYAlertDialogWithBarrierDismiss ();
105105 }),
106106 ],
107107 ),
@@ -110,33 +110,28 @@ showAlertDialog(BuildContext context) {
110110 children: < Widget > [
111111 makeTextButton ("bottom" , () {
112112 YYAlertDialogWithGravity (
113- context: context,
114113 gravity: Gravity .bottom,
115114 );
116115 }),
117116 makeTextButton ("top" , () {
118117 YYAlertDialogWithGravity (
119- context: context,
120118 gravity: Gravity .top,
121119 );
122120 }),
123121 makeTextButton ("left" , () {
124122 YYAlertDialogWithGravity (
125- context: context,
126123 width: 250.0 ,
127124 gravity: Gravity .left,
128125 );
129126 }),
130127 makeTextButton ("right" , () {
131128 YYAlertDialogWithGravity (
132- context: context,
133129 width: 250.0 ,
134130 gravity: Gravity .right,
135131 );
136132 }),
137133 makeTextButton ("center" , () {
138134 YYAlertDialogWithGravity (
139- context: context,
140135 width: 250.0 ,
141136 gravity: Gravity .center,
142137 );
@@ -147,28 +142,24 @@ showAlertDialog(BuildContext context) {
147142 children: < Widget > [
148143 makeTextButton ("left\n bottom" , () {
149144 YYAlertDialogWithGravity (
150- context: context,
151145 width: 250.0 ,
152146 gravity: Gravity .leftBottom,
153147 );
154148 }),
155149 makeTextButton ("left\n top" , () {
156150 YYAlertDialogWithGravity (
157- context: context,
158151 width: 250.0 ,
159152 gravity: Gravity .leftTop,
160153 );
161154 }),
162155 makeTextButton ("right\n bottom" , () {
163156 YYAlertDialogWithGravity (
164- context: context,
165157 width: 250.0 ,
166158 gravity: Gravity .rightBottom,
167159 );
168160 }),
169161 makeTextButton ("right\n top" , () {
170162 YYAlertDialogWithGravity (
171- context: context,
172163 width: 250.0 ,
173164 gravity: Gravity .rightTop,
174165 );
@@ -180,21 +171,18 @@ showAlertDialog(BuildContext context) {
180171 children: < Widget > [
181172 makeTextButton ("left" , () {
182173 YYAlertDialogWithGravity (
183- context: context,
184174 width: 250.0 ,
185175 doubleButtonGravity: Gravity .left,
186176 );
187177 }),
188178 makeTextButton ("right" , () {
189179 YYAlertDialogWithGravity (
190- context: context,
191180 width: 250.0 ,
192181 doubleButtonGravity: Gravity .right,
193182 );
194183 }),
195184 makeTextButton ("center" , () {
196185 YYAlertDialogWithGravity (
197- context: context,
198186 width: 250.0 ,
199187 doubleButtonGravity: Gravity .center,
200188 );
@@ -205,16 +193,16 @@ showAlertDialog(BuildContext context) {
205193 Row (
206194 children: < Widget > [
207195 makeTextButton ("scaleIn" , () {
208- YYAlertDialogWithScaleIn (context );
196+ YYAlertDialogWithScaleIn ();
209197 }),
210198 makeTextButton ("fadeIn" , () {
211- YYAlertDialogWithFadeIn (context );
199+ YYAlertDialogWithFadeIn ();
212200 }),
213201 makeTextButton ("rotateIn" , () {
214- YYAlertDialogWithRotateIn (context );
202+ YYAlertDialogWithRotateIn ();
215203 }),
216204 makeTextButton ("customIn" , () {
217- YYAlertDialogWithCustomIn (context );
205+ YYAlertDialogWithCustomIn ();
218206 }),
219207 ],
220208 ),
@@ -246,7 +234,7 @@ showDevelopDialog(BuildContext context) {
246234 body: Column (
247235 children: < Widget > [
248236 makeTextButton ("show" , () {
249- yyDialog = YYAlertDialogBody (context );
237+ yyDialog = YYAlertDialogBody ();
250238 }),
251239 makeTextButton ("dismiss" , () {
252240 yyDialog? .dismiss ();
0 commit comments