Skip to content

Instantly share code, notes, and snippets.

@HansMuller
Created September 27, 2019 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HansMuller/883d6f9d6a69a094f67d5bf9c93dd300 to your computer and use it in GitHub Desktop.
Save HansMuller/883d6f9d6a69a094f67d5bf9c93dd300 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'l10n/demo_localizations.dart';
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Text(DemoLocalizations.of(context).helloWorld()),
Text(DemoLocalizations.of(context).hello('International World')),
Text(DemoLocalizations.of(context).greeting('Greetings', 'Earthlings')),
Text(DemoLocalizations.of(context).helloWorlds(100)),
],
),
),
);
}
}
class I18NDemoApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
localizationsDelegates: <LocalizationsDelegate<dynamic>>[
DemoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: const <Locale>[
Locale('en', 'US'),
Locale('es', 'ES'),
],
home: Home(),
);
}
}
void main() {
runApp(I18NDemoApp());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment