wrapper.dart
1.74 KB
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
69
70
71
72
73
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class Wrapper extends StatelessWidget {
final Widget? child;
final List<GetPage>? namedRoutes;
final String? initialRoute;
final Transition? defaultTransition;
const Wrapper({
Key? key,
this.child,
this.namedRoutes,
this.initialRoute,
this.defaultTransition,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GetMaterialApp(
defaultTransition: defaultTransition,
initialRoute: initialRoute,
translations: WrapperTranslations(),
locale: WrapperTranslations.locale,
getPages: namedRoutes,
home: Scaffold(
body: child,
),
);
}
}
class WrapperNamed extends StatelessWidget {
final Widget? child;
final List<GetPage>? namedRoutes;
final String? initialRoute;
final Transition? defaultTransition;
const WrapperNamed({
Key? key,
this.child,
this.namedRoutes,
this.initialRoute,
this.defaultTransition,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return GetMaterialApp(
defaultTransition: defaultTransition,
initialRoute: initialRoute,
getPages: namedRoutes,
);
}
}
class WrapperTranslations extends Translations {
static final fallbackLocale = Locale('en', 'US');
static Locale? get locale => Locale('en', 'US');
@override
Map<String, Map<String, String>> get keys => {
'en_US': {
'covid': 'Corona Virus',
'total_confirmed': 'Total Confirmed',
'total_deaths': 'Total Deaths',
},
'pt_BR': {
'covid': 'Corona Vírus',
'total_confirmed': 'Total confirmado',
'total_deaths': 'Total de mortes',
},
};
}