Jonny Borges

fix onClosed is not called. Add onHidden lifecycle

1 # This file tracks properties of this Flutter project. 1 # This file tracks properties of this Flutter project.
2 # Used by Flutter tool to assess capabilities and perform upgrades etc. 2 # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 # 3 #
4 -# This file should be version controlled. 4 +# This file should be version controlled and should not be manually edited.
5 5
6 version: 6 version:
7 - revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
8 - channel: stable 7 + revision: "e1e47221e86272429674bec4f1bd36acc4fc7b77"
  8 + channel: "stable"
9 9
10 project_type: app 10 project_type: app
11 11
@@ -13,26 +13,11 @@ project_type: app @@ -13,26 +13,11 @@ project_type: app
13 migration: 13 migration:
14 platforms: 14 platforms:
15 - platform: root 15 - platform: root
16 - create_revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
17 - base_revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
18 - - platform: android  
19 - create_revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
20 - base_revision: c07f7888888435fd9df505aa2efc38d3cf65681b 16 + create_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77
  17 + base_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77
21 - platform: ios 18 - platform: ios
22 - create_revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
23 - base_revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
24 - - platform: linux  
25 - create_revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
26 - base_revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
27 - - platform: macos  
28 - create_revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
29 - base_revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
30 - - platform: web  
31 - create_revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
32 - base_revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
33 - - platform: windows  
34 - create_revision: c07f7888888435fd9df505aa2efc38d3cf65681b  
35 - base_revision: c07f7888888435fd9df505aa2efc38d3cf65681b 19 + create_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77
  20 + base_revision: e1e47221e86272429674bec4f1bd36acc4fc7b77
36 21
37 # User provided section 22 # User provided section
38 23
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:get/get.dart'; 2 import 'package:get/get.dart';
3 3
4 -import 'lang/translation_service.dart';  
5 -import 'routes/app_pages.dart';  
6 -import 'shared/logger/logger_utils.dart'; 4 +// void main() {
  5 +// runApp(const MyApp());
  6 +// }
7 7
  8 +// class MyApp extends StatelessWidget {
  9 +// const MyApp({Key? key}) : super(key: key);
  10 +
  11 +// @override
  12 +// Widget build(BuildContext context) {
  13 +// return GetMaterialApp(
  14 +// theme: ThemeData(useMaterial3: true),
  15 +// debugShowCheckedModeBanner: false,
  16 +// enableLog: true,
  17 +// logWriterCallback: Logger.write,
  18 +// initialRoute: AppPages.INITIAL,
  19 +// getPages: AppPages.routes,
  20 +// locale: TranslationService.locale,
  21 +// fallbackLocale: TranslationService.fallbackLocale,
  22 +// translations: TranslationService(),
  23 +// );
  24 +// }
  25 +// }
  26 +
  27 +/// Nav 2 snippet
8 void main() { 28 void main() {
9 runApp(const MyApp()); 29 runApp(const MyApp());
10 } 30 }
@@ -15,127 +35,131 @@ class MyApp extends StatelessWidget { @@ -15,127 +35,131 @@ class MyApp extends StatelessWidget {
15 @override 35 @override
16 Widget build(BuildContext context) { 36 Widget build(BuildContext context) {
17 return GetMaterialApp( 37 return GetMaterialApp(
18 - theme: ThemeData(useMaterial3: true), 38 + getPages: [
  39 + GetPage(
  40 + participatesInRootNavigator: true,
  41 + name: '/first',
  42 + page: () => const First()),
  43 + GetPage(
  44 + name: '/second',
  45 + page: () => const Second(),
  46 + ),
  47 + GetPage(
  48 + name: '/third',
  49 + page: () => const Third(),
  50 + ),
  51 + ],
19 debugShowCheckedModeBanner: false, 52 debugShowCheckedModeBanner: false,
20 - enableLog: true,  
21 - logWriterCallback: Logger.write,  
22 - initialRoute: AppPages.INITIAL,  
23 - getPages: AppPages.routes,  
24 - locale: TranslationService.locale,  
25 - fallbackLocale: TranslationService.fallbackLocale,  
26 - translations: TranslationService(),  
27 ); 53 );
28 } 54 }
29 } 55 }
30 56
31 -/// Nav 2 snippet  
32 -// void main() {  
33 -// runApp(const MyApp());  
34 -// }  
35 -  
36 -// class MyApp extends StatelessWidget {  
37 -// const MyApp({Key? key}) : super(key: key); 57 +class FirstController extends GetxController {
  58 + @override
  59 + void onClose() {
  60 + print('on close first');
  61 + super.onClose();
  62 + }
  63 +}
