Skip to content

Instantly share code, notes, and snippets.

@rohan20
Last active November 10, 2018 00:56
Show Gist options
  • Select an option

  • Save rohan20/14acd280e4367965bfe1324cb2cdffd9 to your computer and use it in GitHub Desktop.

Select an option

Save rohan20/14acd280e4367965bfe1324cb2cdffd9 to your computer and use it in GitHub Desktop.
flutter-localizations
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:your_app_package/services/localization/app_translations_delegate.dart';
import 'package:your_app_package/screens/home_page.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
localizationsDelegates: [
const AppTranslationsDelegate(),
//provides localised strings
GlobalMaterialLocalizations.delegate,
//provides RTL support
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
const Locale("en", ""),
const Locale("es", ""),
],
);
}
}
@GaryQian
Copy link

Hi @rohan20, Flutter recently removed support for passing '' as countryCodes. Since this is being referenced in a guide, it would be nice if you could either pass null (const Locale('en', null),) or omit the countryCode (const Locale('en'),)

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment