locale_observer 1.0.0+2 locale_observer: ^1.0.0+2 copied to clipboard
Utility for detecting when the system tells the app that the user's locale has changed.
import 'package:flutter/material.dart';
import 'package:locale_observer/locale_observer.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return LocaleObserver(
didChangeLocales: (BuildContext context, List<Locale> locales) {
print("locales = $locales");
},
child: MaterialApp(
home: HomePage(),
),
);
}
}
class HomePage extends StatefulWidget {
@override
HomePageState createState() => HomePageState();
}
class HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text(''),
),
);
}
}