Projet Minimal Flutter ciblant les plateformes suivantes
Plateformes
- Androïd ✅ TERMINÉ
- iOS ✅ TERMINÉ
- Web ✅ TERMINÉ
Captures d’écran
Mise en route 🚀
Ce projet contient 3 saveurs :
- développement
- mise en scène
- production
To generate code for injectable
```sh
$ flutter packages pub run build_runner build --delete-conflicting-outputs
---
To 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
---
## Running Tests 🧪
To run all unit and widget tests use the following command:
```sh
$ flutter test --coverage --test-randomize-ordering-seed random
Pour afficher le rapport de couverture généré, vous pouvez utiliser lcov.
# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/
# Open Coverage Report
$ open coverage/index.html
Travailler avec des traductions 🌐
Ce projet repose sur flutter_localisations et suit la guide officiel d’internationalisation pour Flutter.
Ajout de chaînes
- Pour ajouter une nouvelle chaîne localisable, ouvrez le
app_en.arb
déposer àlib/l10n/arb/app_en.arb
.
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
}
}
- Ajoutez ensuite une nouvelle clé/valeur et une description
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
},
"helloWorld": "Hello World",
"@helloWorld": {
"description": "Hello World Text"
}
}
- Exécutez la commande pour mettre à jour la traduction
# Generate Translations.
$ flutter gen-l10n --template-arb-file=arb/app_en.arb
- Utiliser la nouvelle chaîne après l’exécution
import 'package:flutter_praxis/l10n/l10n.dart';
@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return Text(l10n.helloWorld);
}
Ajout de paramètres régionaux pris en charge
Mettre à jour le CFBundleLocalizations
tableau dans le Info.plist
à ios/Runner/Info.plist
pour inclure la nouvelle locale.
...
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>es</string>
</array>
...
Ajouter des traductions
- Pour chaque paramètre régional pris en charge, ajoutez un nouveau fichier ARB dans
lib/l10n/arb
.
├── l10n
│ ├── arb
│ │ ├── app_en.arb
│ │ └── app_es.arb
- Ajoutez les chaînes traduites à chaque
.arb
dossier:
app_en.arb
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
}
}
app_es.arb
{
"@@locale": "es",
"counterAppBarTitle": "Contador",
"@counterAppBarTitle": {
"description": "Texto mostrado en la AppBar de la página del contador"
}
}
GitHub
Voir Github