38 64
39 -// @override  
40 -// Widget build(BuildContext context) {  
41 -// return GetMaterialApp(  
42 -// getPages: [  
43 -// GetPage(  
44 -// participatesInRootNavigator: true,  
45 -// name: '/first',  
46 -// page: () => const First()),  
47 -// GetPage(  
48 -// name: '/second',  
49 -// page: () => const Second(),  
50 -// ),  
51 -// GetPage(  
52 -// name: '/third',  
53 -// page: () => const Third(),  
54 -// ),  
55 -// ],  
56 -// debugShowCheckedModeBanner: false,  
57 -// );  
58 -// }  
59 -// } 65 +class First extends StatelessWidget {
  66 + const First({Key? key}) : super(key: key);
60 67
61 -// class First extends StatelessWidget {  
62 -// const First({Key? key}) : super(key: key); 68 + @override
  69 + Widget build(BuildContext context) {
  70 + print('First rebuild');
  71 + Get.put(FirstController());
  72 + return Scaffold(
  73 + appBar: AppBar(
  74 + title: const Text('page one'),
  75 + leading: IconButton(
  76 + icon: const Icon(Icons.more),
  77 + onPressed: () {
  78 + print('THEME CHANGED');
  79 + Get.changeTheme(
  80 + Get.isDarkMode ? ThemeData.light() : ThemeData.dark());
  81 + },
  82 + ),
  83 + ),
  84 + body: Center(
  85 + child: SizedBox(
  86 + height: 300,
  87 + width: 300,
  88 + child: ElevatedButton(
  89 + onPressed: () {
  90 + Get.toNamed('/second?id=123');
  91 + },
  92 + child: const Text('next screen'),
  93 + ),
  94 + ),
  95 + ),
  96 + );
  97 + }
  98 +}
63 99
64 -// @override  
65 -// Widget build(BuildContext context) {  
66 -// print('First rebuild');  
67 -// return Scaffold(  
68 -// appBar: AppBar(  
69 -// title: const Text('page one'),  
70 -// leading: IconButton(  
71 -// icon: const Icon(Icons.more),  
72 -// onPressed: () {  
73 -// print('THEME CHANGED');  
74 -// Get.changeTheme(  
75 -// Get.isDarkMode ? ThemeData.light() : ThemeData.dark());  
76 -// },  
77 -// ),  
78 -// ),  
79 -// body: Center(  
80 -// child: SizedBox(  
81 -// height: 300,  
82 -// width: 300,  
83 -// child: ElevatedButton(  
84 -// onPressed: () {  
85 -// Get.toNamed('/second?id=123');  
86 -// },  
87 -// child: const Text('next screen'),  
88 -// ),  
89 -// ),  
90 -// ),  
91 -// );  
92 -// }  
93 -// } 100 +class SecondController extends GetxController {
  101 + final textEdit = TextEditingController();
  102 + @override
  103 + void onClose() {
  104 + print('on close second');
  105 + textEdit.dispose();
  106 + super.onClose();
  107 + }
  108 +}
94 109
95 -// class Second extends StatelessWidget {  
96 -// const Second({Key? key}) : super(key: key); 110 +class Second extends StatelessWidget {
  111 + const Second({Key? key}) : super(key: key);
