- Multi-Language Support: Supports English, Hindi, and Gujarati. Translates UI text dynamically based on user selection.
- Dynamic Language Switching: Dropdown menu in the app bar for selecting a language. Changes language instantly without restarting the app.
- Localized Texts: Includes common phrases like "Welcome Back", "Hello", "Welcome Message", and "Introduction" that are translated into the supported languages.
- The app uses
ValueNotifier
to manage the current locale dynamically. intl
andflutter_localizations
packages are used for localization setup.- A dropdown in the app bar allows users to select a language (English, Hindi, or Gujarati).
- Text widgets in the app retrieve translations using the
S.of(context)
generated delegate.
ValueNotifier localeNotifier = ValueNotifier(const Locale('en'));
Manages the selected language globally across the app.
DropdownButton<Locale>(
value: localeNotifier.value,
onChanged: (Locale? newLocale) {
if (newLocale != null) {
localeNotifier.value = newLocale;
}
},
items: const [
DropdownMenuItem(value: Locale('en'), child: Text('English')),
DropdownMenuItem(value: Locale('hi'), child: Text('Hindi')),
DropdownMenuItem(value: Locale('gu'), child: Text('Gujarati')),
],
)
Text(S.of(context).welcome_back);
- Clone the repository.
- Run the following command to generate localization files:
- Launch the app:
flutter pub run intl_utils:generate
flutter run
lib/
├── generated/ # Localization files generated by intl
├── screen/ # Screens of the app
│ └── localization_page.dart
├── main.dart # Entry point of the app
flutter_localizations
: Provides localization support for Flutter widgets.intl
: Enables internationalization for text, date, and number formatting.
This project serves as a foundation for implementing localization in Flutter applications, making it easier to create apps for a global audience.