Skip to content

Instantly share code, notes, and snippets.

@roipeker
Created July 14, 2021 20:30
Show Gist options
  • Save roipeker/7bee8d463fe349336412edc15d0fddf0 to your computer and use it in GitHub Desktop.
Save roipeker/7bee8d463fe349336412edc15d0fddf0 to your computer and use it in GitHub Desktop.
GetX/Material issue with locales
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GetMaterialApp(
supportedLocales: [Locale('es'), Locale('en')],
locale: Locale('es'), /// "es" locale not found in Material and fallback doesnt work.
/// fix:
/// localeResolutionCallback: (_, __) => Locale('en'),
fallbackLocale: Locale('en'),
translationsKeys: {'en': {}, 'es': {}}, /// irrelevant for Material
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('locales bug')),
);
}
}
name: getx_test
description: test for intl8 issue
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.13.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
get: ^4.1.4
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment