Skip to content

Commit

Permalink
Merge pull request #3164 from jonataslaw/wasm
Browse files Browse the repository at this point in the history
add support to wasm and refactor example app.
  • Loading branch information
jonataslaw committed Aug 13, 2024
2 parents 474af03 + 8c86d22 commit dc01d5d
Show file tree
Hide file tree
Showing 29 changed files with 697 additions and 721 deletions.
1 change: 0 additions & 1 deletion example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
/windows/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols
Expand Down
12 changes: 6 additions & 6 deletions example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "ba393198430278b6595976de84fe170f553cc728"
revision: "80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819"
channel: "stable"

project_type: app
Expand All @@ -13,11 +13,11 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: ba393198430278b6595976de84fe170f553cc728
base_revision: ba393198430278b6595976de84fe170f553cc728
- platform: ios
create_revision: ba393198430278b6595976de84fe170f553cc728
base_revision: ba393198430278b6595976de84fe170f553cc728
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
- platform: web
create_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819
base_revision: 80c2e84975bbd28ecf5f8d4bd4ca5a2490bfc819

# User provided section

Expand Down
11 changes: 4 additions & 7 deletions example/lib/lang/en_US.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// 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',
'update_language': 'Update language to Portuguese',
'number_of_prizes': 'Number of prizes',
'average_age_of_laureates': 'Average age of laureates',
'details': 'Details',
'total_recovered': 'Total Recovered',
'nobel_by_country': 'Nobel by country',
};
11 changes: 4 additions & 7 deletions example/lib/lang/pt_BR.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// 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',
'update_language': 'Atualizar idioma para Inglês',
'number_of_prizes': 'Número de prêmios',
'average_age_of_laureates': 'Idade média dos laureados',
'details': 'Detalhes',
'total_recovered': 'Total de recuperados'
'nobel_by_country': 'Nobel por país',
};
302 changes: 153 additions & 149 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';

// void main() {
// runApp(const MyApp());
// }

// class MyApp extends StatelessWidget {
// const MyApp({Key? key}) : super(key: key);

// @override
// Widget build(BuildContext context) {
// return GetMaterialApp(
// theme: ThemeData(useMaterial3: true),
// debugShowCheckedModeBanner: false,
// enableLog: true,
// logWriterCallback: Logger.write,
// initialRoute: AppPages.INITIAL,
// getPages: AppPages.routes,
// locale: TranslationService.locale,
// fallbackLocale: TranslationService.fallbackLocale,
// translations: TranslationService(),
// );
// }
// }
import 'lang/translation_service.dart';
import 'routes/app_pages.dart';
import 'shared/logger/logger_utils.dart';

/// Nav 2 snippet
void main() {
runApp(const MyApp());
}
Expand All @@ -35,141 +15,165 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GetMaterialApp(
getPages: [
GetPage(
participatesInRootNavigator: true,
name: '/first',
page: () => const First()),
GetPage(
name: '/second',
page: () => const Second(),
transition: Transition.downToUp,
),
GetPage(
name: '/third',
page: () => const Third(),
),
],
theme: ThemeData(useMaterial3: true),
debugShowCheckedModeBanner: false,
enableLog: true,
logWriterCallback: Logger.write,
initialRoute: AppPages.INITIAL,
getPages: AppPages.routes,
locale: TranslationService.locale,
fallbackLocale: TranslationService.fallbackLocale,
translations: TranslationService(),
);
}
}

class FirstController extends GetxController {
@override
void onClose() {
print('on close first');
super.onClose();
}
}
// /// Nav 2 snippet
// void main() {
// runApp(const MyApp());
// }

