This commit is contained in:
petrovyuri
2025-01-21 14:24:31 +03:00
parent e7b2c31e86
commit 17d096baac
96 changed files with 3575 additions and 0 deletions

6
lib/l10n/app_en.arb Normal file
View File

@@ -0,0 +1,6 @@
{
"helloWorld": "Hello World!",
"@helloWorld": {
"description": "The conventional newborn programmer greeting"
}
}

6
lib/l10n/app_ru.arb Normal file
View File

@@ -0,0 +1,6 @@
{
"helloWorld": "Привет, мир!",
"@helloWorld": {
"description": "Обычное приветствие новичка-программиста"
}
}

View 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();
}
}