Skip to content

Commit

Permalink
fix: improve pokemon name information when is mega or contains -
Browse files Browse the repository at this point in the history
  • Loading branch information
brunogabriel committed Oct 31, 2024
1 parent 5026747 commit 4dd0a95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pokedex/lib/design/components/pokemon_information.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PokemonInformation extends StatelessWidget {
FittedBox(
fit: BoxFit.fitWidth,
child: Text(
pokemon.name.capitalize(),
pokemon.name.capitalizeName(),
overflow: TextOverflow.ellipsis,
style: textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
Expand Down
3 changes: 3 additions & 0 deletions pokedex/lib/shared/extensions/string_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ extension StringExtensions on String {
String capitalizeKebabCase() =>
split('-').map((e) => e.capitalize()).join(' ');

String capitalizeName() =>
replaceAll('-', ' ').split(' ').map((e) => e.capitalize()).join(' ');

// Replace
String replaceScapeChars([String newChar = ' ']) =>
replaceAll(RegExp(r'[\n\t\f]'), newChar).trim();
Expand Down

0 comments on commit 4dd0a95

Please sign in to comment.