Files
lab-app/lib/core/providers/locale_provider.dart
T
Emre Emir 8bbc9dbff2 Initial commit: DLS - Dental Lab System
- Flutter + PocketBase dental lab management system
- Clinic & lab dashboards, job tracking, patient management
- Product catalog, finance tracking, multi-language support
- AI assistant integration, realtime notifications
- Windows installer (Inno Setup) included
- Developed by kovakyazilim.com
2026-06-11 15:57:31 +03:00

40 lines
1.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../l10n/app_strings.dart';
const _kLocaleKey = 'app_locale';
class LocaleNotifier extends StateNotifier<Locale> {
LocaleNotifier(Locale initial) : super(initial);
Future<void> setLocale(Locale locale) async {
state = locale;
final prefs = await SharedPreferences.getInstance();
await prefs.setString(_kLocaleKey, locale.languageCode);
}
static Future<Locale> load() async {
final prefs = await SharedPreferences.getInstance();
final code = prefs.getString(_kLocaleKey) ?? 'tr';
return Locale(code);
}
}
final localeProvider = StateNotifierProvider<LocaleNotifier, Locale>(
(ref) => LocaleNotifier(const Locale('tr')),
);
final stringsProvider = Provider<AppStrings>((ref) {
final locale = ref.watch(localeProvider);
return AppStrings.of(locale.languageCode);
});
const supportedLocales = [
Locale('tr'),
Locale('en'),
Locale('ru'),
Locale('ar'),
Locale('de'),
];