97 112
98 -// @override  
99 -// Widget build(BuildContext context) {  
100 -// print('second rebuild');  
101 -// return Scaffold(  
102 -// appBar: AppBar(  
103 -// title: Text('page two ${Get.parameters["id"]}'),  
104 -// ),  
105 -// body: Center(  
106 -// child: SizedBox(  
107 -// height: 300,  
108 -// width: 300,  
109 -// child: ElevatedButton(  
110 -// onPressed: () {},  
111 -// child: const Text('next screen'),  
112 -// ),  
113 -// ),  
114 -// ),  
115 -// );  
116 -// }  
117 -// } 113 + @override
  114 + Widget build(BuildContext context) {
  115 + final controller = Get.put(SecondController());
  116 + print('second rebuild');
  117 + return Scaffold(
  118 + appBar: AppBar(
  119 + title: Text('page two ${Get.parameters["id"]}'),
  120 + ),
  121 + body: Center(
  122 + child: Column(
  123 + children: [
  124 + Expanded(
  125 + child: TextField(
  126 + controller: controller.textEdit,
  127 + )),
  128 + SizedBox(
  129 + height: 300,
  130 + width: 300,
  131 + child: ElevatedButton(
  132 + onPressed: () {},
  133 + child: const Text('next screen'),
  134 + ),
  135 + ),
  136 + ],
  137 + ),
  138 + ),
  139 + );
  140 + }
  141 +}
118 142
119 -// class Third extends StatelessWidget {  
120 -// const Third({Key? key}) : super(key: key); 143 +class Third extends StatelessWidget {
  144 + const Third({Key? key}) : super(key: key);
121 145
122 -// @override  
123 -// Widget build(BuildContext context) {  
124 -// return Scaffold(  
125 -// backgroundColor: Colors.red,  
126 -// appBar: AppBar(  
127 -// title: const Text('page three'),  
128 -// ),  
129 -// body: Center(  
130 -// child: SizedBox(  
131 -// height: 300,  
132 -// width: 300,  
133 -// child: ElevatedButton(  
134 -// onPressed: () {},  
135 -// child: const Text('go to first screen'),  
136 -// ),  
137 -// ),  
138 -// ),  
139 -// );  
140 -// }  
141 -// } 146 + @override
  147 + Widget build(BuildContext context) {
  148 + return Scaffold(
  149 + backgroundColor: Colors.red,
  150 + appBar: AppBar(
  151 + title: const Text('page three'),
  152 + ),
  153 + body: Center(
  154 + child: SizedBox(
  155 + height: 300,
  156 + width: 300,
  157 + child: ElevatedButton(
  158 + onPressed: () {},
  159 + child: const Text('go to first screen'),
  160 + ),
  161 + ),
  162 + ),
  163 + );
  164 + }
  165 +}
1 -sdk.dir=/home/sumit/Android/Sdk  
2 -flutter.sdk=/home/sumit/softwares/flutter  
  1 +sdk.dir=/Users/jonatasborges/Library/Android/sdk
  2 +flutter.sdk=/Users/jonatasborges/flutter
1 // This is a generated file; do not edit or check into version control. 1 // This is a generated file; do not edit or check into version control.
2 -FLUTTER_ROOT=/home/sumit/softwares/flutter  
3 -FLUTTER_APPLICATION_PATH=/home/sumit/StudioProjects/getx/example_nav2 2 +FLUTTER_ROOT=/Users/jonatasborges/flutter
  3 +FLUTTER_APPLICATION_PATH=/Users/jonatasborges/getx5/getx/example_nav2
4 COCOAPODS_PARALLEL_CODE_SIGN=true 4 COCOAPODS_PARALLEL_CODE_SIGN=true
5 FLUTTER_TARGET=lib/main.dart 5 FLUTTER_TARGET=lib/main.dart
6 FLUTTER_BUILD_DIR=build 6 FLUTTER_BUILD_DIR=build
1 #!/bin/sh 1 #!/bin/sh
2 # This is a generated file; do not edit or check into version control. 2 # This is a generated file; do not edit or check into version control.
3 -export "FLUTTER_ROOT=/home/sumit/softwares/flutter"  
4 -export "FLUTTER_APPLICATION_PATH=/home/sumit/StudioProjects/getx/example_nav2" 3 +export "FLUTTER_ROOT=/Users/jonatasborges/flutter"
  4 +export "FLUTTER_APPLICATION_PATH=/Users/jonatasborges/getx5/getx/example_nav2"
