new change to use intaleq_map sdk 04-16-4
This commit is contained in:
12
packages/get/example/lib/lang/en_us.dart
Normal file
12
packages/get/example/lib/lang/en_us.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
// ignore_for_file: file_names
|
||||
|
||||
const Map<String, String> en_US = {
|
||||
'covid': 'Corona Virus',
|
||||
'total_confirmed': 'Total Confirmed',
|
||||
'total_deaths': 'Total Deaths',
|
||||
'fetch_country': 'Fetch by country',
|
||||
'corona_by_country': 'Corona by country',
|
||||
'total_infecteds': 'Total Infecteds',
|
||||
'details': 'Details',
|
||||
'total_recovered': 'Total Recovered',
|
||||
};
|
||||
12
packages/get/example/lib/lang/pt_br.dart
Normal file
12
packages/get/example/lib/lang/pt_br.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
// ignore_for_file: file_names
|
||||
|
||||
const Map<String, String> pt_BR = {
|
||||
'covid': 'Corona Vírus',
|
||||
'total_confirmed': 'Total confirmado',
|
||||
'total_deaths': 'Total de mortes',
|
||||
'fetch_country': 'Listar por país',
|
||||
'corona_by_country': 'Corona por país',
|
||||
'total_infecteds': 'Total de infectados',
|
||||
'details': 'Detalhes',
|
||||
'total_recovered': 'Total de recuperados'
|
||||
};
|
||||
15
packages/get/example/lib/lang/translation_service.dart
Normal file
15
packages/get/example/lib/lang/translation_service.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'en_us.dart';
|
||||
import 'pt_br.dart';
|
||||
|
||||
class TranslationService extends Translations {
|
||||
static Locale? get locale => Get.deviceLocale;
|
||||
static final fallbackLocale = Locale('en', 'US');
|
||||
@override
|
||||
Map<String, Map<String, String>> get keys => {
|
||||
'en_US': en_US,
|
||||
'pt_BR': pt_BR,
|
||||
};
|
||||
}
|
||||
129
packages/get/example/lib/main.dart
Normal file
129
packages/get/example/lib/main.dart
Normal file
@@ -0,0 +1,129 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'lang/translation_service.dart';
|
||||
import 'routes/app_pages.dart';
|
||||
import 'shared/logger/logger_utils.dart';
|
||||
|
||||
void main() {
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetMaterialApp.router(
|
||||
debugShowCheckedModeBanner: false,
|
||||
enableLog: true,
|
||||
logWriterCallback: Logger.write,
|
||||
// initialRoute: AppPages.INITIAL,
|
||||
getPages: AppPages.routes,
|
||||
locale: TranslationService.locale,
|
||||
fallbackLocale: TranslationService.fallbackLocale,
|
||||
translations: TranslationService(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Nav 2 snippet
|
||||
// void main() {
|
||||
// runApp(MyApp());
|
||||
// }
|
||||
|
||||
// class MyApp extends StatelessWidget {
|
||||
// MyApp({Key? key}) : super(key: key);
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return GetMaterialApp.router(
|
||||
// getPages: [
|
||||
// GetPage(
|
||||
// participatesInRootNavigator: true,
|
||||
// name: '/first',
|
||||
// page: () => First()),
|
||||
// GetPage(
|
||||
// name: '/second',
|
||||
// page: () => Second(),
|
||||
// ),
|
||||
// GetPage(
|
||||
// name: '/third',
|
||||
// page: () => Third(),
|
||||
// ),
|
||||
// ],
|
||||
// debugShowCheckedModeBanner: false,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// class First extends StatelessWidget {
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// appBar: AppBar(
|
||||
// title: Text('page one'),
|
||||
// leading: IconButton(
|
||||
// icon: Icon(Icons.more),
|
||||
// onPressed: () {
|
||||
// Get.changeTheme(
|
||||
// context.isDarkMode ? ThemeData.light() : ThemeData.dark());
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// body: Center(
|
||||
// child: Container(
|
||||
// height: 300,
|
||||
// width: 300,
|
||||
// child: ElevatedButton(
|
||||
// onPressed: () {},
|
||||
// child: Text('next screen'),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// class Second extends StatelessWidget {
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// appBar: AppBar(
|
||||
// title: Text('page two ${Get.parameters["id"]}'),
|
||||
// ),
|
||||
// body: Center(
|
||||
// child: Container(
|
||||
// height: 300,
|
||||
// width: 300,
|
||||
// child: ElevatedButton(
|
||||
// onPressed: () {},
|
||||
// child: Text('next screen'),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// class Third extends StatelessWidget {
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Scaffold(
|
||||
// backgroundColor: Colors.red,
|
||||
// appBar: AppBar(
|
||||
// title: Text('page three'),
|
||||
// ),
|
||||
// body: Center(
|
||||
// child: Container(
|
||||
// height: 300,
|
||||
// width: 300,
|
||||
// child: ElevatedButton(
|
||||
// onPressed: () {},
|
||||
// child: Text('go to first screen'),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:get/get.dart';
|
||||
import '../data/home_api_provider.dart';
|
||||
|
||||
import '../data/home_repository.dart';
|
||||
import '../domain/adapters/repository_adapter.dart';
|
||||
import '../presentation/controllers/home_controller.dart';
|
||||
|
||||
class HomeBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut<IHomeProvider>(() => HomeProvider());
|
||||
Get.lazyPut<IHomeRepository>(() => HomeRepository(provider: Get.find()));
|
||||
Get.lazyPut(() => HomeController(homeRepository: Get.find()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:get/get.dart';
|
||||
import '../domain/entity/cases_model.dart';
|
||||
|
||||
// ignore: one_member_abstracts
|
||||
abstract class IHomeProvider {
|
||||
Future<Response<CasesModel>> getCases(String path);
|
||||
}
|
||||
|
||||
class HomeProvider extends GetConnect implements IHomeProvider {
|
||||
@override
|
||||
void onInit() {
|
||||
httpClient.defaultDecoder =
|
||||
(val) => CasesModel.fromJson(val as Map<String, dynamic>);
|
||||
httpClient.baseUrl = 'https://api.covid19api.com';
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Response<CasesModel>> getCases(String path) => get(path);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import '../domain/adapters/repository_adapter.dart';
|
||||
import '../domain/entity/cases_model.dart';
|
||||
import 'home_api_provider.dart';
|
||||
|
||||
class HomeRepository implements IHomeRepository {
|
||||
HomeRepository({required this.provider});
|
||||
final IHomeProvider provider;
|
||||
|
||||
@override
|
||||
Future<CasesModel> getCases() async {
|
||||
final cases = await provider.getCases("/summary");
|
||||
if (cases.status.hasError) {
|
||||
return Future.error(cases.statusText!);
|
||||
} else {
|
||||
return cases.body!;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import '../entity/cases_model.dart';
|
||||
|
||||
// ignore: one_member_abstracts
|
||||
abstract class IHomeRepository {
|
||||
Future<CasesModel> getCases();
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final welcome = welcomeFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
class CasesModel {
|
||||
CasesModel({
|
||||
required this.id,
|
||||
required this.message,
|
||||
required this.global,
|
||||
required this.countries,
|
||||
required this.date,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String message;
|
||||
final Global global;
|
||||
final List<Country> countries;
|
||||
final DateTime date;
|
||||
|
||||
factory CasesModel.fromRawJson(String str) =>
|
||||
CasesModel.fromJson(json.decode(str) as Map<String, dynamic>);
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory CasesModel.fromJson(Map<String, dynamic> json) => CasesModel(
|
||||
id: json["ID"] as String,
|
||||
message: json["Message"] as String,
|
||||
global: Global.fromJson(json["Global"] as Map<String, dynamic>),
|
||||
countries: List<Country>.from((json["Countries"] as Iterable).map(
|
||||
(x) => Country.fromJson(x as Map<String, dynamic>),
|
||||
)),
|
||||
date: DateTime.parse(json["Date"] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"ID": id,
|
||||
"Message": message,
|
||||
"Global": global.toJson(),
|
||||
"Countries": List<dynamic>.from(countries.map((x) => x.toJson())),
|
||||
"Date": date.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
class Country {
|
||||
Country({
|
||||
required this.id,
|
||||
required this.country,
|
||||
required this.countryCode,
|
||||
required this.slug,
|
||||
required this.newConfirmed,
|
||||
required this.totalConfirmed,
|
||||
required this.newDeaths,
|
||||
required this.totalDeaths,
|
||||
required this.newRecovered,
|
||||
required this.totalRecovered,
|
||||
required this.date,
|
||||
required this.premium,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String country;
|
||||
final String countryCode;
|
||||
final String slug;
|
||||
final int newConfirmed;
|
||||
final int totalConfirmed;
|
||||
final int newDeaths;
|
||||
final int totalDeaths;
|
||||
final int newRecovered;
|
||||
final int totalRecovered;
|
||||
final DateTime date;
|
||||
final Premium premium;
|
||||
|
||||
factory Country.fromRawJson(String str) =>
|
||||
Country.fromJson(json.decode(str) as Map<String, dynamic>);
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory Country.fromJson(Map<String, dynamic> json) => Country(
|
||||
id: json["ID"] as String,
|
||||
country: json["Country"] as String,
|
||||
countryCode: json["CountryCode"] as String,
|
||||
slug: json["Slug"] as String,
|
||||
newConfirmed: json["NewConfirmed"] as int,
|
||||
totalConfirmed: json["TotalConfirmed"] as int,
|
||||
newDeaths: json["NewDeaths"] as int,
|
||||
totalDeaths: json["TotalDeaths"] as int,
|
||||
newRecovered: json["NewRecovered"] as int,
|
||||
totalRecovered: json["TotalRecovered"] as int,
|
||||
date: DateTime.parse(json["Date"] as String),
|
||||
premium: Premium.fromJson(json["Premium"] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"ID": id,
|
||||
"Country": country,
|
||||
"CountryCode": countryCode,
|
||||
"Slug": slug,
|
||||
"NewConfirmed": newConfirmed,
|
||||
"TotalConfirmed": totalConfirmed,
|
||||
"NewDeaths": newDeaths,
|
||||
"TotalDeaths": totalDeaths,
|
||||
"NewRecovered": newRecovered,
|
||||
"TotalRecovered": totalRecovered,
|
||||
"Date": date.toIso8601String(),
|
||||
"Premium": premium.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
class Premium {
|
||||
Premium();
|
||||
|
||||
factory Premium.fromRawJson(String str) =>
|
||||
Premium.fromJson(json.decode(str) as Map<String, dynamic>);
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory Premium.fromJson(Map<String, dynamic> json) => Premium();
|
||||
|
||||
Map<String, dynamic> toJson() => {};
|
||||
}
|
||||
|
||||
class Global {
|
||||
Global({
|
||||
required this.newConfirmed,
|
||||
required this.totalConfirmed,
|
||||
required this.newDeaths,
|
||||
required this.totalDeaths,
|
||||
required this.newRecovered,
|
||||
required this.totalRecovered,
|
||||
required this.date,
|
||||
});
|
||||
|
||||
final int newConfirmed;
|
||||
final int totalConfirmed;
|
||||
final int newDeaths;
|
||||
final int totalDeaths;
|
||||
final int newRecovered;
|
||||
final int totalRecovered;
|
||||
final DateTime date;
|
||||
|
||||
factory Global.fromRawJson(String str) =>
|
||||
Global.fromJson(json.decode(str) as Map<String, dynamic>);
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory Global.fromJson(Map<String, dynamic> json) => Global(
|
||||
newConfirmed: json["NewConfirmed"] as int,
|
||||
totalConfirmed: json["TotalConfirmed"] as int,
|
||||
newDeaths: json["NewDeaths"] as int,
|
||||
totalDeaths: json["TotalDeaths"] as int,
|
||||
newRecovered: json["NewRecovered"] as int,
|
||||
totalRecovered: json["TotalRecovered"] as int,
|
||||
date: DateTime.parse(json["Date"] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"NewConfirmed": newConfirmed,
|
||||
"TotalConfirmed": totalConfirmed,
|
||||
"NewDeaths": newDeaths,
|
||||
"TotalDeaths": totalDeaths,
|
||||
"NewRecovered": newRecovered,
|
||||
"TotalRecovered": totalRecovered,
|
||||
"Date": date.toIso8601String(),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../domain/adapters/repository_adapter.dart';
|
||||
import '../../domain/entity/cases_model.dart';
|
||||
|
||||
class HomeController extends SuperController<CasesModel> {
|
||||
HomeController({required this.homeRepository});
|
||||
|
||||
final IHomeRepository homeRepository;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
//Loading, Success, Error handle with 1 line of code
|
||||
append(() => homeRepository.getCases);
|
||||
}
|
||||
|
||||
Country getCountryById(String id) {
|
||||
final index = int.tryParse(id);
|
||||
if (index != null) {
|
||||
return state!.countries[index];
|
||||
}
|
||||
|
||||
return state!.countries.first;
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
print('The build method is done. '
|
||||
'Your controller is ready to call dialogs and snackbars');
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
print('onClose called');
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeMetrics() {
|
||||
print('the window size did change');
|
||||
super.didChangeMetrics();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangePlatformBrightness() {
|
||||
print('platform change ThemeMode');
|
||||
super.didChangePlatformBrightness();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> didPushRoute(String route) {
|
||||
print('the route $route will be open');
|
||||
return super.didPushRoute(route);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> didPopRoute() {
|
||||
print('the current route will be closed');
|
||||
return super.didPopRoute();
|
||||
}
|
||||
|
||||
@override
|
||||
void onDetached() {
|
||||
print('onDetached called');
|
||||
}
|
||||
|
||||
@override
|
||||
void onInactive() {
|
||||
print('onInative called');
|
||||
}
|
||||
|
||||
@override
|
||||
void onPaused() {
|
||||
print('onPaused called');
|
||||
}
|
||||
|
||||
@override
|
||||
void onResumed() {
|
||||
print('onResumed called');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../controllers/home_controller.dart';
|
||||
|
||||
class CountryView extends GetView<HomeController> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
colorFilter: ColorFilter.linearToSrgbGamma(),
|
||||
image: NetworkImage(
|
||||
"https://images.pexels.com/photos/3902882/pexels-photo-3902882.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"))),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0),
|
||||
child: Container(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
title: Text('corona_by_country'.tr),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
),
|
||||
body: Center(
|
||||
child: ListView.builder(
|
||||
itemCount: controller.state!.countries.length,
|
||||
itemBuilder: (context, index) {
|
||||
final country = controller.state!.countries[index];
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
//Get.rootDelegate.toNamed('/home/country');
|
||||
Get.rootDelegate
|
||||
.toNamed('/home/country/details?id=$index');
|
||||
},
|
||||
trailing: CircleAvatar(
|
||||
backgroundImage: NetworkImage(
|
||||
"https://flagpedia.net/data/flags/normal/${country.countryCode.toLowerCase()}.png"),
|
||||
),
|
||||
title: Text(country.country),
|
||||
subtitle: Text(
|
||||
// ignore: lines_longer_than_80_chars
|
||||
'${'total_infecteds'.tr}${' ${country.totalConfirmed}'}'),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../controllers/home_controller.dart';
|
||||
|
||||
class DetailsView extends GetView<HomeController> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final parameter = Get.rootDelegate.parameters;
|
||||
final country = controller.getCountryById(parameter['id'] ?? '');
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
colorFilter: ColorFilter.linearToSrgbGamma(),
|
||||
image: NetworkImage(
|
||||
"https://flagpedia.net/data/flags/normal/${country.countryCode.toLowerCase()}.png"),
|
||||
),
|
||||
),
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0),
|
||||
child: Container(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
title: Text('details'.tr),
|
||||
backgroundColor: Colors.black12,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'${country.country}',
|
||||
style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 35,
|
||||
),
|
||||
Text(
|
||||
'total_confirmed'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${country.totalConfirmed}',
|
||||
style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
'total_deaths'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${country.totalDeaths}',
|
||||
style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
'total_recovered'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${country.totalRecovered}',
|
||||
style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../controllers/home_controller.dart';
|
||||
|
||||
class HomeView extends GetView<HomeController> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
colorFilter: ColorFilter.linearToSrgbGamma(),
|
||||
image: NetworkImage(
|
||||
"https://images.pexels.com/photos/3902882/pexels-photo-3902882.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"),
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.add),
|
||||
onPressed: () {
|
||||
Get.snackbar('title', 'message');
|
||||
},
|
||||
),
|
||||
title: Text('covid'.tr),
|
||||
backgroundColor: Colors.white10,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
),
|
||||
body: Center(
|
||||
child: controller.obx(
|
||||
(state) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
Text(
|
||||
'total_confirmed'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${state!.global.totalConfirmed}',
|
||||
style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
'total_deaths'.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 30,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${state.global.totalDeaths}',
|
||||
style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
textStyle: TextStyle(color: Colors.black),
|
||||
side: BorderSide(
|
||||
color: Colors.deepPurple,
|
||||
width: 3,
|
||||
),
|
||||
shape: StadiumBorder(),
|
||||
),
|
||||
onPressed: () async {
|
||||
final data =
|
||||
await Get.rootDelegate.toNamed('/home/country');
|
||||
print('DATA: $data');
|
||||
},
|
||||
child: Text(
|
||||
'fetch_country'.tr,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
textStyle: TextStyle(color: Colors.black),
|
||||
side: BorderSide(
|
||||
color: Colors.deepPurple,
|
||||
width: 3,
|
||||
),
|
||||
shape: StadiumBorder(),
|
||||
),
|
||||
onPressed: () {
|
||||
Get.updateLocale(Locale('pt', 'BR'));
|
||||
},
|
||||
child: Text(
|
||||
'Update language to Portuguese',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
32
packages/get/example/lib/routes/app_pages.dart
Normal file
32
packages/get/example/lib/routes/app_pages.dart
Normal file
@@ -0,0 +1,32 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../pages/home/bindings/home_binding.dart';
|
||||
import '../pages/home/presentation/views/country_view.dart';
|
||||
import '../pages/home/presentation/views/details_view.dart';
|
||||
import '../pages/home/presentation/views/home_view.dart';
|
||||
|
||||
part 'app_routes.dart';
|
||||
|
||||
// ignore: avoid_classes_with_only_static_members
|
||||
class AppPages {
|
||||
static const INITIAL = Routes.HOME;
|
||||
|
||||
static final routes = [
|
||||
GetPage(
|
||||
name: Routes.HOME,
|
||||
page: () => HomeView(),
|
||||
binding: HomeBinding(),
|
||||
children: [
|
||||
GetPage(
|
||||
name: Routes.COUNTRY,
|
||||
page: () => CountryView(),
|
||||
children: [
|
||||
GetPage(
|
||||
name: Routes.DETAILS,
|
||||
page: () => DetailsView(),
|
||||
),
|
||||
],
|
||||
),
|
||||
]),
|
||||
];
|
||||
}
|
||||
7
packages/get/example/lib/routes/app_routes.dart
Normal file
7
packages/get/example/lib/routes/app_routes.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
part of 'app_pages.dart';
|
||||
|
||||
abstract class Routes {
|
||||
static const HOME = '/home';
|
||||
static const COUNTRY = '/country';
|
||||
static const DETAILS = '/details';
|
||||
}
|
||||
6
packages/get/example/lib/shared/logger/logger_utils.dart
Normal file
6
packages/get/example/lib/shared/logger/logger_utils.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
mixin Logger {
|
||||
// Sample of abstract logging function
|
||||
static void write(String text, {bool isError = false}) {
|
||||
Future.microtask(() => print('** $text. isError: [$isError]'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user