class First extends StatelessWidget {
const First({Key? key}) : super(key: key);
// class MyApp extends StatelessWidget {
// const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
print('First rebuild');
Get.put(FirstController());
return Scaffold(
appBar: AppBar(
title: const Text('page one'),
leading: IconButton(
icon: const Icon(Icons.more),
onPressed: () {
Get.snackbar(
'title',
"message",
mainButton:
TextButton(onPressed: () {}, child: const Text('button')),
isDismissible: true,
duration: Duration(seconds: 5),
snackbarStatus: (status) => print(status),
);
// print('THEME CHANGED');
// Get.changeTheme(
// Get.isDarkMode ? ThemeData.light() : ThemeData.dark());
},
),
),
body: Center(
child: SizedBox(
height: 300,
width: 300,
child: ElevatedButton(
onPressed: () {
Get.toNamed('/second?id=123');
},
child: const Text('next screen'),
),
),
),
);
}
}
// @override
// Widget build(BuildContext context) {
// return GetMaterialApp(
// getPages: [
// GetPage(
// participatesInRootNavigator: true,
// name: '/first',
// page: () => const First()),
// GetPage(
// name: '/second',
// page: () => const Second(),
// transition: Transition.downToUp,
// ),
// GetPage(
// name: '/third',
// page: () => const Third(),
// ),
// ],
// debugShowCheckedModeBanner: false,
// );
// }
// }

class SecondController extends GetxController {
final textEdit = TextEditingController();
@override
void onClose() {
print('on close second');
textEdit.dispose();
super.onClose();
}
}
// class FirstController extends GetxController {
// @override
// void onClose() {
// print('on close first');
// super.onClose();
// }
// }

class Second extends StatelessWidget {
const Second({Key? key}) : super(key: key);
// class First extends StatelessWidget {
// const First({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
final controller = Get.put(SecondController());
print('second rebuild');
return Scaffold(
appBar: AppBar(
title: Text('page two ${Get.parameters["id"]}'),
),
body: Center(
child: Column(
children: [
Expanded(
child: TextField(
controller: controller.textEdit,
)),
SizedBox(
height: 300,
width: 300,
child: ElevatedButton(
onPressed: () {},
child: const Text('next screen'),
),
),
],
),
),
);
}
}
// @override
// Widget build(BuildContext context) {
// print('First rebuild');
// Get.put(FirstController());
// return Scaffold(
// appBar: AppBar(
// title: const Text('page one'),
// leading: IconButton(
// icon: const Icon(Icons.more),
// onPressed: () {
// Get.snackbar(
// 'title',
// "message",
// mainButton:
// TextButton(onPressed: () {}, child: const Text('button')),
// isDismissible: true,
// duration: Duration(seconds: 5),
// snackbarStatus: (status) => print(status),
// );
// // print('THEME CHANGED');
// // Get.changeTheme(
// // Get.isDarkMode ? ThemeData.light() : ThemeData.dark());
// },
// ),
// ),
// body: Center(
// child: SizedBox(
// height: 300,
// width: 300,
// child: ElevatedButton(
// onPressed: () {
// Get.toNamed('/second?id=123');
// },
// child: const Text('next screen'),
// ),
// ),
// ),
// );
// }
// }

class Third extends StatelessWidget {
const Third({Key? key}) : super(key: key);
// class SecondController extends GetxController {
// final textEdit = TextEditingController();
// @override
// void onClose() {
// print('on close second');
// textEdit.dispose();
// super.onClose();
// }
// }

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.red,
appBar: AppBar(
title: const Text('page three'),
),
body: Center(
child: SizedBox(
height: 300,
width: 300,
child: ElevatedButton(
onPressed: () {},
child: const Text('go to first screen'),
),
),
),
);
}
}
// class Second extends StatelessWidget {
// const Second({Key? key}) : super(key: key);

// @override
// Widget build(BuildContext context) {
// final controller = Get.put(SecondController());
// print('second rebuild');
// return Scaffold(
// appBar: AppBar(
// title: Text('page two ${Get.parameters["id"]}'),
// ),
// body: Center(
// child: Column(
// children: [
// Expanded(
// child: TextField(
// controller: controller.textEdit,
// )),
// SizedBox(
// height: 300,
// width: 300,
// child: ElevatedButton(
// onPressed: () {},
// child: const Text('next screen'),
// ),
// ),
// ],
// ),
// ),
// );
// }
// }

// class Third extends StatelessWidget {
// const Third({Key? key}) : super(key: key);

// @override
// Widget build(BuildContext context) {
// return Scaffold(
// backgroundColor: Colors.red,
// appBar: AppBar(
// title: const Text('page three'),
// ),
// body: Center(
// child: SizedBox(
// height: 300,
// width: 300,
// child: ElevatedButton(
// onPressed: () {},
// child: const Text('go to first screen'),
// ),
// ),
// ),
// );
// }
// }
Loading

0 comments on commit dc01d5d

Please sign in to comment.