Jonny Borges

fix example

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(
// 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());
}
... ... @@ -34,103 +15,126 @@ 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(),
),
GetPage(
name: '/third',
page: () => const Third(),
),
],
debugShowCheckedModeBanner: false,
enableLog: true,
logWriterCallback: Logger.write,
initialRoute: AppPages.INITIAL,
getPages: AppPages.routes,
locale: TranslationService.locale,
fallbackLocale: TranslationService.fallbackLocale,
translations: TranslationService(),
);
}
}
class First extends StatelessWidget {
const First({Key? key}) : super(key: key);
/// Nav 2 snippet
// void main() {
// runApp(const MyApp());
// }
@override
Widget build(BuildContext context) {
print('First rebuild');
return Scaffold(
appBar: AppBar(
title: const Text('page one'),
leading: IconButton(
icon: const Icon(Icons.more),
onPressed: () {
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 MyApp extends StatelessWidget {
// const MyApp({Key? key}) : super(key: key);
class Second extends StatelessWidget {
const Second({Key? key}) : super(key: key);
// @override
// Widget build(BuildContext context) {
// return GetMaterialApp(
// getPages: [
// GetPage(
// participatesInRootNavigator: true,
// name: '/first',
// page: () => const First()),
// GetPage(
// name: '/second',
// page: () => const Second(),
// ),
// GetPage(
// name: '/third',
// page: () => const Third(),
// ),
// ],
// debugShowCheckedModeBanner: false,
// );
// }
// }
@override
Widget build(BuildContext context) {
print('second rebuild');
return Scaffold(
appBar: AppBar(
title: Text('page two ${Get.parameters["id"]}'),
),
body: Center(
child: SizedBox(
height: 300,
width: 300,
child: ElevatedButton(
onPressed: () {},
child: const Text('next screen'),
),
),
),
);
}
}
// class First extends StatelessWidget {
// const First({Key? key}) : super(key: key);
class Third extends StatelessWidget {
const Third({Key? key}) : super(key: key);
// @override
// Widget build(BuildContext context) {
// print('First rebuild');
// return Scaffold(
// appBar: AppBar(
// title: const Text('page one'),
// leading: IconButton(
// icon: const Icon(Icons.more),
// onPressed: () {
// 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 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) {
// print('second rebuild');
// return Scaffold(
// appBar: AppBar(
// title: Text('page two ${Get.parameters["id"]}'),
// ),
// body: Center(
// child: 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'),
// ),
// ),
// ),
// );
// }
// }
... ...