Skip to content

Commit 1b60557

Browse files
committed
Perbaikan null aware exception di UI Detail Meals
1 parent 834f8aa commit 1b60557

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/src/ui/detailmeals/detail_meals_screen.dart

+9-9
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class _DetailMealsScreenState extends State<DetailMealsScreen> {
114114
return Column(
115115
crossAxisAlignment: CrossAxisAlignment.start,
116116
children: <Widget>[
117-
_buildTagMeal(detailMeals?.strTags ?? widget.favoriteMeal.strTags),
117+
_buildTagMeal(detailMeals?.strTags ?? widget.favoriteMeal?.strTags ?? null),
118118
Padding(padding: EdgeInsets.only(top: 24.0)),
119119
_buildWidgetPanelInfoGeneralMeal(detailMeals),
120120
Padding(padding: EdgeInsets.only(top: 24.0)),
@@ -129,16 +129,16 @@ class _DetailMealsScreenState extends State<DetailMealsScreen> {
129129
style: Theme.of(context).textTheme.title,
130130
),
131131
_buildWidgetInfoInstructions(
132-
detailMeals?.strInstructions ?? widget.favoriteMeal.strInstructions,
132+
detailMeals?.strInstructions ?? widget.favoriteMeal?.strInstructions ?? "",
133133
),
134134
],
135135
);
136136
}
137137

138138
Widget _buildWidgetInfoInstructions(String strInstructions) {
139139
return Padding(
140-
padding: EdgeInsets.only(left: 8.0, top: 8.0, right: 8.0),
141-
child: Text(strInstructions),
140+
padding: EdgeInsets.only(left: 8.0, top: 8.0, right: 8.0, bottom: 16.0),
141+
child: Text(strInstructions.isEmpty ? "N/A" : strInstructions),
142142
);
143143
}
144144

@@ -315,17 +315,17 @@ class _DetailMealsScreenState extends State<DetailMealsScreen> {
315315
mainAxisAlignment: MainAxisAlignment.spaceAround,
316316
children: <Widget>[
317317
_buildWidgetInfoPlayVideo(
318-
detailMeals?.strYoutube ?? widget.favoriteMeal.strYoutube),
318+
detailMeals?.strYoutube ?? widget.favoriteMeal?.strYoutube ?? ""),
319319
Padding(padding: EdgeInsets.only(left: 8.0)),
320320
_buildVerticalDivider(),
321321
Padding(padding: EdgeInsets.only(left: 8.0)),
322322
_buildWidgetInfoCategoryMeal(
323-
detailMeals?.strCategory ?? widget.favoriteMeal.strCategory),
323+
detailMeals?.strCategory ?? widget.favoriteMeal?.strCategory ?? ""),
324324
Padding(padding: EdgeInsets.only(left: 8.0)),
325325
_buildVerticalDivider(),
326326
Padding(padding: EdgeInsets.only(left: 8.0)),
327327
_buildWidgetInfoCountryMeal(
328-
detailMeals?.strArea ?? widget.favoriteMeal.strArea),
328+
detailMeals?.strArea ?? widget.favoriteMeal?.strArea ?? ""),
329329
Padding(padding: EdgeInsets.only(left: 8.0)),
330330
],
331331
);
@@ -335,7 +335,7 @@ class _DetailMealsScreenState extends State<DetailMealsScreen> {
335335
return Column(
336336
children: <Widget>[
337337
Text("Country"),
338-
Text(strArea, style: TextStyle(fontWeight: FontWeight.bold)),
338+
Text(strArea.isEmpty ? "N/A" : strArea, style: TextStyle(fontWeight: FontWeight.bold)),
339339
],
340340
);
341341
}
@@ -344,7 +344,7 @@ class _DetailMealsScreenState extends State<DetailMealsScreen> {
344344
return Column(
345345
children: <Widget>[
346346
Text("Category"),
347-
Text(strCategory, style: TextStyle(fontWeight: FontWeight.bold)),
347+
Text(strCategory.isEmpty ? "N/A" : strCategory, style: TextStyle(fontWeight: FontWeight.bold)),
348348
],
349349
);
350350
}

0 commit comments

Comments
 (0)