From 0fd7def1e4afb050118da06acda654597406028c Mon Sep 17 00:00:00 2001 From: 98spag Date: Tue, 30 May 2023 17:12:42 +0200 Subject: [PATCH] feat: format helper --- lib/android/components/card_component.dart | 8 +------- lib/android/config/format_helper.dart | 5 +++++ 2 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 lib/android/config/format_helper.dart diff --git a/lib/android/components/card_component.dart b/lib/android/components/card_component.dart index 11dd02b..9665103 100644 --- a/lib/android/components/card_component.dart +++ b/lib/android/components/card_component.dart @@ -1,6 +1,7 @@ import 'package:basic_utils/basic_utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; +import '../config/format_helper.dart'; import '../models/food.dart'; import '../pages/nav_pages/search_food.dart'; @@ -102,13 +103,6 @@ class _CardComponentState extends State { } return resultMap; } - - String getFoodListStringByFood(String foodName, int count, int calories){ - int maxWidth = 35; - String limitedText = foodName.length > maxWidth ? "${foodName.substring(0, maxWidth - 3)} ... $count x $calories kcal" : "$foodName $count x $calories kcal"; - return limitedText; - } - @override Widget build(BuildContext context) { return Card( diff --git a/lib/android/config/format_helper.dart b/lib/android/config/format_helper.dart new file mode 100644 index 0000000..76297ee --- /dev/null +++ b/lib/android/config/format_helper.dart @@ -0,0 +1,5 @@ +String getFoodListStringByFood(String foodName, int count, int calories){ + int maxWidth = 35; + String limitedText = foodName.length > maxWidth ? "${foodName.substring(0, maxWidth - 3)} ... $count x $calories kcal" : "$foodName $count x $calories kcal"; + return limitedText; +}