5 export "COCOAPODS_PARALLEL_CODE_SIGN=true" 5 export "COCOAPODS_PARALLEL_CODE_SIGN=true"
6 export "FLUTTER_TARGET=lib/main.dart" 6 export "FLUTTER_TARGET=lib/main.dart"
7 export "FLUTTER_BUILD_DIR=build" 7 export "FLUTTER_BUILD_DIR=build"
1 import 'package:get/get.dart'; 1 import 'package:get/get.dart';
2 2
3 class RootController extends GetxController { 3 class RootController extends GetxController {
4 - //TODO: Implement RootController  
5 -  
6 final count = 0.obs; 4 final count = 0.obs;
7 @override 5 @override
8 void onInit() { 6 void onInit() {
1 import 'package:get/get.dart'; 1 import 'package:get/get.dart';
2 2
3 class SettingsController extends GetxController { 3 class SettingsController extends GetxController {
4 - //TODO: Implement SettingsController  
5 -  
6 final count = 0.obs; 4 final count = 0.obs;
7 @override 5 @override
8 void onInit() { 6 void onInit() {
@@ -182,7 +182,7 @@ @@ -182,7 +182,7 @@
182 isa = PBXProject; 182 isa = PBXProject;
183 attributes = { 183 attributes = {
184 LastSwiftUpdateCheck = 0920; 184 LastSwiftUpdateCheck = 0920;
185 - LastUpgradeCheck = 1300; 185 + LastUpgradeCheck = 1430;
186 ORGANIZATIONNAME = ""; 186 ORGANIZATIONNAME = "";
187 TargetAttributes = { 187 TargetAttributes = {
188 33CC10EC2044A3C60003C045 = { 188 33CC10EC2044A3C60003C045 = {
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <Scheme 2 <Scheme
3 - LastUpgradeVersion = "1300" 3 + LastUpgradeVersion = "1430"
4 version = "1.3"> 4 version = "1.3">
5 <BuildAction 5 <BuildAction
6 parallelizeBuildables = "YES" 6 parallelizeBuildables = "YES"
@@ -59,9 +59,10 @@ class RouterReportManager<T> { @@ -59,9 +59,10 @@ class RouterReportManager<T> {
59 59
60 void reportRouteDispose(T disposed) { 60 void reportRouteDispose(T disposed) {
61 if (Get.smartManagement != SmartManagement.onlyBuilder) { 61 if (Get.smartManagement != SmartManagement.onlyBuilder) {
62 - ambiguate(Engine.instance)!.addPostFrameCallback((_) {  
63 - _removeDependencyByRoute(disposed);  
64 - }); 62 + // ambiguate(Engine.instance)!.addPostFrameCallback((_) {
  63 + // Future.microtask(() {
  64 + _removeDependencyByRoute(disposed);
  65 + // });
65 } 66 }
66 } 67 }
67 68
@@ -20,7 +20,8 @@ class GetInformationParser extends RouteInformationParser<RouteDecoder> { @@ -20,7 +20,8 @@ class GetInformationParser extends RouteInformationParser<RouteDecoder> {
20 SynchronousFuture<RouteDecoder> parseRouteInformation( 20 SynchronousFuture<RouteDecoder> parseRouteInformation(
21 RouteInformation routeInformation, 21 RouteInformation routeInformation,
22 ) { 22 ) {
23 - var location = routeInformation.location; 23 + final uri = routeInformation.uri;
  24 + var location = uri.toString();
24 if (location == '/') { 25 if (location == '/') {
25 //check if there is a corresponding page 26 //check if there is a corresponding page
26 //if not, relocate to initialRoute 27 //if not, relocate to initialRoute
@@ -41,7 +42,7 @@ class GetInformationParser extends RouteInformationParser<RouteDecoder> { @@ -41,7 +42,7 @@ class GetInformationParser extends RouteInformationParser<RouteDecoder> {
41 @override 42 @override
42 RouteInformation restoreRouteInformation(RouteDecoder configuration) { 43 RouteInformation restoreRouteInformation(RouteDecoder configuration) {
43 return RouteInformation( 44 return RouteInformation(
44 - location: configuration.pageSettings?.name, 45 + uri: Uri.tryParse(configuration.pageSettings?.name ?? ''),
45 state: null, 46 state: null,
46 ); 47 );
47 } 48 }
@@ -177,8 +177,9 @@ class MiddlewareRunner { @@ -177,8 +177,9 @@ class MiddlewareRunner {
177 return page; 177 return page;
178 } 178 }
179 179
180 - void runOnPageDispose() =>  
181 - _getMiddlewares().forEach((element) => element.onPageDispose()); 180 + void runOnPageDispose() {
  181 + _getMiddlewares().forEach((element) => element.onPageDispose());
  182 + }
182 } 183 }
183 184
184 class PageRedirect { 185 class PageRedirect {
@@ -242,10 +242,10 @@ class SnackbarController { @@ -242,10 +242,10 @@ class SnackbarController {
242 onEnter: (_) => snackbar.onHover?.call(snackbar, SnackHoverState.entered), 242 onEnter: (_) => snackbar.onHover?.call(snackbar, SnackHoverState.entered),
243 onExit: (_) => snackbar.onHover?.call(snackbar, SnackHoverState.exited), 243 onExit: (_) => snackbar.onHover?.call(snackbar, SnackHoverState.exited),
244 child: GestureDetector( 244 child: GestureDetector(
245 - child: snackbar,  
246 onTap: snackbar.onTap != null 245 onTap: snackbar.onTap != null
247 ? () => snackbar.onTap?.call(snackbar) 246 ? () => snackbar.onTap?.call(snackbar)
248 : null, 247 : null,
  248 + child: snackbar,
249 ), 249 ),
250 ); 250 );
251 }); 251 });
@@ -122,6 +122,9 @@ mixin FullLifeCycleMixin on FullLifeCycleController { @@ -122,6 +122,9 @@ mixin FullLifeCycleMixin on FullLifeCycleController {
122 case AppLifecycleState.detached: 122 case AppLifecycleState.detached:
123 onDetached(); 123 onDetached();
124 break; 124 break;
  125 + case AppLifecycleState.hidden:
  126 + onHidden();
  127 + break;
125 } 128 }
126 } 129 }
127 130
@@ -129,4 +132,5 @@ mixin FullLifeCycleMixin on FullLifeCycleController { @@ -129,4 +132,5 @@ mixin FullLifeCycleMixin on FullLifeCycleController {
129 void onPaused() {} 132 void onPaused() {}
130 void onInactive() {} 133 void onInactive() {}
131 void onDetached() {} 134 void onDetached() {}
  135 + void onHidden() {}
132 } 136 }
@@ -4,7 +4,7 @@ version: 5.0.0-release-candidate-4 @@ -4,7 +4,7 @@ version: 5.0.0-release-candidate-4
4 homepage: https://github.com/jonataslaw/getx 4 homepage: https://github.com/jonataslaw/getx
5 5
6 environment: 6 environment:
7 - sdk: '>=2.17.0 <4.0.0' 7 + sdk: ">=2.17.0 <4.0.0"
8 8
9 dependencies: 9 dependencies:
10 flutter: 10 flutter:
@@ -16,7 +16,6 @@ dev_dependencies: @@ -16,7 +16,6 @@ dev_dependencies:
16 flutter_test: 16 flutter_test:
17 sdk: flutter 17 sdk: flutter
18 flutter_lints: ^2.0.2 18 flutter_lints: ^2.0.2
19 -  
20 19
21 # For information on the generic Dart part of this file, see the 20 # For information on the generic Dart part of this file, see the
22 # following page: https://dart.dev/tools/pub/pubspec 21 # following page: https://dart.dev/tools/pub/pubspec