mirror of
https://github.com/smmarty/friflex_flutter_starter.git
synced 2025-12-22 09:30:45 +00:00
init
This commit is contained in:
6
lib/l10n/app_en.arb
Normal file
6
lib/l10n/app_en.arb
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"helloWorld": "Hello World!",
|
||||
"@helloWorld": {
|
||||
"description": "The conventional newborn programmer greeting"
|
||||
}
|
||||
}
|
||||
6
lib/l10n/app_ru.arb
Normal file
6
lib/l10n/app_ru.arb
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"helloWorld": "Привет, мир!",
|
||||
"@helloWorld": {
|
||||
"description": "Обычное приветствие новичка-программиста"
|
||||
}
|
||||
}
|
||||
32
lib/l10n/localization_notifier.dart
Normal file
32
lib/l10n/localization_notifier.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
typedef LocalizationBuilder = Widget Function();
|
||||
|
||||
/// Виджет для перестройки виджета в зависимости от локализации
|
||||
class LocalizationConsumer extends StatelessWidget {
|
||||
const LocalizationConsumer({super.key, required this.builder});
|
||||
|
||||
final LocalizationBuilder builder;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<LocalizationNotifier>(
|
||||
builder: (_, __, ___) {
|
||||
return builder();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Класс для управления локализацией
|
||||
final class LocalizationNotifier extends ChangeNotifier {
|
||||
Locale _locale = const Locale('en', 'US');
|
||||
|
||||
Locale get locale => _locale;
|
||||
|
||||
void changeLocal(Locale locale) {
|
||||
_locale = locale;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user