Showing
2 changed files
with
59 additions
and
0 deletions
@@ -11,6 +11,7 @@ class MyApp extends StatelessWidget { | @@ -11,6 +11,7 @@ class MyApp extends StatelessWidget { | ||
11 | return ScreenUtilInit( | 11 | return ScreenUtilInit( |
12 | builder: (child) { | 12 | builder: (child) { |
13 | return MaterialApp( | 13 | return MaterialApp( |
14 | + key: const GlobalObjectKey('screen-util'), | ||
14 | debugShowCheckedModeBanner: false, | 15 | debugShowCheckedModeBanner: false, |
15 | title: 'First Method', | 16 | title: 'First Method', |
16 | // You can use the library anywhere in the app even in theme | 17 | // You can use the library anywhere in the app even in theme |
@@ -93,6 +93,64 @@ class HomePageScaffold extends StatelessWidget { | @@ -93,6 +93,64 @@ class HomePageScaffold extends StatelessWidget { | ||
93 | ), | 93 | ), |
94 | ), | 94 | ), |
95 | 18.verticalSpace, | 95 | 18.verticalSpace, |
96 | + ElevatedButton( | ||
97 | + onPressed: () { | ||
98 | + showDialog( | ||
99 | + context: context, | ||
100 | + builder: (_) { | ||
101 | + return Dialog( | ||
102 | + child: Padding( | ||
103 | + padding: EdgeInsets.all(12.r), | ||
104 | + child: const Text('Dialog'), | ||
105 | + ), | ||
106 | + ); | ||
107 | + }, | ||
108 | + ); | ||
109 | + }, | ||
110 | + child: const Text('Show Dialog'), | ||
111 | + ), | ||
112 | + 18.verticalSpace, | ||
113 | + ElevatedButton( | ||
114 | + onPressed: () { | ||
115 | + Navigator.of(context).push( | ||
116 | + MaterialPageRoute(builder: (context) { | ||
117 | + return ScreenUtilInit(builder: (context) { | ||
118 | + return HomePageScaffold(title: title); | ||
119 | + }); | ||
120 | + }), | ||
121 | + ); | ||
122 | + }, | ||
123 | + child: const Text('Go to next page'), | ||
124 | + ), | ||
125 | + 18.verticalSpace, | ||
126 | + ElevatedButton( | ||
127 | + onPressed: () { | ||
128 | + showModalBottomSheet<void>( | ||
129 | + context: context, | ||
130 | + builder: (BuildContext context) { | ||
131 | + return Container( | ||
132 | + height: 200.w, | ||
133 | + color: Colors.amber, | ||
134 | + child: Center( | ||
135 | + child: Column( | ||
136 | + mainAxisAlignment: MainAxisAlignment.center, | ||
137 | + mainAxisSize: MainAxisSize.min, | ||
138 | + children: <Widget>[ | ||
139 | + const Text('Modal BottomSheet'), | ||
140 | + ElevatedButton( | ||
141 | + child: const Text('Close BottomSheet'), | ||
142 | + onPressed: Navigator.of(context).pop, | ||
143 | + ) | ||
144 | + ], | ||
145 | + ), | ||
146 | + ), | ||
147 | + ); | ||
148 | + }, | ||
149 | + ); | ||
150 | + }, | ||
151 | + child: const Text('Open BottomSheet'), | ||
152 | + ), | ||
153 | + 18.verticalSpace, | ||
96 | Text('Device width:${ScreenUtil().screenWidth}dp'), | 154 | Text('Device width:${ScreenUtil().screenWidth}dp'), |
97 | Text('Device height:${ScreenUtil().screenHeight}dp'), | 155 | Text('Device height:${ScreenUtil().screenHeight}dp'), |
98 | Text('Device pixel density:${ScreenUtil().pixelRatio}'), | 156 | Text('Device pixel density:${ScreenUtil().pixelRatio}'), |
-
Please register or login to post a comment