From 22137f66cf8b03f17262ce8da743d312bc601bb6 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 1 Oct 2023 11:11:50 +0300 Subject: [PATCH] Correct toTitleCase function --- lib/ui/company_gateway/edit/company_gateway_edit.dart | 3 +-- lib/utils/strings.dart | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ui/company_gateway/edit/company_gateway_edit.dart b/lib/ui/company_gateway/edit/company_gateway_edit.dart index 23902a92c..473d67db6 100644 --- a/lib/ui/company_gateway/edit/company_gateway_edit.dart +++ b/lib/ui/company_gateway/edit/company_gateway_edit.dart @@ -265,8 +265,7 @@ class _CompanyGatewayEditState extends State .toList(), ), SizedBox(height: 16), - for (var gatewayTypeId - in gateway?.options.keys ?? []) + for (var gatewayTypeId in gateway?.options.keys ?? []) SwitchListTile( title: Text(kGatewayTypes.containsKey(gatewayTypeId) ? localization diff --git a/lib/utils/strings.dart b/lib/utils/strings.dart index e0cfd295d..cdbe588ec 100644 --- a/lib/utils/strings.dart +++ b/lib/utils/strings.dart @@ -51,7 +51,8 @@ String toTitleCase(String text) { return text.toUpperCase(); } - text = toSpaceCase(text.toLowerCase()); + text = toSpaceCase(text); + final words = text.split(' '); final capitalized = words.map((word) { if (word == 'url') { @@ -63,7 +64,7 @@ String toTitleCase(String text) { } final first = word.substring(0, 1).toUpperCase(); - final rest = word.substring(1); + final rest = word.substring(1).toLowerCase(); return '$first$rest'; });