-
Notifications
You must be signed in to change notification settings - Fork 65
/
main.dart
68 lines (63 loc) · 1.99 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Developed by Marcelo Glasberg (2019) https://glasberg.dev and https://github.com/marcglasberg
// For more info, see: https://pub.dartlang.org/packages/i18n_extension
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:i18n_extension/i18n_extension.dart';
import 'main.i18n.dart';
import 'my_screen.dart';
/// This example demonstrates basic translations using a `I18n` widget.
///
/// There are 3 widget files that need translations:
/// * main.dart
/// * my_screen.dart
/// * my_widget.dart
///
/// And there is one translations-file for each one:
/// * main.i18n.dart
/// * my_screen.i18n.dart
/// * my_widget.i18n.dart
///
/// Note: We could have put all translations into a single translations-file
/// that would be used by all widget files. It's up to you how to organize
/// things.
///
/// Note: The translations-files in this example use strings as keys.
/// For example:
///
/// "You clicked the button %d times:".plural(counter),
///
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('en', "US"),
const Locale('pt', "BR"),
],
home: I18n(
// Usually you should not provide an initialLocale,
// and just let it use the system locale.
// initialLocale: Locale("pt", "BR"),
//
child: MyHomePage(),
),
);
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("i18n Demo".i18n)),
body: MyScreen(),
);
}
}