Skip to content

Commit 1be2eb1

Browse files
richardthe3rdclaude
andcommitted
fix: resolve rebase conflict with #252 vegan field
Keep isVegan field name from this PR but preserve the robust multi-type parsing (bool/num/string) introduced by #252. Remove the duplicate fragile cast and rename all .vegan accessor references to .isVegan. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9b711b8 commit 1be2eb1

4 files changed

Lines changed: 18 additions & 23 deletions

File tree

lib/models/drink.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class Product {
6262
final String? notes;
6363
final String? statusText;
6464
final String? bar;
65-
final bool? vegan;
6665
final Map<String, int> allergens;
6766
final bool? isVegan;
6867

@@ -76,7 +75,6 @@ class Product {
7675
this.notes,
7776
this.statusText,
7877
this.bar,
79-
this.vegan,
8078
this.allergens = const {},
8179
this.isVegan,
8280
});
@@ -148,9 +146,8 @@ class Product {
148146
notes: json['notes']?.toString(),
149147
statusText: json['status_text']?.toString(),
150148
bar: bar,
151-
vegan: parsedVegan,
152149
allergens: allergens,
153-
isVegan: json['is_vegan'] as bool?,
150+
isVegan: parsedVegan,
154151
);
155152
}
156153

@@ -165,7 +162,6 @@ class Product {
165162
if (notes != null) 'notes': notes,
166163
if (statusText != null) 'status_text': statusText,
167164
if (bar != null) 'bar': bar,
168-
if (vegan != null) 'is_vegan': vegan,
169165
'allergens': allergens,
170166
if (isVegan != null) 'is_vegan': isVegan,
171167
};
@@ -260,7 +256,6 @@ class Drink {
260256
String? get notes => product.notes;
261257
String? get statusText => product.statusText;
262258
String? get bar => product.bar;
263-
bool? get vegan => product.vegan;
264259
Map<String, int> get allergens => product.allergens;
265260
AvailabilityStatus? get availabilityStatus => product.availabilityStatus;
266261
String? get allergenText => product.allergenText;

lib/screens/drink_detail_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class _DrinkDetailScreenState extends State<DrinkDetailScreen> {
179179
: theme.colorScheme.primary,
180180
),
181181
// Vegan indicator
182-
if (drink.vegan == true)
182+
if (drink.isVegan == true)
183183
HeroInfoRow(
184184
icon: Icons.eco,
185185
text: 'Vegan',

test/drink_detail_screen_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void main() {
4040
dispense: 'cask',
4141
style: 'IPA',
4242
bar: 'Main Bar',
43-
vegan: true,
43+
isVegan: true,
4444
notes: 'A hoppy beer with citrus notes',
4545
allergens: {'gluten': 1, 'sulphites': 1},
4646
);

test/models_test.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void main() {
2929
expect(product.notes, 'A test beer');
3030
expect(product.statusText, 'Plenty left');
3131
expect(product.bar, 'Main Bar');
32-
expect(product.vegan, isTrue);
32+
expect(product.isVegan, isTrue);
3333
expect(product.allergens, {'gluten': 1});
3434
});
3535

@@ -48,7 +48,7 @@ void main() {
4848
expect(product.notes, isNull);
4949
expect(product.statusText, isNull);
5050
expect(product.bar, isNull);
51-
expect(product.vegan, isNull);
51+
expect(product.isVegan, isNull);
5252
expect(product.allergens, isEmpty);
5353
});
5454

@@ -198,7 +198,7 @@ void main() {
198198
'abv': '4.0',
199199
'vegan': true,
200200
});
201-
expect(product.vegan, isTrue);
201+
expect(product.isVegan, isTrue);
202202
});
203203

204204
test('prefers is_vegan when both keys are present', () {
@@ -211,7 +211,7 @@ void main() {
211211
'is_vegan': false,
212212
'vegan': true,
213213
});
214-
expect(product.vegan, isFalse);
214+
expect(product.isVegan, isFalse);
215215
});
216216

217217
test('parses numeric one as true', () {
@@ -223,7 +223,7 @@ void main() {
223223
'abv': '4.0',
224224
'is_vegan': 1,
225225
});
226-
expect(product.vegan, isTrue);
226+
expect(product.isVegan, isTrue);
227227
});
228228

229229
test('parses numeric zero as false', () {
@@ -235,7 +235,7 @@ void main() {
235235
'abv': '4.0',
236236
'is_vegan': 0,
237237
});
238-
expect(product.vegan, isFalse);
238+
expect(product.isVegan, isFalse);
239239
});
240240

241241
test('parses supported string values', () {
@@ -287,12 +287,12 @@ void main() {
287287
'abv': '4.0',
288288
'is_vegan': '0',
289289
});
290-
expect(yesProduct.vegan, isTrue);
291-
expect(noProduct.vegan, isFalse);
292-
expect(trueProduct.vegan, isTrue);
293-
expect(falseProduct.vegan, isFalse);
294-
expect(oneProduct.vegan, isTrue);
295-
expect(zeroProduct.vegan, isFalse);
290+
expect(yesProduct.isVegan, isTrue);
291+
expect(noProduct.isVegan, isFalse);
292+
expect(trueProduct.isVegan, isTrue);
293+
expect(falseProduct.isVegan, isFalse);
294+
expect(oneProduct.isVegan, isTrue);
295+
expect(zeroProduct.isVegan, isFalse);
296296
});
297297

298298
test('returns null for unsupported string values', () {
@@ -304,7 +304,7 @@ void main() {
304304
'abv': '4.0',
305305
'is_vegan': 'maybe',
306306
});
307-
expect(product.vegan, isNull);
307+
expect(product.isVegan, isNull);
308308
});
309309
});
310310

@@ -433,7 +433,7 @@ void main() {
433433
notes: 'A test beer',
434434
statusText: 'Plenty left',
435435
bar: 'Main Bar',
436-
vegan: true,
436+
isVegan: true,
437437
allergens: {'gluten': 1},
438438
);
439439

@@ -828,7 +828,7 @@ void main() {
828828
expect(drink.notes, 'Hoppy and bold');
829829
expect(drink.statusText, 'Plenty left');
830830
expect(drink.bar, 'Bar A');
831-
expect(drink.vegan, isTrue);
831+
expect(drink.isVegan, isTrue);
832832
expect(drink.allergens, {'gluten': 1});
833833
expect(drink.availabilityStatus, AvailabilityStatus.plenty);
834834
expect(drink.allergenText, 'Gluten');

0 commit comments

Comments
 (0)