Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tech-andgar/demo-clean-flutter-app
https://github.com/tech-andgar/demo-clean-flutter-app
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/tech-andgar/demo-clean-flutter-app
- Owner: tech-andgar
- Created: 2024-01-03T22:20:27.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-30T21:17:41.000Z (13 days ago)
- Last Synced: 2024-12-30T22:18:55.070Z (13 days ago)
- Language: Dart
- Size: 8.44 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DEMO AFGR - Test Technical
![coverage][coverage_badge]
---
https://github.com/user-attachments/assets/6b6ef4c9-0b84-41c6-b419-504812ad79a0
## Getting Started π
This project contains 3 flavors:
- development
- staging
- productionTo run the desired flavor either use the launch configuration in VSCode/Android Studio or use the following commands:
```sh
# Development
$ flutter run --flavor development --target lib/main_development.dart# Staging
$ flutter run --flavor staging --target lib/main_staging.dart# Production
$ flutter run --flavor production --target lib/main_production.dart
```_\*Demo AFGR works on iOS, Android, Web, and Windows._
---
## Running Tests π§ͺ
To run all unit and widget tests use the following command:
```sh
flutter test --coverage --test-randomize-ordering-seed random
```To view the generated coverage report you can use [lcov](https://github.com/linux-test-project/lcov).
```sh
# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/# Open Coverage Report
$ open coverage/index.html
```---
## Working with Translations π
This project relies on flutter_localizations and follows the [Package easy_localization](https://pub.dev/packages/easy_localization).
### Adding Strings
1. To add a new localizable string, open the `en-US.json` file at `lib/resources/langs/en-US.json`.
```json
{
"feature": {
"main": {
"sliverListUrl": {
"dataEmpty": "Looks a bit empty here! Add your first shortened URLs."
},
"title": "Recently shortend URLs"
}
}
}
```2. Then add a new key/value and description
```json
{
"feature": {
"main": {
"sliverListUrl": {
"dataEmpty": "Looks a bit empty here! Add your first shortened URLs."
},
"title": "Recently shortend URLs"
}
},
"widget": {
"cdsItemListTileShortcutUrl": {
"iconButton": {
"onPressed": {
"msgSnackbar": "Link shortend {linkShortend}\nCopied to your clipboard"
}
}
}
}
}
```3. Use the new string
```dart
import 'package:easy_localization/easy_localization.dart';
import '../generated/locale_keys.g.dart';@override
Widget build(BuildContext context) {
return Text(LocaleKeys.feature_main_title.tr());
}
```or used with named arguments
```dart
import 'package:easy_localization/easy_localization.dart';
import '../generated/locale_keys.g.dart';@override
Widget build(BuildContext context) {
return Text(
LocaleKeys
.widget_cdsItemListTileShortcutUrl_iconButton_onPressed_msgSnackbar
.tr(namedArgs: {'linkShortend': 'https://short.link/123abc'})
);
}
```### Adding Supported Locales
Update the `CFBundleLocalizations` array in the `Info.plist` at `ios/Runner/Info.plist` to include the new locale.
```xml
...CFBundleLocalizations
en
es
...
```### Adding Translations
1. For each supported locale, add a new ARB file in `lib/resources/langs`.
```txt
βββ resources
β βββ langs
β β βββ en-US.json
β β βββ es-ES.json
```2. Add the translated strings to each `.json` file:
`es-ES.json`
```json
{
"feature": {
"main": {
"sliverListUrl": {
"dataEmpty": "Β‘Parece un poco vacΓo aquΓ! AΓ±ade tus primeras URLs acortadas."
},
"title": "URL acortadas recientemente"
}
}
}
````en-US.json`
```json
{
"feature": {
"main": {
"sliverListUrl": {
"dataEmpty": "Looks a bit empty here! Add your first shortened URLs."
},
"title": "Recently shortend URLs"
}
},
}
```### Generating Translations
To use the latest translations changes, you will need to generate them:
1. Generate localizations for the current project:
```sh
dart run easy_localization:generate && dart run easy_localization:generate -f keys -o locale_keys.g.dart
```[coverage_badge]: coverage_badge.svg