Skip to content

Commit 3ac8d0e

Browse files
committed
Fix parsing
1 parent 57763a5 commit 3ac8d0e

4 files changed

Lines changed: 20 additions & 12 deletions

File tree

lib/model/attribute.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
class ProductAttribute {
22
int id;
33
String name;
4-
int position;
5-
bool visible;
6-
bool variation;
4+
int? position;
5+
bool? visible;
6+
bool? variation;
77
List<String> options;
88

99
ProductAttribute.fromJson(Map<String, dynamic> json)
@@ -12,9 +12,9 @@ class ProductAttribute {
1212
position = json['position'],
1313
visible = json['visible'],
1414
variation = json['variation'],
15-
options = (json['options'] as List)
16-
.map((option) => option.toString())
17-
.toList();
15+
options = (json['options'] as List?)
16+
?.map((option) => option.toString())
17+
.toList() ?? [];
1818
}
1919

2020
class Attribute {

lib/screens/orders/create/create_order_widgets.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,14 @@ class CreateOrderProduct extends StatelessWidget {
9191
children: [
9292
_buildItemImage(context, item.id, item.featuredImage),
9393
SizedBox(width: 8),
94-
Text(
95-
item.name,
96-
style: TextStyle(fontSize: 16),
94+
SizedBox(
95+
width: MediaQuery.of(context).size.width - 176,
96+
child: Text(
97+
item.name,
98+
maxLines: 1,
99+
overflow: TextOverflow.ellipsis,
100+
style: TextStyle(fontSize: 16),
101+
),
97102
),
98103
DotSpacer(),
99104
Text('${item.quantity.value} x '),

lib/screens/product/product_cubit.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:async';
2+
13
import 'package:flutter_bloc/flutter_bloc.dart';
24
import 'package:wooapp/database/database.dart';
35
import 'package:wooapp/datasource/product_data_source.dart';
@@ -19,7 +21,8 @@ class ProductCubit extends Cubit<ProductState> {
1921
_ds.getProduct(_productId).then((product) {
2022
_db.saveProductView(product);
2123
emit(ContentProductState(product));
22-
}).catchError((error) {
24+
}).catchError((error, stacktrace) {
25+
Completer().completeError(error, stacktrace);
2326
emit(ErrorProductState());
2427
});
2528
}

lib/widget/widget_product_variations.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ class ProductVariationSelectionWidgetState
8080

8181
void _genVariations() {
8282
for (var attr in widget.product.attributes) {
83-
if (!attr.variation) continue;
84-
if (!attr.visible) continue;
83+
if (attr.variation == null || attr.variation == false) continue;
84+
if (attr.visible == null || attr.visible == false) continue;
8585
_variableAttrs.add(attr);
8686
}
8787
for (var attr in _variableAttrs) {

0 commit comments

Comments
 (0)