25 lines
746 B
Dart
25 lines
746 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
/// Supported locales for the Tloto mobile app.
|
|
class AppLocale {
|
|
static const Locale english = Locale('en');
|
|
static const Locale french = Locale('fr');
|
|
|
|
static const List<Locale> supported = [english, french];
|
|
|
|
static const String _prefKey = 'app_locale';
|
|
|
|
static Future<Locale> loadSaved() async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
final code = prefs.getString(_prefKey);
|
|
if (code == 'fr') return french;
|
|
return english;
|
|
}
|
|
|
|
static Future<void> save(Locale locale) async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
await prefs.setString(_prefKey, locale.languageCode);
|
|
}
|
|
}
|