Skip to content

Commit 277c37c

Browse files
committed
Improve code style using lint rules v2.0.1
1 parent bfdd3b9 commit 277c37c

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

lib/src/controller/product_controller.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ class ProductController extends GetxController {
174174
if (product.sizes?.categorical != null) {
175175
for (var element in product.sizes!.categorical!) {
176176
if (element.isSelected) {
177-
currentSize = "Size:" + element.categorical.name.toString();
177+
currentSize = "Size: ${element.categorical.name}";
178178
}
179179
}
180180
}
181181

182182
if (product.sizes?.numerical != null) {
183183
for (var element in product.sizes!.numerical!) {
184184
if (element.isSelected) {
185-
currentSize = "Size:" + element.numerical;
185+
currentSize = "Size: ${element.numerical}";
186186
}
187187
}
188188
}

lib/src/view/screen/cart_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ class CartScreen extends StatelessWidget {
179179
padding: const EdgeInsets.only(left: 30, right: 30, bottom: 20),
180180
child: ElevatedButton(
181181
style: ElevatedButton.styleFrom(padding: const EdgeInsets.all(20)),
182-
child: const Text("Buy Now"),
183182
onPressed: controller.isEmptyCart ? null : () {},
183+
child: const Text("Buy Now"),
184184
),
185185
),
186186
);

lib/src/view/screen/product_detail_screen.dart

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ class ProductDetailScreen extends StatelessWidget {
2424
controller.productImageDefaultIndex.value = 0;
2525
Navigator.pop(context);
2626
},
27-
icon: const Icon(
28-
Icons.arrow_back,
29-
color: Colors.black,
30-
),
27+
icon: const Icon(Icons.arrow_back, color: Colors.black),
3128
),
3229
);
3330
}
@@ -54,10 +51,7 @@ class ProductDetailScreen extends StatelessWidget {
5451
itemBuilder: (_, index) {
5552
return FittedBox(
5653
fit: BoxFit.none,
57-
child: Image.asset(
58-
product.images[index],
59-
scale: 3,
60-
),
54+
child: Image.asset(product.images[index], scale: 3),
6155
);
6256
},
6357
),
@@ -83,9 +77,7 @@ class ProductDetailScreen extends StatelessWidget {
8377
RatingBar.builder(
8478
initialRating: product.rating,
8579
direction: Axis.horizontal,
86-
itemBuilder: (_, index) {
87-
return const Icon(Icons.star, color: Colors.amber);
88-
},
80+
itemBuilder: (_, __) => const Icon(Icons.star, color: Colors.amber),
8981
onRatingUpdate: (_) {},
9082
),
9183
Text(
@@ -196,19 +188,17 @@ class ProductDetailScreen extends StatelessWidget {
196188
SizedBox(
197189
height: 40,
198190
child: GetBuilder<ProductController>(
199-
builder: (ProductController controller) {
200-
return productSizesListView();
201-
},
191+
builder: (_) => productSizesListView(),
202192
),
203193
),
204194
const SizedBox(height: 20),
205195
SizedBox(
206196
width: double.infinity,
207197
child: ElevatedButton(
208-
child: const Text("Add to cart"),
209198
onPressed: product.isAvailable
210199
? () => controller.addToCart(product)
211200
: null,
201+
child: const Text("Add to cart"),
212202
),
213203
)
214204
],

lib/src/view/widget/product_grid_view.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ class ProductGridView extends StatelessWidget {
130130
itemBuilder: (_, index) {
131131
Product product = controller.filteredProducts[index];
132132
return OpenContainerWrapper(
133+
product: product,
133134
child: GridTile(
134135
header: _gridItemHeader(product, index),
135136
footer: _gridItemFooter(product, context),
136137
child: _gridItemBody(product),
137138
),
138-
product: product,
139139
);
140140
},
141141
),

0 commit comments

Comments
 (0)