@@ -131,7 +131,8 @@ class _BuildGridItems extends ConsumerWidget {
131131 @override
132132 Widget build (BuildContext context, ref) {
133133 final gridCount = ref.watch (_gridNotifierProvider.select ((it) => it.gridCount));
134- final watchColumnCrossAxisCount = ref.watch (_gridNotifierProvider.select ((it) => it.columnCrossAxisCount));
134+ final watchColumnCrossAxisCount =
135+ ref.watch (_gridNotifierProvider.select ((it) => it.columnCrossAxisCount));
135136
136137 if (gridCount == 0 ) {
137138 return const Center (child: MediumText (StringsManager .notInitializeGridYet));
@@ -212,16 +213,8 @@ class _PathGrid extends StatelessWidget {
212213
213214 @override
214215 Widget build (BuildContext context) {
215- return Consumer (
216- builder: (context, ref, _) {
217- final size = ref.watch (_gridNotifierProvider.select ((it) => it.gridSize));
218-
219- return Container (
220- width: size,
221- height: size,
222- decoration: const BoxDecoration (color: ColorManager .light2Yellow),
223- );
224- },
216+ return const _WidgetSize (
217+ decoration: BoxDecoration (color: ColorManager .light2Yellow),
225218 );
226219 }
227220}
@@ -231,16 +224,8 @@ class _WallGrid extends StatelessWidget {
231224
232225 @override
233226 Widget build (BuildContext context) {
234- return Consumer (
235- builder: (context, ref, _) {
236- final size = ref.watch (_gridNotifierProvider.select ((it) => it.gridSize));
237-
238- return Container (
239- width: size,
240- height: size,
241- decoration: const BoxDecoration (color: ColorManager .wallBlack),
242- );
243- },
227+ return const _WidgetSize (
228+ decoration: BoxDecoration (color: ColorManager .wallBlack),
244229 );
245230 }
246231}
@@ -250,23 +235,15 @@ class _StartPointGrid extends StatelessWidget {
250235
251236 @override
252237 Widget build (BuildContext context) {
253- return Consumer (
254- builder: (context, ref, _) {
255- final size = ref.watch (_gridNotifierProvider.select ((it) => it.gridSize));
256-
257- return Container (
258- width: size,
259- height: size,
260- decoration: const BoxDecoration (shape: BoxShape .circle),
261- child: const FittedBox (
262- child: CustomIcon (
263- Icons .arrow_forward_ios_rounded,
264- size: 50 ,
265- color: ColorManager .darkPurple,
266- ),
267- ),
268- );
269- },
238+ return const _WidgetSize (
239+ decoration: BoxDecoration (shape: BoxShape .circle),
240+ child: FittedBox (
241+ child: CustomIcon (
242+ Icons .arrow_forward_ios_rounded,
243+ size: 50 ,
244+ color: ColorManager .darkPurple,
245+ ),
246+ ),
270247 );
271248 }
272249}
@@ -276,27 +253,19 @@ class _TargetPointGrid extends StatelessWidget {
276253
277254 @override
278255 Widget build (BuildContext context) {
279- return Consumer (
280- builder: (context, ref, _) {
281- final size = ref.watch (_gridNotifierProvider.select ((it) => it.gridSize));
282-
283- return Container (
284- width: size,
285- height: size,
286- decoration: const BoxDecoration (shape: BoxShape .circle),
287- child: const FittedBox (
288- child: _Circle (
289- radius: 30 ,
290- backgroundColor: ColorManager .darkPurple,
291- child: _Circle (
292- radius: 20 ,
293- backgroundColor: ColorManager .white,
294- child: _Circle (radius: 12 , backgroundColor: ColorManager .darkPurple),
295- ),
296- ),
256+ return const _WidgetSize (
257+ decoration: BoxDecoration (shape: BoxShape .circle),
258+ child: FittedBox (
259+ child: _Circle (
260+ radius: 30 ,
261+ backgroundColor: ColorManager .darkPurple,
262+ child: _Circle (
263+ radius: 20 ,
264+ backgroundColor: ColorManager .white,
265+ child: _Circle (radius: 12 , backgroundColor: ColorManager .darkPurple),
297266 ),
298- );
299- } ,
267+ ),
268+ ) ,
300269 );
301270 }
302271}
@@ -325,16 +294,25 @@ class _DefaultGrid extends StatelessWidget {
325294
326295 @override
327296 Widget build (BuildContext context) {
328- return Consumer (
329- builder: (context, ref, _) {
330- final size = ref.watch (_gridNotifierProvider.select ((it) => it.gridSize));
331-
332- return Container (
333- width: size,
334- height: size,
335- decoration: const BoxDecoration (color: ColorManager .transparent),
336- );
337- },
297+ return const _WidgetSize (
298+ decoration: BoxDecoration (color: ColorManager .transparent),
299+ );
300+ }
301+ }
302+
303+ class _WidgetSize extends ConsumerWidget {
304+ const _WidgetSize ({this .child, this .decoration});
305+ final Widget ? child;
306+ final Decoration ? decoration;
307+ @override
308+ Widget build (BuildContext context, ref) {
309+ final size = ref.watch (_gridNotifierProvider.select ((it) => it.gridSize));
310+
311+ return Container (
312+ width: size,
313+ height: size,
314+ decoration: decoration,
315+ child: child,
338316 );
339317 }
340318}
0 commit comments