11import 'package:arabic_learning/funcs/ui.dart' ;
22import 'package:flutter/material.dart' ;
33
4- Widget settingItem (BuildContext context, MediaQueryData mediaQuery, List <Widget > list, String title, {bool withPadding = true }) {
5- List <Container > decoratedContainers = list.map ((widget) {
6- return Container (
7- width: mediaQuery.size.width * 0.90 ,
8- //height: mediaQuery.size.height * 0.08,
9- padding: withPadding ? EdgeInsets .all (8.0 ) : EdgeInsets .zero,
10- decoration: BoxDecoration (
11- color: Theme .of (context).colorScheme.onPrimary.withAlpha (150 ),
12- borderRadius: BorderRadius .all (Radius .circular (5.0 )),
13- ),
14- child: widget,
15- );
16- }).toList ();
17- if (decoratedContainers.length > 1 ){
18- decoratedContainers[0 ] = Container (
19- width: mediaQuery.size.width * 0.90 ,
20- //height: mediaQuery.size.height * 0.08,
21- margin: decoratedContainers[0 ].margin,
22- padding: decoratedContainers[0 ].padding,
23- decoration: BoxDecoration (
24- color: Theme .of (context).colorScheme.onPrimary.withAlpha (150 ),
25- borderRadius: BorderRadius .vertical (top: Radius .circular (25.0 ), bottom: Radius .circular (5.0 )),
26- ),
27- child: decoratedContainers[0 ].child,
28- );
29- decoratedContainers[decoratedContainers.length - 1 ] = Container (
30- width: mediaQuery.size.width * 0.90 ,
31- //height: mediaQuery.size.height * 0.08,
32- margin: decoratedContainers[decoratedContainers.length - 1 ].margin,
33- padding: decoratedContainers[decoratedContainers.length - 1 ].padding,
34- decoration: BoxDecoration (
35- color: Theme .of (context).colorScheme.onPrimary.withAlpha (150 ),
36- borderRadius: BorderRadius .vertical (bottom: Radius .circular (25.0 ), top: Radius .circular (5.0 )),
37- ),
38- child: decoratedContainers[decoratedContainers.length - 1 ].child,
39- );
40- } else {
41- decoratedContainers[0 ] = Container (
42- width: mediaQuery.size.width * 0.90 ,
43- //height: mediaQuery.size.height * 0.08,
44- margin: decoratedContainers[0 ].margin,
45- padding: decoratedContainers[0 ].padding,
46- decoration: BoxDecoration (
47- color: Theme .of (context).colorScheme.onPrimary.withAlpha (150 ),
48- borderRadius: BorderRadius .all (Radius .circular (25.0 )),
49- ),
50- child: decoratedContainers[0 ].child,
51- );
52- }
53- //Add Sizedbox between each item in list
54- List <Widget > newList = [];
55- for (var i = 0 ; i < decoratedContainers.length; i++ ) {
56- newList.add (decoratedContainers[i]);
57- if (i != decoratedContainers.length - 1 ) {
58- newList.add (SizedBox (height: mediaQuery.size.height * 0.005 ));
4+ class SettingItem extends StatelessWidget {
5+ final String title;
6+ final EdgeInsetsGeometry ? padding;
7+ final List <Widget > children;
8+ const SettingItem ({super .key, required this .children, required this .title, this .padding});
9+
10+ @override
11+ Widget build (BuildContext context) {
12+ MediaQueryData mediaQuery = MediaQuery .of (context);
13+ List <Container > decoratedContainers = children.map ((widget) {
14+ return Container (
15+ width: mediaQuery.size.width * 0.90 ,
16+ padding: padding,
17+ decoration: BoxDecoration (
18+ color: Theme .of (context).colorScheme.onPrimary.withAlpha (150 ),
19+ borderRadius: BorderRadius .all (Radius .circular (5.0 )),
20+ ),
21+ child: widget,
22+ );
23+ }).toList ();
24+
25+ if (decoratedContainers.length > 1 ){
26+ decoratedContainers[0 ] = Container (
27+ width: mediaQuery.size.width * 0.90 ,
28+ margin: decoratedContainers[0 ].margin,
29+ padding: decoratedContainers[0 ].padding,
30+ decoration: BoxDecoration (
31+ color: Theme .of (context).colorScheme.onPrimary.withAlpha (150 ),
32+ borderRadius: BorderRadius .vertical (top: Radius .circular (25.0 ), bottom: Radius .circular (5.0 )),
33+ ),
34+ child: decoratedContainers[0 ].child,
35+ );
36+ decoratedContainers[decoratedContainers.length - 1 ] = Container (
37+ width: mediaQuery.size.width * 0.90 ,
38+ margin: decoratedContainers[decoratedContainers.length - 1 ].margin,
39+ padding: decoratedContainers[decoratedContainers.length - 1 ].padding,
40+ decoration: BoxDecoration (
41+ color: Theme .of (context).colorScheme.onPrimary.withAlpha (150 ),
42+ borderRadius: BorderRadius .vertical (bottom: Radius .circular (25.0 ), top: Radius .circular (5.0 )),
43+ ),
44+ child: decoratedContainers[decoratedContainers.length - 1 ].child,
45+ );
46+ } else {
47+ decoratedContainers[0 ] = Container (
48+ width: mediaQuery.size.width * 0.90 ,
49+ margin: decoratedContainers[0 ].margin,
50+ padding: decoratedContainers[0 ].padding,
51+ decoration: BoxDecoration (
52+ color: Theme .of (context).colorScheme.onPrimary.withAlpha (150 ),
53+ borderRadius: BorderRadius .all (Radius .circular (25.0 )),
54+ ),
55+ child: decoratedContainers[0 ].child,
56+ );
5957 }
60- }
61- return Column (
62- mainAxisAlignment: MainAxisAlignment .start,
63- crossAxisAlignment: CrossAxisAlignment .start,
64- children: [
65- TextContainer (text: title),
66- Center (
67- child: Column (
68- children: newList,
58+ //Add Sizedbox between each item in list
59+ List <Widget > newList = [];
60+ for (var i = 0 ; i < decoratedContainers.length; i++ ) {
61+ newList.add (decoratedContainers[i]);
62+ if (i != decoratedContainers.length - 1 ) {
63+ newList.add (SizedBox (height: mediaQuery.size.height * 0.005 ));
64+ }
65+ }
66+ return Column (
67+ mainAxisAlignment: MainAxisAlignment .start,
68+ crossAxisAlignment: CrossAxisAlignment .start,
69+ children: [
70+ TextContainer (text: title),
71+ Center (
72+ child: Column (
73+ children: newList,
74+ ),
6975 ),
70- ),
71- ]
72- );
76+ ]
77+ );
78+ }
7379}
0 commit comments