Showing
81 changed files
with
705 additions
and
601 deletions
1 | +## [5.0.0-release-candidate] | ||
2 | +Refactor StateManager, RouteManager and InstanceManager from scratch | ||
3 | +Fixed Bugs | ||
4 | +Added a Scopped DI | ||
5 | +Api now uses Navigator 2 | ||
6 | +Added new RouteOutlet | ||
7 | +Added a new futurize method to StateMixin, that tracks updates, errors, and states programatically, | ||
8 | + | ||
1 | ## [4.6.1] | 9 | ## [4.6.1] |
2 | Fix GetConnect on Flutter web | 10 | Fix GetConnect on Flutter web |
3 | 11 |
@@ -22,6 +22,8 @@ linter: | @@ -22,6 +22,8 @@ linter: | ||
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file | 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file |
23 | # producing the lint. | 23 | # producing the lint. |
24 | rules: | 24 | rules: |
25 | + camel_case_types: false | ||
26 | + constant_identifier_names: false | ||
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule | 27 | # avoid_print: false # Uncomment to disable the `avoid_print` rule |
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule | 28 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule |
27 | 29 |
@@ -6,7 +6,7 @@ import 'pt_br.dart'; | @@ -6,7 +6,7 @@ import 'pt_br.dart'; | ||
6 | 6 | ||
7 | class TranslationService extends Translations { | 7 | class TranslationService extends Translations { |
8 | static Locale? get locale => Get.deviceLocale; | 8 | static Locale? get locale => Get.deviceLocale; |
9 | - static final fallbackLocale = Locale('en', 'US'); | 9 | + static const fallbackLocale = Locale('en', 'US'); |
10 | @override | 10 | @override |
11 | Map<String, Map<String, String>> get keys => { | 11 | Map<String, Map<String, String>> get keys => { |
12 | 'en_US': en_US, | 12 | 'en_US': en_US, |
@@ -6,7 +6,7 @@ import 'routes/app_pages.dart'; | @@ -6,7 +6,7 @@ import 'routes/app_pages.dart'; | ||
6 | import 'shared/logger/logger_utils.dart'; | 6 | import 'shared/logger/logger_utils.dart'; |
7 | 7 | ||
8 | void main() { | 8 | void main() { |
9 | - runApp(MyApp()); | 9 | + runApp(const MyApp()); |
10 | } | 10 | } |
11 | 11 | ||
12 | class MyApp extends StatelessWidget { | 12 | class MyApp extends StatelessWidget { |
@@ -10,7 +10,7 @@ class CountryView extends GetView<HomeController> { | @@ -10,7 +10,7 @@ class CountryView extends GetView<HomeController> { | ||
10 | @override | 10 | @override |
11 | Widget build(BuildContext context) { | 11 | Widget build(BuildContext context) { |
12 | return Container( | 12 | return Container( |
13 | - decoration: BoxDecoration( | 13 | + decoration: const BoxDecoration( |
14 | image: DecorationImage( | 14 | image: DecorationImage( |
15 | fit: BoxFit.cover, | 15 | fit: BoxFit.cover, |
16 | colorFilter: ColorFilter.linearToSrgbGamma(), | 16 | colorFilter: ColorFilter.linearToSrgbGamma(), |
@@ -18,38 +18,36 @@ class CountryView extends GetView<HomeController> { | @@ -18,38 +18,36 @@ class CountryView extends GetView<HomeController> { | ||
18 | "https://images.pexels.com/photos/3902882/pexels-photo-3902882.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"))), | 18 | "https://images.pexels.com/photos/3902882/pexels-photo-3902882.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"))), |
19 | child: BackdropFilter( | 19 | child: BackdropFilter( |
20 | filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0), | 20 | filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0), |
21 | - child: Container( | ||
22 | - child: Scaffold( | 21 | + child: Scaffold( |
22 | + backgroundColor: Colors.transparent, | ||
23 | + appBar: AppBar( | ||
24 | + title: Text('corona_by_country'.tr), | ||
23 | backgroundColor: Colors.transparent, | 25 | backgroundColor: Colors.transparent, |
24 | - appBar: AppBar( | ||
25 | - title: Text('corona_by_country'.tr), | ||
26 | - backgroundColor: Colors.transparent, | ||
27 | - elevation: 0, | ||
28 | - centerTitle: true, | ||
29 | - ), | ||
30 | - body: Center( | ||
31 | - child: ListView.builder( | ||
32 | - itemCount: controller.state.countries.length, | ||
33 | - itemBuilder: (context, index) { | ||
34 | - final country = controller.state.countries[index]; | ||
35 | - return ListTile( | ||
36 | - onTap: () async { | ||
37 | - //Get.rootDelegate.toNamed('/home/country'); | ||
38 | - final data = await Get.toNamed( | ||
39 | - '/home/country/details?id=$index'); | ||
40 | - print(data); | ||
41 | - }, | ||
42 | - trailing: CircleAvatar( | ||
43 | - backgroundImage: NetworkImage( | ||
44 | - "https://flagpedia.net/data/flags/normal/${country.countryCode.toLowerCase()}.png"), | ||
45 | - ), | ||
46 | - title: Text(country.country), | ||
47 | - subtitle: Text( | ||
48 | - // ignore: lines_longer_than_80_chars | ||
49 | - '${'total_infecteds'.tr}${' ${country.totalConfirmed}'}'), | ||
50 | - ); | ||
51 | - }), | ||
52 | - ), | 26 | + elevation: 0, |
27 | + centerTitle: true, | ||
28 | + ), | ||
29 | + body: Center( | ||
30 | + child: ListView.builder( | ||
31 | + itemCount: controller.state.countries.length, | ||
32 | + itemBuilder: (context, index) { | ||
33 | + final country = controller.state.countries[index]; | ||
34 | + return ListTile( | ||
35 | + onTap: () async { | ||
36 | + //Get.rootDelegate.toNamed('/home/country'); | ||
37 | + final data = | ||
38 | + await Get.toNamed('/home/country/details?id=$index'); | ||
39 | + Get.log(data); | ||
40 | + }, | ||
41 | + trailing: CircleAvatar( | ||
42 | + backgroundImage: NetworkImage( | ||
43 | + "https://flagpedia.net/data/flags/normal/${country.countryCode.toLowerCase()}.png"), | ||
44 | + ), | ||
45 | + title: Text(country.country), | ||
46 | + subtitle: Text( | ||
47 | + // ignore: lines_longer_than_80_chars | ||
48 | + '${'total_infecteds'.tr}${' ${country.totalConfirmed}'}'), | ||
49 | + ); | ||
50 | + }), | ||
53 | ), | 51 | ), |
54 | ), | 52 | ), |
55 | ), | 53 | ), |
@@ -15,77 +15,79 @@ class DetailsView extends GetView<HomeController> { | @@ -15,77 +15,79 @@ class DetailsView extends GetView<HomeController> { | ||
15 | decoration: BoxDecoration( | 15 | decoration: BoxDecoration( |
16 | image: DecorationImage( | 16 | image: DecorationImage( |
17 | fit: BoxFit.cover, | 17 | fit: BoxFit.cover, |
18 | - colorFilter: ColorFilter.linearToSrgbGamma(), | 18 | + colorFilter: const ColorFilter.linearToSrgbGamma(), |
19 | image: NetworkImage( | 19 | image: NetworkImage( |
20 | "https://flagpedia.net/data/flags/normal/${country.countryCode.toLowerCase()}.png"), | 20 | "https://flagpedia.net/data/flags/normal/${country.countryCode.toLowerCase()}.png"), |
21 | ), | 21 | ), |
22 | ), | 22 | ), |
23 | child: BackdropFilter( | 23 | child: BackdropFilter( |
24 | filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0), | 24 | filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0), |
25 | - child: Container( | ||
26 | - child: Scaffold( | ||
27 | - backgroundColor: Colors.transparent, | ||
28 | - appBar: AppBar( | ||
29 | - title: Text('details'.tr), | ||
30 | - backgroundColor: Colors.black12, | ||
31 | - elevation: 0, | ||
32 | - centerTitle: true, | ||
33 | - ), | ||
34 | - body: Center( | ||
35 | - child: Column( | ||
36 | - mainAxisAlignment: MainAxisAlignment.center, | ||
37 | - children: [ | ||
38 | - Text( | ||
39 | - '${country.country}', | ||
40 | - style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold), | ||
41 | - ), | ||
42 | - SizedBox( | ||
43 | - height: 35, | ||
44 | - ), | ||
45 | - Text( | ||
46 | - 'total_confirmed'.tr, | ||
47 | - style: TextStyle( | ||
48 | - fontSize: 25, | ||
49 | - ), | ||
50 | - ), | ||
51 | - Text( | ||
52 | - '${country.totalConfirmed}', | ||
53 | - style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold), | ||
54 | - ), | ||
55 | - SizedBox( | ||
56 | - height: 10, | ||
57 | - ), | ||
58 | - Text( | ||
59 | - 'total_deaths'.tr, | ||
60 | - style: TextStyle( | ||
61 | - fontSize: 25, | ||
62 | - ), | ||
63 | - ), | ||
64 | - Text( | ||
65 | - '${country.totalDeaths}', | ||
66 | - style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold), | ||
67 | - ), | ||
68 | - SizedBox( | ||
69 | - height: 10, | 25 | + child: Scaffold( |
26 | + backgroundColor: Colors.transparent, | ||
27 | + appBar: AppBar( | ||
28 | + title: Text('details'.tr), | ||
29 | + backgroundColor: Colors.black12, | ||
30 | + elevation: 0, | ||
31 | + centerTitle: true, | ||
32 | + ), | ||
33 | + body: Center( | ||
34 | + child: Column( | ||
35 | + mainAxisAlignment: MainAxisAlignment.center, | ||
36 | + children: [ | ||
37 | + Text( | ||
38 | + country.country, | ||
39 | + style: | ||
40 | + const TextStyle(fontSize: 45, fontWeight: FontWeight.bold), | ||
41 | + ), | ||
42 | + const SizedBox( | ||
43 | + height: 35, | ||
44 | + ), | ||
45 | + Text( | ||
46 | + 'total_confirmed'.tr, | ||
47 | + style: const TextStyle( | ||
48 | + fontSize: 25, | ||
70 | ), | 49 | ), |
71 | - Text( | ||
72 | - 'total_recovered'.tr, | ||
73 | - style: TextStyle( | ||
74 | - fontSize: 25, | ||
75 | - ), | 50 | + ), |
51 | + Text( | ||
52 | + '${country.totalConfirmed}', | ||
53 | + style: | ||
54 | + const TextStyle(fontSize: 35, fontWeight: FontWeight.bold), | ||
55 | + ), | ||
56 | + const SizedBox( | ||
57 | + height: 10, | ||
58 | + ), | ||
59 | + Text( | ||
60 | + 'total_deaths'.tr, | ||
61 | + style: const TextStyle( | ||
62 | + fontSize: 25, | ||
76 | ), | 63 | ), |
77 | - Text( | ||
78 | - '${country.totalRecovered}', | ||
79 | - style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold), | 64 | + ), |
65 | + Text( | ||
66 | + '${country.totalDeaths}', | ||
67 | + style: | ||
68 | + const TextStyle(fontSize: 35, fontWeight: FontWeight.bold), | ||
69 | + ), | ||
70 | + const SizedBox( | ||
71 | + height: 10, | ||
72 | + ), | ||
73 | + Text( | ||
74 | + 'total_recovered'.tr, | ||
75 | + style: const TextStyle( | ||
76 | + fontSize: 25, | ||
80 | ), | 77 | ), |
81 | - TextButton( | ||
82 | - onPressed: () { | ||
83 | - Get.back(result: 'djsoidjsoidj'); | ||
84 | - }, | ||
85 | - child: Text('back')) | ||
86 | - ], | ||
87 | - )), | ||
88 | - ), | 78 | + ), |
79 | + Text( | ||
80 | + '${country.totalRecovered}', | ||
81 | + style: | ||
82 | + const TextStyle(fontSize: 35, fontWeight: FontWeight.bold), | ||
83 | + ), | ||
84 | + TextButton( | ||
85 | + onPressed: () { | ||
86 | + Get.back(result: 'djsoidjsoidj'); | ||
87 | + }, | ||
88 | + child: const Text('back')) | ||
89 | + ], | ||
90 | + )), | ||
89 | ), | 91 | ), |
90 | ), | 92 | ), |
91 | ); | 93 | ); |
@@ -9,7 +9,7 @@ class HomeView extends GetView<HomeController> { | @@ -9,7 +9,7 @@ class HomeView extends GetView<HomeController> { | ||
9 | @override | 9 | @override |
10 | Widget build(BuildContext context) { | 10 | Widget build(BuildContext context) { |
11 | return Container( | 11 | return Container( |
12 | - decoration: BoxDecoration( | 12 | + decoration: const BoxDecoration( |
13 | color: Colors.white, | 13 | color: Colors.white, |
14 | image: DecorationImage( | 14 | image: DecorationImage( |
15 | fit: BoxFit.cover, | 15 | fit: BoxFit.cover, |
@@ -22,7 +22,7 @@ class HomeView extends GetView<HomeController> { | @@ -22,7 +22,7 @@ class HomeView extends GetView<HomeController> { | ||
22 | backgroundColor: Colors.transparent, | 22 | backgroundColor: Colors.transparent, |
23 | appBar: AppBar( | 23 | appBar: AppBar( |
24 | leading: IconButton( | 24 | leading: IconButton( |
25 | - icon: Icon(Icons.add), | 25 | + icon: const Icon(Icons.add), |
26 | onPressed: () { | 26 | onPressed: () { |
27 | Get.snackbar('title', 'message'); | 27 | Get.snackbar('title', 'message'); |
28 | }, | 28 | }, |
@@ -38,43 +38,45 @@ class HomeView extends GetView<HomeController> { | @@ -38,43 +38,45 @@ class HomeView extends GetView<HomeController> { | ||
38 | return Column( | 38 | return Column( |
39 | mainAxisAlignment: MainAxisAlignment.center, | 39 | mainAxisAlignment: MainAxisAlignment.center, |
40 | children: [ | 40 | children: [ |
41 | - SizedBox( | 41 | + const SizedBox( |
42 | height: 100, | 42 | height: 100, |
43 | ), | 43 | ), |
44 | Text( | 44 | Text( |
45 | 'total_confirmed'.tr, | 45 | 'total_confirmed'.tr, |
46 | - style: TextStyle( | 46 | + style: const TextStyle( |
47 | fontSize: 30, | 47 | fontSize: 30, |
48 | ), | 48 | ), |
49 | ), | 49 | ), |
50 | Text( | 50 | Text( |
51 | '${state!.global.totalConfirmed}', | 51 | '${state!.global.totalConfirmed}', |
52 | - style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold), | 52 | + style: const TextStyle( |
53 | + fontSize: 45, fontWeight: FontWeight.bold), | ||
53 | ), | 54 | ), |
54 | - SizedBox( | 55 | + const SizedBox( |
55 | height: 10, | 56 | height: 10, |
56 | ), | 57 | ), |
57 | Text( | 58 | Text( |
58 | 'total_deaths'.tr, | 59 | 'total_deaths'.tr, |
59 | - style: TextStyle( | 60 | + style: const TextStyle( |
60 | fontSize: 30, | 61 | fontSize: 30, |
61 | ), | 62 | ), |
62 | ), | 63 | ), |
63 | Text( | 64 | Text( |
64 | '${state.global.totalDeaths}', | 65 | '${state.global.totalDeaths}', |
65 | - style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold), | 66 | + style: const TextStyle( |
67 | + fontSize: 45, fontWeight: FontWeight.bold), | ||
66 | ), | 68 | ), |
67 | - SizedBox( | 69 | + const SizedBox( |
68 | height: 10, | 70 | height: 10, |
69 | ), | 71 | ), |
70 | OutlinedButton( | 72 | OutlinedButton( |
71 | style: OutlinedButton.styleFrom( | 73 | style: OutlinedButton.styleFrom( |
72 | - textStyle: TextStyle(color: Colors.black), | ||
73 | - side: BorderSide( | 74 | + textStyle: const TextStyle(color: Colors.black), |
75 | + side: const BorderSide( | ||
74 | color: Colors.deepPurple, | 76 | color: Colors.deepPurple, |
75 | width: 3, | 77 | width: 3, |
76 | ), | 78 | ), |
77 | - shape: StadiumBorder(), | 79 | + shape: const StadiumBorder(), |
78 | ), | 80 | ), |
79 | onPressed: () async { | 81 | onPressed: () async { |
80 | //await Navigation Get.rootDelegate.toNamed('/home/country'); | 82 | //await Navigation Get.rootDelegate.toNamed('/home/country'); |
@@ -82,7 +84,7 @@ class HomeView extends GetView<HomeController> { | @@ -82,7 +84,7 @@ class HomeView extends GetView<HomeController> { | ||
82 | }, | 84 | }, |
83 | child: Text( | 85 | child: Text( |
84 | 'fetch_country'.tr, | 86 | 'fetch_country'.tr, |
85 | - style: TextStyle( | 87 | + style: const TextStyle( |
86 | fontWeight: FontWeight.bold, | 88 | fontWeight: FontWeight.bold, |
87 | color: Colors.black, | 89 | color: Colors.black, |
88 | ), | 90 | ), |
@@ -90,17 +92,17 @@ class HomeView extends GetView<HomeController> { | @@ -90,17 +92,17 @@ class HomeView extends GetView<HomeController> { | ||
90 | ), | 92 | ), |
91 | OutlinedButton( | 93 | OutlinedButton( |
92 | style: OutlinedButton.styleFrom( | 94 | style: OutlinedButton.styleFrom( |
93 | - textStyle: TextStyle(color: Colors.black), | ||
94 | - side: BorderSide( | 95 | + textStyle: const TextStyle(color: Colors.black), |
96 | + side: const BorderSide( | ||
95 | color: Colors.deepPurple, | 97 | color: Colors.deepPurple, |
96 | width: 3, | 98 | width: 3, |
97 | ), | 99 | ), |
98 | - shape: StadiumBorder(), | 100 | + shape: const StadiumBorder(), |
99 | ), | 101 | ), |
100 | onPressed: () { | 102 | onPressed: () { |
101 | - Get.updateLocale(Locale('pt', 'BR')); | 103 | + Get.updateLocale(const Locale('pt', 'BR')); |
102 | }, | 104 | }, |
103 | - child: Text( | 105 | + child: const Text( |
104 | 'Update language to Portuguese', | 106 | 'Update language to Portuguese', |
105 | style: TextStyle( | 107 | style: TextStyle( |
106 | fontWeight: FontWeight.bold, | 108 | fontWeight: FontWeight.bold, |
@@ -14,16 +14,16 @@ class AppPages { | @@ -14,16 +14,16 @@ class AppPages { | ||
14 | static final routes = [ | 14 | static final routes = [ |
15 | GetPage( | 15 | GetPage( |
16 | name: Routes.HOME, | 16 | name: Routes.HOME, |
17 | - page: () => HomeView(), | 17 | + page: () => const HomeView(), |
18 | binding: HomeBinding(), | 18 | binding: HomeBinding(), |
19 | children: [ | 19 | children: [ |
20 | GetPage( | 20 | GetPage( |
21 | name: Routes.COUNTRY, | 21 | name: Routes.COUNTRY, |
22 | - page: () => CountryView(), | 22 | + page: () => const CountryView(), |
23 | children: [ | 23 | children: [ |
24 | GetPage( | 24 | GetPage( |
25 | name: Routes.DETAILS, | 25 | name: Routes.DETAILS, |
26 | - page: () => DetailsView(), | 26 | + page: () => const DetailsView(), |
27 | ), | 27 | ), |
28 | ], | 28 | ], |
29 | ), | 29 | ), |
1 | mixin Logger { | 1 | mixin Logger { |
2 | // Sample of abstract logging function | 2 | // Sample of abstract logging function |
3 | static void write(String text, {bool isError = false}) { | 3 | static void write(String text, {bool isError = false}) { |
4 | + // ignore: avoid_print | ||
4 | Future.microtask(() => print('** $text. isError: [$isError]')); | 5 | Future.microtask(() => print('** $text. isError: [$isError]')); |
5 | } | 6 | } |
6 | } | 7 | } |
@@ -3,13 +3,11 @@ import 'dart:io'; | @@ -3,13 +3,11 @@ import 'dart:io'; | ||
3 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
4 | import 'package:flutter_test/flutter_test.dart'; | 4 | import 'package:flutter_test/flutter_test.dart'; |
5 | import 'package:get/get.dart'; | 5 | import 'package:get/get.dart'; |
6 | +import 'package:get_demo/pages/home/domain/adapters/repository_adapter.dart'; | ||
7 | +import 'package:get_demo/pages/home/domain/entity/cases_model.dart'; | ||
8 | +import 'package:get_demo/pages/home/presentation/controllers/home_controller.dart'; | ||
6 | // import 'package:get_demo/routes/app_pages.dart'; | 9 | // import 'package:get_demo/routes/app_pages.dart'; |
7 | // import 'package:get_test/get_test.dart'; | 10 | // import 'package:get_test/get_test.dart'; |
8 | -import 'package:matcher/matcher.dart' as m; | ||
9 | - | ||
10 | -import '../lib/pages/home/domain/adapters/repository_adapter.dart'; | ||
11 | -import '../lib/pages/home/domain/entity/cases_model.dart'; | ||
12 | -import '../lib/pages/home/presentation/controllers/home_controller.dart'; | ||
13 | 11 | ||
14 | class MockRepositorySuccess implements IHomeRepository { | 12 | class MockRepositorySuccess implements IHomeRepository { |
15 | @override | 13 | @override |
@@ -57,7 +55,7 @@ void main() { | @@ -57,7 +55,7 @@ void main() { | ||
57 | test('Test Controller', () async { | 55 | test('Test Controller', () async { |
58 | /// Controller can't be on memory | 56 | /// Controller can't be on memory |
59 | expect(() => Get.find<HomeController>(tag: 'success'), | 57 | expect(() => Get.find<HomeController>(tag: 'success'), |
60 | - throwsA(m.TypeMatcher<String>())); | 58 | + throwsA(const TypeMatcher<String>())); |
61 | 59 | ||
62 | /// binding will put the controller on memory | 60 | /// binding will put the controller on memory |
63 | binding.dependencies(); | 61 | binding.dependencies(); |
@@ -72,7 +70,7 @@ void main() { | @@ -72,7 +70,7 @@ void main() { | ||
72 | expect(controller.status.isLoading, true); | 70 | expect(controller.status.isLoading, true); |
73 | 71 | ||
74 | /// await time request | 72 | /// await time request |
75 | - await Future.delayed(Duration(milliseconds: 100)); | 73 | + await Future.delayed(const Duration(milliseconds: 100)); |
76 | 74 | ||
77 | /// test if status is success | 75 | /// test if status is success |
78 | expect(controller.status.isSuccess, true); | 76 | expect(controller.status.isSuccess, true); |
@@ -8,7 +8,7 @@ class DashboardController extends GetxController { | @@ -8,7 +8,7 @@ class DashboardController extends GetxController { | ||
8 | void onReady() { | 8 | void onReady() { |
9 | super.onReady(); | 9 | super.onReady(); |
10 | Timer.periodic( | 10 | Timer.periodic( |
11 | - Duration(seconds: 1), | 11 | + const Duration(seconds: 1), |
12 | (timer) { | 12 | (timer) { |
13 | now.value = DateTime.now(); | 13 | now.value = DateTime.now(); |
14 | }, | 14 | }, |
@@ -4,6 +4,8 @@ import 'package:get/get.dart'; | @@ -4,6 +4,8 @@ import 'package:get/get.dart'; | ||
4 | import '../controllers/dashboard_controller.dart'; | 4 | import '../controllers/dashboard_controller.dart'; |
5 | 5 | ||
6 | class DashboardView extends GetView<DashboardController> { | 6 | class DashboardView extends GetView<DashboardController> { |
7 | + const DashboardView({super.key}); | ||
8 | + | ||
7 | @override | 9 | @override |
8 | Widget build(BuildContext context) { | 10 | Widget build(BuildContext context) { |
9 | return Scaffold( | 11 | return Scaffold( |
@@ -12,7 +14,7 @@ class DashboardView extends GetView<DashboardController> { | @@ -12,7 +14,7 @@ class DashboardView extends GetView<DashboardController> { | ||
12 | () => Column( | 14 | () => Column( |
13 | mainAxisSize: MainAxisSize.min, | 15 | mainAxisSize: MainAxisSize.min, |
14 | children: [ | 16 | children: [ |
15 | - Text( | 17 | + const Text( |
16 | 'DashboardView is working', | 18 | 'DashboardView is working', |
17 | style: TextStyle(fontSize: 20), | 19 | style: TextStyle(fontSize: 20), |
18 | ), | 20 | ), |
@@ -14,7 +14,6 @@ class HomeView extends GetView<HomeController> { | @@ -14,7 +14,6 @@ class HomeView extends GetView<HomeController> { | ||
14 | final delegate = context.navigation; | 14 | final delegate = context.navigation; |
15 | //This router outlet handles the appbar and the bottom navigation bar | 15 | //This router outlet handles the appbar and the bottom navigation bar |
16 | final currentLocation = context.location; | 16 | final currentLocation = context.location; |
17 | - print(currentLocation); | ||
18 | var currentIndex = 0; | 17 | var currentIndex = 0; |
19 | if (currentLocation.startsWith(Routes.products) == true) { | 18 | if (currentLocation.startsWith(Routes.products) == true) { |
20 | currentIndex = 2; | 19 | currentIndex = 2; |
@@ -46,7 +45,7 @@ class HomeView extends GetView<HomeController> { | @@ -46,7 +45,7 @@ class HomeView extends GetView<HomeController> { | ||
46 | default: | 45 | default: |
47 | } | 46 | } |
48 | }, | 47 | }, |
49 | - items: [ | 48 | + items: const [ |
50 | // _Paths.HOME + [Empty] | 49 | // _Paths.HOME + [Empty] |
51 | BottomNavigationBarItem( | 50 | BottomNavigationBarItem( |
52 | icon: Icon(Icons.home), | 51 | icon: Icon(Icons.home), |
@@ -6,6 +6,8 @@ import '../../../routes/app_pages.dart'; | @@ -6,6 +6,8 @@ import '../../../routes/app_pages.dart'; | ||
6 | import '../controllers/login_controller.dart'; | 6 | import '../controllers/login_controller.dart'; |
7 | 7 | ||
8 | class LoginView extends GetView<LoginController> { | 8 | class LoginView extends GetView<LoginController> { |
9 | + const LoginView({super.key}); | ||
10 | + | ||
9 | @override | 11 | @override |
10 | Widget build(BuildContext context) { | 12 | Widget build(BuildContext context) { |
11 | return Scaffold( | 13 | return Scaffold( |
@@ -25,7 +27,7 @@ class LoginView extends GetView<LoginController> { | @@ -25,7 +27,7 @@ class LoginView extends GetView<LoginController> { | ||
25 | }, | 27 | }, |
26 | ), | 28 | ), |
27 | MaterialButton( | 29 | MaterialButton( |
28 | - child: Text( | 30 | + child: const Text( |
29 | 'Do LOGIN !!', | 31 | 'Do LOGIN !!', |
30 | style: TextStyle(color: Colors.blue, fontSize: 20), | 32 | style: TextStyle(color: Colors.blue, fontSize: 20), |
31 | ), | 33 | ), |
1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
2 | - | ||
3 | import 'package:get/get.dart'; | 2 | import 'package:get/get.dart'; |
4 | 3 | ||
5 | import '../controllers/product_details_controller.dart'; | 4 | import '../controllers/product_details_controller.dart'; |
6 | 5 | ||
7 | class ProductDetailsView extends GetWidget<ProductDetailsController> { | 6 | class ProductDetailsView extends GetWidget<ProductDetailsController> { |
7 | + const ProductDetailsView({super.key}); | ||
8 | + | ||
8 | @override | 9 | @override |
9 | Widget build(BuildContext context) { | 10 | Widget build(BuildContext context) { |
10 | return Scaffold( | 11 | return Scaffold( |
@@ -12,7 +13,7 @@ class ProductDetailsView extends GetWidget<ProductDetailsController> { | @@ -12,7 +13,7 @@ class ProductDetailsView extends GetWidget<ProductDetailsController> { | ||
12 | child: Column( | 13 | child: Column( |
13 | mainAxisSize: MainAxisSize.min, | 14 | mainAxisSize: MainAxisSize.min, |
14 | children: [ | 15 | children: [ |
15 | - Text( | 16 | + const Text( |
16 | 'ProductDetailsView is working', | 17 | 'ProductDetailsView is working', |
17 | style: TextStyle(fontSize: 20), | 18 | style: TextStyle(fontSize: 20), |
18 | ), | 19 | ), |
@@ -11,13 +11,13 @@ class ProductsView extends GetView<ProductsController> { | @@ -11,13 +11,13 @@ class ProductsView extends GetView<ProductsController> { | ||
11 | return Scaffold( | 11 | return Scaffold( |
12 | floatingActionButton: FloatingActionButton.extended( | 12 | floatingActionButton: FloatingActionButton.extended( |
13 | onPressed: () => controller.loadDemoProductsFromSomeWhere(), | 13 | onPressed: () => controller.loadDemoProductsFromSomeWhere(), |
14 | - label: Text('Add'), | 14 | + label: const Text('Add'), |
15 | ), | 15 | ), |
16 | body: Column( | 16 | body: Column( |
17 | children: [ | 17 | children: [ |
18 | - Hero( | 18 | + const Hero( |
19 | tag: 'heroLogo', | 19 | tag: 'heroLogo', |
20 | - child: const FlutterLogo(), | 20 | + child: FlutterLogo(), |
21 | ), | 21 | ), |
22 | Expanded( | 22 | Expanded( |
23 | child: Obx( | 23 | child: Obx( |
@@ -5,6 +5,8 @@ import '../../../routes/app_pages.dart'; | @@ -5,6 +5,8 @@ import '../../../routes/app_pages.dart'; | ||
5 | import '../controllers/profile_controller.dart'; | 5 | import '../controllers/profile_controller.dart'; |
6 | 6 | ||
7 | class ProfileView extends GetView<ProfileController> { | 7 | class ProfileView extends GetView<ProfileController> { |
8 | + const ProfileView({super.key}); | ||
9 | + | ||
8 | @override | 10 | @override |
9 | Widget build(BuildContext context) { | 11 | Widget build(BuildContext context) { |
10 | return Scaffold( | 12 | return Scaffold( |
@@ -13,16 +15,16 @@ class ProfileView extends GetView<ProfileController> { | @@ -13,16 +15,16 @@ class ProfileView extends GetView<ProfileController> { | ||
13 | child: Column( | 15 | child: Column( |
14 | mainAxisSize: MainAxisSize.min, | 16 | mainAxisSize: MainAxisSize.min, |
15 | children: [ | 17 | children: [ |
16 | - Text( | 18 | + const Text( |
17 | 'ProfileView is working', | 19 | 'ProfileView is working', |
18 | style: TextStyle(fontSize: 20), | 20 | style: TextStyle(fontSize: 20), |
19 | ), | 21 | ), |
20 | - Hero( | 22 | + const Hero( |
21 | tag: 'heroLogo', | 23 | tag: 'heroLogo', |
22 | - child: const FlutterLogo(), | 24 | + child: FlutterLogo(), |
23 | ), | 25 | ), |
24 | MaterialButton( | 26 | MaterialButton( |
25 | - child: Text('Show a test dialog'), | 27 | + child: const Text('Show a test dialog'), |
26 | onPressed: () { | 28 | onPressed: () { |
27 | //shows a dialog | 29 | //shows a dialog |
28 | Get.defaultDialog( | 30 | Get.defaultDialog( |
@@ -32,7 +34,7 @@ class ProfileView extends GetView<ProfileController> { | @@ -32,7 +34,7 @@ class ProfileView extends GetView<ProfileController> { | ||
32 | }, | 34 | }, |
33 | ), | 35 | ), |
34 | MaterialButton( | 36 | MaterialButton( |
35 | - child: Text('Show a test dialog in Home router outlet'), | 37 | + child: const Text('Show a test dialog in Home router outlet'), |
36 | onPressed: () { | 38 | onPressed: () { |
37 | //shows a dialog | 39 | //shows a dialog |
38 | 40 |
@@ -19,7 +19,7 @@ class DrawerWidget extends StatelessWidget { | @@ -19,7 +19,7 @@ class DrawerWidget extends StatelessWidget { | ||
19 | color: Colors.red, | 19 | color: Colors.red, |
20 | ), | 20 | ), |
21 | ListTile( | 21 | ListTile( |
22 | - title: Text('Home'), | 22 | + title: const Text('Home'), |
23 | onTap: () { | 23 | onTap: () { |
24 | Get.toNamed(Routes.home); | 24 | Get.toNamed(Routes.home); |
25 | //to close the drawer | 25 | //to close the drawer |
@@ -28,7 +28,7 @@ class DrawerWidget extends StatelessWidget { | @@ -28,7 +28,7 @@ class DrawerWidget extends StatelessWidget { | ||
28 | }, | 28 | }, |
29 | ), | 29 | ), |
30 | ListTile( | 30 | ListTile( |
31 | - title: Text('Settings'), | 31 | + title: const Text('Settings'), |
32 | onTap: () { | 32 | onTap: () { |
33 | Get.toNamed(Routes.settings); | 33 | Get.toNamed(Routes.settings); |
34 | //to close the drawer | 34 | //to close the drawer |
@@ -38,7 +38,7 @@ class DrawerWidget extends StatelessWidget { | @@ -38,7 +38,7 @@ class DrawerWidget extends StatelessWidget { | ||
38 | ), | 38 | ), |
39 | if (AuthService.to.isLoggedInValue) | 39 | if (AuthService.to.isLoggedInValue) |
40 | ListTile( | 40 | ListTile( |
41 | - title: Text( | 41 | + title: const Text( |
42 | 'Logout', | 42 | 'Logout', |
43 | style: TextStyle( | 43 | style: TextStyle( |
44 | color: Colors.red, | 44 | color: Colors.red, |
@@ -54,7 +54,7 @@ class DrawerWidget extends StatelessWidget { | @@ -54,7 +54,7 @@ class DrawerWidget extends StatelessWidget { | ||
54 | ), | 54 | ), |
55 | if (!AuthService.to.isLoggedInValue) | 55 | if (!AuthService.to.isLoggedInValue) |
56 | ListTile( | 56 | ListTile( |
57 | - title: Text( | 57 | + title: const Text( |
58 | 'Login', | 58 | 'Login', |
59 | style: TextStyle( | 59 | style: TextStyle( |
60 | color: Colors.blue, | 60 | color: Colors.blue, |
@@ -6,6 +6,8 @@ import '../controllers/root_controller.dart'; | @@ -6,6 +6,8 @@ import '../controllers/root_controller.dart'; | ||
6 | import 'drawer.dart'; | 6 | import 'drawer.dart'; |
7 | 7 | ||
8 | class RootView extends GetView<RootController> { | 8 | class RootView extends GetView<RootController> { |
9 | + const RootView({super.key}); | ||
10 | + | ||
9 | @override | 11 | @override |
10 | Widget build(BuildContext context) { | 12 | Widget build(BuildContext context) { |
11 | return RouterOutlet.builder( | 13 | return RouterOutlet.builder( |
@@ -13,7 +15,7 @@ class RootView extends GetView<RootController> { | @@ -13,7 +15,7 @@ class RootView extends GetView<RootController> { | ||
13 | builder: (context) { | 15 | builder: (context) { |
14 | final title = context.location; | 16 | final title = context.location; |
15 | return Scaffold( | 17 | return Scaffold( |
16 | - drawer: DrawerWidget(), | 18 | + drawer: const DrawerWidget(), |
17 | appBar: AppBar( | 19 | appBar: AppBar( |
18 | title: Text(title), | 20 | title: Text(title), |
19 | centerTitle: true, | 21 | centerTitle: true, |
1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
2 | - | ||
3 | import 'package:get/get.dart'; | 2 | import 'package:get/get.dart'; |
4 | 3 | ||
5 | import '../controllers/settings_controller.dart'; | 4 | import '../controllers/settings_controller.dart'; |
6 | 5 | ||
7 | class SettingsView extends GetView<SettingsController> { | 6 | class SettingsView extends GetView<SettingsController> { |
7 | + const SettingsView({super.key}); | ||
8 | + | ||
8 | @override | 9 | @override |
9 | Widget build(BuildContext context) { | 10 | Widget build(BuildContext context) { |
10 | - return Scaffold( | 11 | + return const Scaffold( |
11 | body: Center( | 12 | body: Center( |
12 | child: Text( | 13 | child: Text( |
13 | 'SettingsView is working', | 14 | 'SettingsView is working', |
@@ -18,11 +18,11 @@ class SplashService extends GetxService { | @@ -18,11 +18,11 @@ class SplashService extends GetxService { | ||
18 | 18 | ||
19 | Future<void> _initFunction() async { | 19 | Future<void> _initFunction() async { |
20 | final t = Timer.periodic( | 20 | final t = Timer.periodic( |
21 | - Duration(milliseconds: 500), | 21 | + const Duration(milliseconds: 500), |
22 | (t) => _changeActiveString(), | 22 | (t) => _changeActiveString(), |
23 | ); | 23 | ); |
24 | //simulate some long running operation | 24 | //simulate some long running operation |
25 | - await Future.delayed(Duration(seconds: 5)); | 25 | + await Future.delayed(const Duration(seconds: 5)); |
26 | //cancel the timer once we are done | 26 | //cancel the timer once we are done |
27 | t.cancel(); | 27 | t.cancel(); |
28 | } | 28 | } |
1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
2 | - | ||
3 | import 'package:get/get.dart'; | 2 | import 'package:get/get.dart'; |
4 | 3 | ||
5 | import '../controllers/splash_service.dart'; | 4 | import '../controllers/splash_service.dart'; |
6 | 5 | ||
7 | class SplashView extends GetView<SplashService> { | 6 | class SplashView extends GetView<SplashService> { |
7 | + const SplashView({super.key}); | ||
8 | + | ||
8 | @override | 9 | @override |
9 | Widget build(BuildContext context) { | 10 | Widget build(BuildContext context) { |
10 | return Scaffold( | 11 | return Scaffold( |
@@ -15,10 +16,10 @@ class SplashView extends GetView<SplashService> { | @@ -15,10 +16,10 @@ class SplashView extends GetView<SplashService> { | ||
15 | Obx( | 16 | Obx( |
16 | () => Text( | 17 | () => Text( |
17 | controller.welcomeStr[controller.activeStr.value], | 18 | controller.welcomeStr[controller.activeStr.value], |
18 | - style: TextStyle(fontSize: 20), | 19 | + style: const TextStyle(fontSize: 20), |
19 | ), | 20 | ), |
20 | ), | 21 | ), |
21 | - CircularProgressIndicator(), | 22 | + const CircularProgressIndicator(), |
22 | ], | 23 | ], |
23 | ), | 24 | ), |
24 | ), | 25 | ), |
@@ -28,7 +28,7 @@ class AppPages { | @@ -28,7 +28,7 @@ class AppPages { | ||
28 | static final routes = [ | 28 | static final routes = [ |
29 | GetPage( | 29 | GetPage( |
30 | name: '/', | 30 | name: '/', |
31 | - page: () => RootView(), | 31 | + page: () => const RootView(), |
32 | bindings: [RootBinding()], | 32 | bindings: [RootBinding()], |
33 | participatesInRootNavigator: true, | 33 | participatesInRootNavigator: true, |
34 | preventDuplicates: true, | 34 | preventDuplicates: true, |
@@ -39,7 +39,7 @@ class AppPages { | @@ -39,7 +39,7 @@ class AppPages { | ||
39 | EnsureNotAuthedMiddleware(), | 39 | EnsureNotAuthedMiddleware(), |
40 | ], | 40 | ], |
41 | name: _Paths.login, | 41 | name: _Paths.login, |
42 | - page: () => LoginView(), | 42 | + page: () => const LoginView(), |
43 | bindings: [LoginBinding()], | 43 | bindings: [LoginBinding()], |
44 | ), | 44 | ), |
45 | GetPage( | 45 | GetPage( |
@@ -53,7 +53,7 @@ class AppPages { | @@ -53,7 +53,7 @@ class AppPages { | ||
53 | children: [ | 53 | children: [ |
54 | GetPage( | 54 | GetPage( |
55 | name: _Paths.dashboard, | 55 | name: _Paths.dashboard, |
56 | - page: () => DashboardView(), | 56 | + page: () => const DashboardView(), |
57 | bindings: [ | 57 | bindings: [ |
58 | DashboardBinding(), | 58 | DashboardBinding(), |
59 | ], | 59 | ], |
@@ -64,7 +64,7 @@ class AppPages { | @@ -64,7 +64,7 @@ class AppPages { | ||
64 | EnsureAuthMiddleware(), | 64 | EnsureAuthMiddleware(), |
65 | ], | 65 | ], |
66 | name: _Paths.profile, | 66 | name: _Paths.profile, |
67 | - page: () => ProfileView(), | 67 | + page: () => const ProfileView(), |
68 | title: 'Profile', | 68 | title: 'Profile', |
69 | transition: Transition.size, | 69 | transition: Transition.size, |
70 | bindings: [ProfileBinding()], | 70 | bindings: [ProfileBinding()], |
@@ -82,8 +82,8 @@ class AppPages { | @@ -82,8 +82,8 @@ class AppPages { | ||
82 | name: _Paths.productDetails, | 82 | name: _Paths.productDetails, |
83 | transition: Transition.cupertino, | 83 | transition: Transition.cupertino, |
84 | showCupertinoParallax: true, | 84 | showCupertinoParallax: true, |
85 | - page: () => ProductDetailsView(), | ||
86 | - bindings: [], | 85 | + page: () => const ProductDetailsView(), |
86 | + bindings: const [], | ||
87 | middlewares: [ | 87 | middlewares: [ |
88 | //only enter this route when authed | 88 | //only enter this route when authed |
89 | EnsureAuthMiddleware(), | 89 | EnsureAuthMiddleware(), |
@@ -95,7 +95,7 @@ class AppPages { | @@ -95,7 +95,7 @@ class AppPages { | ||
95 | ), | 95 | ), |
96 | GetPage( | 96 | GetPage( |
97 | name: _Paths.settings, | 97 | name: _Paths.settings, |
98 | - page: () => SettingsView(), | 98 | + page: () => const SettingsView(), |
99 | bindings: [ | 99 | bindings: [ |
100 | SettingsBinding(), | 100 | SettingsBinding(), |
101 | ], | 101 | ], |
@@ -268,9 +268,9 @@ class GetConnect extends GetConnectInterface { | @@ -268,9 +268,9 @@ class GetConnect extends GetConnectInterface { | ||
268 | }) { | 268 | }) { |
269 | _checkIfDisposed(isHttp: false); | 269 | _checkIfDisposed(isHttp: false); |
270 | 270 | ||
271 | - final _socket = GetSocket(_concatUrl(url)!, ping: ping); | ||
272 | - sockets.add(_socket); | ||
273 | - return _socket; | 271 | + final newSocket = GetSocket(_concatUrl(url)!, ping: ping); |
272 | + sockets.add(newSocket); | ||
273 | + return newSocket; | ||
274 | } | 274 | } |
275 | 275 | ||
276 | String? _concatUrl(String? url) { | 276 | String? _concatUrl(String? url) { |
@@ -4,7 +4,8 @@ List<int> fileToBytes(dynamic data) { | @@ -4,7 +4,8 @@ List<int> fileToBytes(dynamic data) { | ||
4 | if (data is List<int>) { | 4 | if (data is List<int>) { |
5 | return data; | 5 | return data; |
6 | } else { | 6 | } else { |
7 | - throw FormatException('File is not "File" or "String" or "List<int>"'); | 7 | + throw const FormatException( |
8 | + 'File is not "File" or "String" or "List<int>"'); | ||
8 | } | 9 | } |
9 | } | 10 | } |
10 | 11 |
@@ -12,7 +12,8 @@ List<int> fileToBytes(dynamic data) { | @@ -12,7 +12,8 @@ List<int> fileToBytes(dynamic data) { | ||
12 | } else if (data is List<int>) { | 12 | } else if (data is List<int>) { |
13 | return data; | 13 | return data; |
14 | } else { | 14 | } else { |
15 | - throw FormatException('File is not "File" or "String" or "List<int>"'); | 15 | + throw const FormatException( |
16 | + 'File is not "File" or "String" or "List<int>"'); | ||
16 | } | 17 | } |
17 | } | 18 | } |
18 | 19 |
@@ -25,9 +25,9 @@ class FormData { | @@ -25,9 +25,9 @@ class FormData { | ||
25 | static const int _maxBoundaryLength = 70; | 25 | static const int _maxBoundaryLength = 70; |
26 | 26 | ||
27 | static String _getBoundary() { | 27 | static String _getBoundary() { |
28 | - final _random = Random(); | 28 | + final newRandom = Random(); |
29 | var list = List<int>.generate(_maxBoundaryLength - GET_BOUNDARY.length, | 29 | var list = List<int>.generate(_maxBoundaryLength - GET_BOUNDARY.length, |
30 | - (_) => boundaryCharacters[_random.nextInt(boundaryCharacters.length)], | 30 | + (_) => boundaryCharacters[newRandom.nextInt(boundaryCharacters.length)], |
31 | growable: false); | 31 | growable: false); |
32 | return '$GET_BOUNDARY${String.fromCharCodes(list)}'; | 32 | return '$GET_BOUNDARY${String.fromCharCodes(list)}'; |
33 | } | 33 | } |
@@ -161,11 +161,11 @@ extension Inst on GetInterface { | @@ -161,11 +161,11 @@ extension Inst on GetInterface { | ||
161 | 161 | ||
162 | _InstanceBuilderFactory<S>? dep; | 162 | _InstanceBuilderFactory<S>? dep; |
163 | if (_singl.containsKey(key)) { | 163 | if (_singl.containsKey(key)) { |
164 | - final _dep = _singl[key]; | ||
165 | - if (_dep == null || !_dep.isDirty) { | 164 | + final newDep = _singl[key]; |
165 | + if (newDep == null || !newDep.isDirty) { | ||
166 | return; | 166 | return; |
167 | } else { | 167 | } else { |
168 | - dep = _dep as _InstanceBuilderFactory<S>; | 168 | + dep = newDep as _InstanceBuilderFactory<S>; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | _singl[key] = _InstanceBuilderFactory<S>( | 171 | _singl[key] = _InstanceBuilderFactory<S>( |
@@ -44,7 +44,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { | @@ -44,7 +44,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { | ||
44 | final bool removeTop; | 44 | final bool removeTop; |
45 | 45 | ||
46 | @override | 46 | @override |
47 | - Duration get transitionDuration => Duration(milliseconds: 700); | 47 | + Duration get transitionDuration => const Duration(milliseconds: 700); |
48 | 48 | ||
49 | @override | 49 | @override |
50 | bool get barrierDismissible => isDismissible; | 50 | bool get barrierDismissible => isDismissible; |
@@ -51,9 +51,9 @@ class GetDialogRoute<T> extends PopupRoute<T> { | @@ -51,9 +51,9 @@ class GetDialogRoute<T> extends PopupRoute<T> { | ||
51 | Widget buildPage(BuildContext context, Animation<double> animation, | 51 | Widget buildPage(BuildContext context, Animation<double> animation, |
52 | Animation<double> secondaryAnimation) { | 52 | Animation<double> secondaryAnimation) { |
53 | return Semantics( | 53 | return Semantics( |
54 | - child: widget(context, animation, secondaryAnimation), | ||
55 | scopesRoute: true, | 54 | scopesRoute: true, |
56 | explicitChildNodes: true, | 55 | explicitChildNodes: true, |
56 | + child: widget(context, animation, secondaryAnimation), | ||
57 | ); | 57 | ); |
58 | } | 58 | } |
59 | 59 |
@@ -187,7 +187,7 @@ extension ExtensionDialog on GetInterface { | @@ -187,7 +187,7 @@ extension ExtensionDialog on GetInterface { | ||
187 | actions.add(TextButton( | 187 | actions.add(TextButton( |
188 | style: TextButton.styleFrom( | 188 | style: TextButton.styleFrom( |
189 | tapTargetSize: MaterialTapTargetSize.shrinkWrap, | 189 | tapTargetSize: MaterialTapTargetSize.shrinkWrap, |
190 | - padding: EdgeInsets.symmetric(horizontal: 10, vertical: 8), | 190 | + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), |
191 | shape: RoundedRectangleBorder( | 191 | shape: RoundedRectangleBorder( |
192 | side: BorderSide( | 192 | side: BorderSide( |
193 | color: buttonColor ?? theme.colorScheme.secondary, | 193 | color: buttonColor ?? theme.colorScheme.secondary, |
@@ -230,8 +230,8 @@ extension ExtensionDialog on GetInterface { | @@ -230,8 +230,8 @@ extension ExtensionDialog on GetInterface { | ||
230 | } | 230 | } |
231 | 231 | ||
232 | Widget baseAlertDialog = AlertDialog( | 232 | Widget baseAlertDialog = AlertDialog( |
233 | - titlePadding: titlePadding ?? EdgeInsets.all(8), | ||
234 | - contentPadding: contentPadding ?? EdgeInsets.all(8), | 233 | + titlePadding: titlePadding ?? const EdgeInsets.all(8), |
234 | + contentPadding: contentPadding ?? const EdgeInsets.all(8), | ||
235 | 235 | ||
236 | backgroundColor: backgroundColor ?? theme.dialogBackgroundColor, | 236 | backgroundColor: backgroundColor ?? theme.dialogBackgroundColor, |
237 | shape: RoundedRectangleBorder( | 237 | shape: RoundedRectangleBorder( |
@@ -244,7 +244,7 @@ extension ExtensionDialog on GetInterface { | @@ -244,7 +244,7 @@ extension ExtensionDialog on GetInterface { | ||
244 | content ?? | 244 | content ?? |
245 | Text(middleText, | 245 | Text(middleText, |
246 | textAlign: TextAlign.center, style: middleTextStyle), | 246 | textAlign: TextAlign.center, style: middleTextStyle), |
247 | - SizedBox(height: 16), | 247 | + const SizedBox(height: 16), |
248 | ButtonTheme( | 248 | ButtonTheme( |
249 | minWidth: 78.0, | 249 | minWidth: 78.0, |
250 | height: 34.0, | 250 | height: 34.0, |
@@ -433,14 +433,14 @@ extension ExtensionSnackbar on GetInterface { | @@ -433,14 +433,14 @@ extension ExtensionSnackbar on GetInterface { | ||
433 | ), | 433 | ), |
434 | snackPosition: snackPosition ?? SnackPosition.top, | 434 | snackPosition: snackPosition ?? SnackPosition.top, |
435 | borderRadius: borderRadius ?? 15, | 435 | borderRadius: borderRadius ?? 15, |
436 | - margin: margin ?? EdgeInsets.symmetric(horizontal: 10), | 436 | + margin: margin ?? const EdgeInsets.symmetric(horizontal: 10), |
437 | duration: duration, | 437 | duration: duration, |
438 | barBlur: barBlur ?? 7.0, | 438 | barBlur: barBlur ?? 7.0, |
439 | backgroundColor: backgroundColor ?? Colors.grey.withOpacity(0.2), | 439 | backgroundColor: backgroundColor ?? Colors.grey.withOpacity(0.2), |
440 | icon: icon, | 440 | icon: icon, |
441 | shouldIconPulse: shouldIconPulse ?? true, | 441 | shouldIconPulse: shouldIconPulse ?? true, |
442 | maxWidth: maxWidth, | 442 | maxWidth: maxWidth, |
443 | - padding: padding ?? EdgeInsets.all(16), | 443 | + padding: padding ?? const EdgeInsets.all(16), |
444 | borderColor: borderColor, | 444 | borderColor: borderColor, |
445 | borderWidth: borderWidth, | 445 | borderWidth: borderWidth, |
446 | leftBarIndicatorColor: leftBarIndicatorColor, | 446 | leftBarIndicatorColor: leftBarIndicatorColor, |
@@ -457,7 +457,7 @@ extension ExtensionSnackbar on GetInterface { | @@ -457,7 +457,7 @@ extension ExtensionSnackbar on GetInterface { | ||
457 | snackStyle: snackStyle ?? SnackStyle.floating, | 457 | snackStyle: snackStyle ?? SnackStyle.floating, |
458 | forwardAnimationCurve: forwardAnimationCurve ?? Curves.easeOutCirc, | 458 | forwardAnimationCurve: forwardAnimationCurve ?? Curves.easeOutCirc, |
459 | reverseAnimationCurve: reverseAnimationCurve ?? Curves.easeOutCirc, | 459 | reverseAnimationCurve: reverseAnimationCurve ?? Curves.easeOutCirc, |
460 | - animationDuration: animationDuration ?? Duration(seconds: 1), | 460 | + animationDuration: animationDuration ?? const Duration(seconds: 1), |
461 | overlayBlur: overlayBlur ?? 0.0, | 461 | overlayBlur: overlayBlur ?? 0.0, |
462 | overlayColor: overlayColor ?? Colors.transparent, | 462 | overlayColor: overlayColor ?? Colors.transparent, |
463 | userInputForm: userInputForm); | 463 | userInputForm: userInputForm); |
@@ -1082,14 +1082,14 @@ extension GetNavigationExt on GetInterface { | @@ -1082,14 +1082,14 @@ extension GetNavigationExt on GetInterface { | ||
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | GetDelegate searchDelegate(dynamic k) { | 1084 | GetDelegate searchDelegate(dynamic k) { |
1085 | - GetDelegate _key; | 1085 | + GetDelegate key; |
1086 | if (k == null) { | 1086 | if (k == null) { |
1087 | - _key = Get.rootController.rootDelegate; | 1087 | + key = Get.rootController.rootDelegate; |
1088 | } else { | 1088 | } else { |
1089 | if (!keys.containsKey(k)) { | 1089 | if (!keys.containsKey(k)) { |
1090 | throw 'Route id ($k) not found'; | 1090 | throw 'Route id ($k) not found'; |
1091 | } | 1091 | } |
1092 | - _key = keys[k]!; | 1092 | + key = keys[k]!; |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | // if (_key.listenersLength == 0 && !testMode) { | 1095 | // if (_key.listenersLength == 0 && !testMode) { |
@@ -1102,7 +1102,7 @@ extension GetNavigationExt on GetInterface { | @@ -1102,7 +1102,7 @@ extension GetNavigationExt on GetInterface { | ||
1102 | // """; | 1102 | // """; |
1103 | // } | 1103 | // } |
1104 | 1104 | ||
1105 | - return _key; | 1105 | + return key; |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | /// give current arguments | 1108 | /// give current arguments |
@@ -1156,11 +1156,11 @@ extension GetNavigationExt on GetInterface { | @@ -1156,11 +1156,11 @@ extension GetNavigationExt on GetInterface { | ||
1156 | 1156 | ||
1157 | /// give access to Theme.of(context) | 1157 | /// give access to Theme.of(context) |
1158 | ThemeData get theme { | 1158 | ThemeData get theme { |
1159 | - var _theme = ThemeData.fallback(); | 1159 | + var theme = ThemeData.fallback(); |
1160 | if (context != null) { | 1160 | if (context != null) { |
1161 | - _theme = Theme.of(context!); | 1161 | + theme = Theme.of(context!); |
1162 | } | 1162 | } |
1163 | - return _theme; | 1163 | + return theme; |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | /// The current null safe [WidgetsBinding] | 1166 | /// The current null safe [WidgetsBinding] |
@@ -1283,8 +1283,8 @@ extension OverlayExt on GetInterface { | @@ -1283,8 +1283,8 @@ extension OverlayExt on GetInterface { | ||
1283 | }); | 1283 | }); |
1284 | final overlayEntryLoader = OverlayEntry(builder: (context) { | 1284 | final overlayEntryLoader = OverlayEntry(builder: (context) { |
1285 | return loadingWidget ?? | 1285 | return loadingWidget ?? |
1286 | - Center( | ||
1287 | - child: Container( | 1286 | + const Center( |
1287 | + child: SizedBox( | ||
1288 | height: 90, | 1288 | height: 90, |
1289 | width: 90, | 1289 | width: 90, |
1290 | child: Text('Loading...'), | 1290 | child: Text('Loading...'), |
@@ -65,7 +65,7 @@ class GetCupertinoApp extends StatelessWidget { | @@ -65,7 +65,7 @@ class GetCupertinoApp extends StatelessWidget { | ||
65 | final List<Bind> binds; | 65 | final List<Bind> binds; |
66 | final ScrollBehavior? scrollBehavior; | 66 | final ScrollBehavior? scrollBehavior; |
67 | 67 | ||
68 | - GetCupertinoApp({ | 68 | + const GetCupertinoApp({ |
69 | Key? key, | 69 | Key? key, |
70 | this.theme, | 70 | this.theme, |
71 | this.navigatorKey, | 71 | this.navigatorKey, |
@@ -125,18 +125,7 @@ class GetCupertinoApp extends StatelessWidget { | @@ -125,18 +125,7 @@ class GetCupertinoApp extends StatelessWidget { | ||
125 | routerDelegate = null, | 125 | routerDelegate = null, |
126 | super(key: key); | 126 | super(key: key); |
127 | 127 | ||
128 | - static String _cleanRouteName(String name) { | ||
129 | - name = name.replaceAll('() => ', ''); | ||
130 | - | ||
131 | - /// uncommonent for URL styling. | ||
132 | - // name = name.paramCase!; | ||
133 | - if (!name.startsWith('/')) { | ||
134 | - name = '/$name'; | ||
135 | - } | ||
136 | - return Uri.tryParse(name)?.toString() ?? name; | ||
137 | - } | ||
138 | - | ||
139 | - GetCupertinoApp.router({ | 128 | + const GetCupertinoApp.router({ |
140 | Key? key, | 129 | Key? key, |
141 | this.theme, | 130 | this.theme, |
142 | this.routeInformationProvider, | 131 | this.routeInformationProvider, |
@@ -240,8 +229,8 @@ class GetCupertinoApp extends StatelessWidget { | @@ -240,8 +229,8 @@ class GetCupertinoApp extends StatelessWidget { | ||
240 | ? TextDirection.rtl | 229 | ? TextDirection.rtl |
241 | : TextDirection.ltr), | 230 | : TextDirection.ltr), |
242 | child: builder == null | 231 | child: builder == null |
243 | - ? (child ?? Material()) | ||
244 | - : builder!(context, child ?? Material()), | 232 | + ? (child ?? const Material()) |
233 | + : builder!(context, child ?? const Material()), | ||
245 | ), | 234 | ), |
246 | title: title, | 235 | title: title, |
247 | onGenerateTitle: onGenerateTitle, | 236 | onGenerateTitle: onGenerateTitle, |
@@ -129,7 +129,7 @@ class GetMaterialApp extends StatelessWidget { | @@ -129,7 +129,7 @@ class GetMaterialApp extends StatelessWidget { | ||
129 | routerDelegate = null, | 129 | routerDelegate = null, |
130 | super(key: key); | 130 | super(key: key); |
131 | 131 | ||
132 | - GetMaterialApp.router({ | 132 | + const GetMaterialApp.router({ |
133 | Key? key, | 133 | Key? key, |
134 | this.routeInformationProvider, | 134 | this.routeInformationProvider, |
135 | this.scaffoldMessengerKey, | 135 | this.scaffoldMessengerKey, |
@@ -240,7 +240,6 @@ class GetMaterialApp extends StatelessWidget { | @@ -240,7 +240,6 @@ class GetMaterialApp extends StatelessWidget { | ||
240 | // ], | 240 | // ], |
241 | child: Builder(builder: (context) { | 241 | child: Builder(builder: (context) { |
242 | final controller = GetRoot.of(context); | 242 | final controller = GetRoot.of(context); |
243 | - print('ROUTERRRR ${controller.config.routerDelegate}'); | ||
244 | return MaterialApp.router( | 243 | return MaterialApp.router( |
245 | routerDelegate: controller.config.routerDelegate, | 244 | routerDelegate: controller.config.routerDelegate, |
246 | routeInformationParser: controller.config.routeInformationParser, | 245 | routeInformationParser: controller.config.routeInformationParser, |
@@ -253,8 +252,8 @@ class GetMaterialApp extends StatelessWidget { | @@ -253,8 +252,8 @@ class GetMaterialApp extends StatelessWidget { | ||
253 | ? TextDirection.rtl | 252 | ? TextDirection.rtl |
254 | : TextDirection.ltr), | 253 | : TextDirection.ltr), |
255 | child: builder == null | 254 | child: builder == null |
256 | - ? (child ?? Material()) | ||
257 | - : builder!(context, child ?? Material()), | 255 | + ? (child ?? const Material()) |
256 | + : builder!(context, child ?? const Material()), | ||
258 | ), | 257 | ), |
259 | title: title, | 258 | title: title, |
260 | onGenerateTitle: onGenerateTitle, | 259 | onGenerateTitle: onGenerateTitle, |
@@ -276,7 +276,7 @@ class ConfigData { | @@ -276,7 +276,7 @@ class ConfigData { | ||
276 | } | 276 | } |
277 | 277 | ||
278 | class GetRoot extends StatefulWidget { | 278 | class GetRoot extends StatefulWidget { |
279 | - GetRoot({ | 279 | + const GetRoot({ |
280 | Key? key, | 280 | Key? key, |
281 | required this.config, | 281 | required this.config, |
282 | required this.child, | 282 | required this.child, |
@@ -132,15 +132,15 @@ class GetPageRoute<T> extends PageRoute<T> | @@ -132,15 +132,15 @@ class GetPageRoute<T> extends PageRoute<T> | ||
132 | final dep = item.dependencies(); | 132 | final dep = item.dependencies(); |
133 | if (dep is List<Bind>) { | 133 | if (dep is List<Bind>) { |
134 | _child = Binds( | 134 | _child = Binds( |
135 | - child: middlewareRunner.runOnPageBuilt(pageToBuild()), | ||
136 | binds: dep, | 135 | binds: dep, |
136 | + child: middlewareRunner.runOnPageBuilt(pageToBuild()), | ||
137 | ); | 137 | ); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | } else if (bindingsToBind is List<Bind>) { | 140 | } else if (bindingsToBind is List<Bind>) { |
141 | _child = Binds( | 141 | _child = Binds( |
142 | - child: middlewareRunner.runOnPageBuilt(pageToBuild()), | ||
143 | binds: bindingsToBind, | 142 | binds: bindingsToBind, |
143 | + child: middlewareRunner.runOnPageBuilt(pageToBuild()), | ||
144 | ); | 144 | ); |
145 | } | 145 | } |
146 | } | 146 | } |
@@ -89,7 +89,7 @@ class SlideDownTransition { | @@ -89,7 +89,7 @@ class SlideDownTransition { | ||
89 | Widget child) { | 89 | Widget child) { |
90 | return SlideTransition( | 90 | return SlideTransition( |
91 | position: Tween<Offset>( | 91 | position: Tween<Offset>( |
92 | - begin: Offset(0.0, 1.0), | 92 | + begin: const Offset(0.0, 1.0), |
93 | end: Offset.zero, | 93 | end: Offset.zero, |
94 | ).animate(animation), | 94 | ).animate(animation), |
95 | child: child, | 95 | child: child, |
@@ -107,7 +107,7 @@ class SlideLeftTransition { | @@ -107,7 +107,7 @@ class SlideLeftTransition { | ||
107 | Widget child) { | 107 | Widget child) { |
108 | return SlideTransition( | 108 | return SlideTransition( |
109 | position: Tween<Offset>( | 109 | position: Tween<Offset>( |
110 | - begin: Offset(-1.0, 0.0), | 110 | + begin: const Offset(-1.0, 0.0), |
111 | end: Offset.zero, | 111 | end: Offset.zero, |
112 | ).animate(animation), | 112 | ).animate(animation), |
113 | child: child, | 113 | child: child, |
@@ -125,7 +125,7 @@ class SlideRightTransition { | @@ -125,7 +125,7 @@ class SlideRightTransition { | ||
125 | Widget child) { | 125 | Widget child) { |
126 | return SlideTransition( | 126 | return SlideTransition( |
127 | position: Tween<Offset>( | 127 | position: Tween<Offset>( |
128 | - begin: Offset(1.0, 0.0), | 128 | + begin: const Offset(1.0, 0.0), |
129 | end: Offset.zero, | 129 | end: Offset.zero, |
130 | ).animate(animation), | 130 | ).animate(animation), |
131 | child: child, | 131 | child: child, |
@@ -143,7 +143,7 @@ class SlideTopTransition { | @@ -143,7 +143,7 @@ class SlideTopTransition { | ||
143 | Widget child) { | 143 | Widget child) { |
144 | return SlideTransition( | 144 | return SlideTransition( |
145 | position: Tween<Offset>( | 145 | position: Tween<Offset>( |
146 | - begin: Offset(0.0, -1.0), | 146 | + begin: const Offset(0.0, -1.0), |
147 | end: Offset.zero, | 147 | end: Offset.zero, |
148 | ).animate(animation), | 148 | ).animate(animation), |
149 | child: child, | 149 | child: child, |
@@ -48,7 +48,7 @@ class GetNavigator extends Navigator { | @@ -48,7 +48,7 @@ class GetNavigator extends Navigator { | ||
48 | ); | 48 | ); |
49 | 49 | ||
50 | GetNavigator({ | 50 | GetNavigator({ |
51 | - GlobalKey<NavigatorState>? key, | 51 | + Key? key, |
52 | bool Function(Route<dynamic>, dynamic)? onPopPage, | 52 | bool Function(Route<dynamic>, dynamic)? onPopPage, |
53 | required List<GetPage> pages, | 53 | required List<GetPage> pages, |
54 | List<NavigatorObserver>? observers, | 54 | List<NavigatorObserver>? observers, |
@@ -164,19 +164,19 @@ class GetPage<T> extends Page<T> { | @@ -164,19 +164,19 @@ class GetPage<T> extends Page<T> { | ||
164 | @override | 164 | @override |
165 | Route<T> createRoute(BuildContext context) { | 165 | Route<T> createRoute(BuildContext context) { |
166 | // return GetPageRoute<T>(settings: this, page: page); | 166 | // return GetPageRoute<T>(settings: this, page: page); |
167 | - final _page = PageRedirect( | 167 | + final page = PageRedirect( |
168 | route: this, | 168 | route: this, |
169 | settings: this, | 169 | settings: this, |
170 | unknownRoute: unknownRoute, | 170 | unknownRoute: unknownRoute, |
171 | ).getPageToRoute<T>(this, unknownRoute, context); | 171 | ).getPageToRoute<T>(this, unknownRoute, context); |
172 | 172 | ||
173 | - return _page; | 173 | + return page; |
174 | } | 174 | } |
175 | 175 | ||
176 | static PathDecoded _nameToRegex(String path) { | 176 | static PathDecoded _nameToRegex(String path) { |
177 | var keys = <String?>[]; | 177 | var keys = <String?>[]; |
178 | 178 | ||
179 | - String _replace(Match pattern) { | 179 | + String recursiveReplace(Match pattern) { |
180 | var buffer = StringBuffer('(?:'); | 180 | var buffer = StringBuffer('(?:'); |
181 | 181 | ||
182 | if (pattern[1] != null) buffer.write('.'); | 182 | if (pattern[1] != null) buffer.write('.'); |
@@ -188,7 +188,7 @@ class GetPage<T> extends Page<T> { | @@ -188,7 +188,7 @@ class GetPage<T> extends Page<T> { | ||
188 | } | 188 | } |
189 | 189 | ||
190 | var stringPath = '$path/?' | 190 | var stringPath = '$path/?' |
191 | - .replaceAllMapped(RegExp(r'(\.)?:(\w+)(\?)?'), _replace) | 191 | + .replaceAllMapped(RegExp(r'(\.)?:(\w+)(\?)?'), recursiveReplace) |
192 | .replaceAll('//', '/'); | 192 | .replaceAll('//', '/'); |
193 | 193 | ||
194 | return PathDecoded(RegExp('^$stringPath\$'), keys); | 194 | return PathDecoded(RegExp('^$stringPath\$'), keys); |
@@ -93,7 +93,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -93,7 +93,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
93 | }) : navigatorKey = navigatorKey ?? GlobalKey<NavigatorState>(), | 93 | }) : navigatorKey = navigatorKey ?? GlobalKey<NavigatorState>(), |
94 | notFoundRoute = notFoundRoute ??= GetPage( | 94 | notFoundRoute = notFoundRoute ??= GetPage( |
95 | name: '/404', | 95 | name: '/404', |
96 | - page: () => Scaffold( | 96 | + page: () => const Scaffold( |
97 | body: Center(child: Text('Route not found')), | 97 | body: Center(child: Text('Route not found')), |
98 | ), | 98 | ), |
99 | ) { | 99 | ) { |
@@ -380,8 +380,8 @@ Cannot read the previousTitle for a route that has not yet been installed''', | @@ -380,8 +380,8 @@ Cannot read the previousTitle for a route that has not yet been installed''', | ||
380 | ? CurvedAnimation(parent: animation, curve: finalCurve) | 380 | ? CurvedAnimation(parent: animation, curve: finalCurve) |
381 | : animation, | 381 | : animation, |
382 | secondaryRouteAnimation: secondaryAnimation, | 382 | secondaryRouteAnimation: secondaryAnimation, |
383 | - child: child, | ||
384 | linearTransition: linearTransition, | 383 | linearTransition: linearTransition, |
384 | + child: child, | ||
385 | ); | 385 | ); |
386 | } else { | 386 | } else { |
387 | if (route.customTransition != null) { | 387 | if (route.customTransition != null) { |
@@ -636,7 +636,7 @@ Cannot read the previousTitle for a route that has not yet been installed''', | @@ -636,7 +636,7 @@ Cannot read the previousTitle for a route that has not yet been installed''', | ||
636 | )); | 636 | )); |
637 | 637 | ||
638 | case Transition.fade: | 638 | case Transition.fade: |
639 | - return FadeUpwardsPageTransitionsBuilder().buildTransitions( | 639 | + return const FadeUpwardsPageTransitionsBuilder().buildTransitions( |
640 | route, | 640 | route, |
641 | context, | 641 | context, |
642 | animation, | 642 | animation, |
@@ -656,7 +656,7 @@ Cannot read the previousTitle for a route that has not yet been installed''', | @@ -656,7 +656,7 @@ Cannot read the previousTitle for a route that has not yet been installed''', | ||
656 | )); | 656 | )); |
657 | 657 | ||
658 | case Transition.topLevel: | 658 | case Transition.topLevel: |
659 | - return ZoomPageTransitionsBuilder().buildTransitions( | 659 | + return const ZoomPageTransitionsBuilder().buildTransitions( |
660 | route, | 660 | route, |
661 | context, | 661 | context, |
662 | animation, | 662 | animation, |
@@ -676,7 +676,7 @@ Cannot read the previousTitle for a route that has not yet been installed''', | @@ -676,7 +676,7 @@ Cannot read the previousTitle for a route that has not yet been installed''', | ||
676 | )); | 676 | )); |
677 | 677 | ||
678 | case Transition.native: | 678 | case Transition.native: |
679 | - return PageTransitionsTheme().buildTransitions( | 679 | + return const PageTransitionsTheme().buildTransitions( |
680 | route, | 680 | route, |
681 | context, | 681 | context, |
682 | iosAnimation, | 682 | iosAnimation, |
@@ -57,17 +57,17 @@ class Dependencies { | @@ -57,17 +57,17 @@ class Dependencies { | ||
57 | } | 57 | } |
58 | 58 | ||
59 | abstract class Module extends StatefulWidget { | 59 | abstract class Module extends StatefulWidget { |
60 | - Module({Key? key}) : super(key: key); | 60 | + const Module({Key? key}) : super(key: key); |
61 | 61 | ||
62 | Widget view(BuildContext context); | 62 | Widget view(BuildContext context); |
63 | 63 | ||
64 | void dependencies(Dependencies i); | 64 | void dependencies(Dependencies i); |
65 | 65 | ||
66 | @override | 66 | @override |
67 | - _ModuleState createState() => _ModuleState(); | 67 | + ModuleState createState() => ModuleState(); |
68 | } | 68 | } |
69 | 69 | ||
70 | -class _ModuleState extends State<Module> { | 70 | +class ModuleState extends State<Module> { |
71 | @override | 71 | @override |
72 | void initState() { | 72 | void initState() { |
73 | RouterReportManager.instance.reportCurrentRoute(this); | 73 | RouterReportManager.instance.reportCurrentRoute(this); |
@@ -57,10 +57,10 @@ class RouteDecoder { | @@ -57,10 +57,10 @@ class RouteDecoder { | ||
57 | } | 57 | } |
58 | 58 | ||
59 | void replaceArguments(Object? arguments) { | 59 | void replaceArguments(Object? arguments) { |
60 | - final _route = route; | ||
61 | - if (_route != null) { | ||
62 | - final index = currentTreeBranch.indexOf(_route); | ||
63 | - currentTreeBranch[index] = _route.copyWith(arguments: arguments); | 60 | + final newRoute = route; |
61 | + if (newRoute != null) { | ||
62 | + final index = currentTreeBranch.indexOf(newRoute); | ||
63 | + currentTreeBranch[index] = newRoute.copyWith(arguments: arguments); | ||
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 |
@@ -130,8 +130,8 @@ class MiddlewareRunner { | @@ -130,8 +130,8 @@ class MiddlewareRunner { | ||
130 | final List<GetMiddleware>? _middlewares; | 130 | final List<GetMiddleware>? _middlewares; |
131 | 131 | ||
132 | List<GetMiddleware> _getMiddlewares() { | 132 | List<GetMiddleware> _getMiddlewares() { |
133 | - final _m = _middlewares ?? <GetMiddleware>[]; | ||
134 | - return List.of(_m) | 133 | + final newMiddleware = _middlewares ?? <GetMiddleware>[]; |
134 | + return List.of(newMiddleware) | ||
135 | ..sort( | 135 | ..sort( |
136 | (a, b) => (a.priority ?? 0).compareTo(b.priority ?? 0), | 136 | (a, b) => (a.priority ?? 0).compareTo(b.priority ?? 0), |
137 | ); | 137 | ); |
@@ -198,34 +198,33 @@ class PageRedirect { | @@ -198,34 +198,33 @@ class PageRedirect { | ||
198 | GetPageRoute<T> getPageToRoute<T>( | 198 | GetPageRoute<T> getPageToRoute<T>( |
199 | GetPage rou, GetPage? unk, BuildContext context) { | 199 | GetPage rou, GetPage? unk, BuildContext context) { |
200 | while (needRecheck(context)) {} | 200 | while (needRecheck(context)) {} |
201 | - final _r = (isUnknown ? unk : rou)!; | 201 | + final r = (isUnknown ? unk : rou)!; |
202 | 202 | ||
203 | return GetPageRoute<T>( | 203 | return GetPageRoute<T>( |
204 | - page: _r.page, | ||
205 | - parameter: _r.parameters, | ||
206 | - alignment: _r.alignment, | ||
207 | - title: _r.title, | ||
208 | - maintainState: _r.maintainState, | ||
209 | - routeName: _r.name, | ||
210 | - settings: _r, | ||
211 | - curve: _r.curve, | ||
212 | - showCupertinoParallax: _r.showCupertinoParallax, | ||
213 | - gestureWidth: _r.gestureWidth, | ||
214 | - opaque: _r.opaque, | ||
215 | - customTransition: _r.customTransition, | ||
216 | - bindings: _r.bindings, | ||
217 | - binding: _r.binding, | ||
218 | - binds: _r.binds, | ||
219 | - transitionDuration: | ||
220 | - _r.transitionDuration ?? Get.defaultTransitionDuration, | 204 | + page: r.page, |
205 | + parameter: r.parameters, | ||
206 | + alignment: r.alignment, | ||
207 | + title: r.title, | ||
208 | + maintainState: r.maintainState, | ||
209 | + routeName: r.name, | ||
210 | + settings: r, | ||
211 | + curve: r.curve, | ||
212 | + showCupertinoParallax: r.showCupertinoParallax, | ||
213 | + gestureWidth: r.gestureWidth, | ||
214 | + opaque: r.opaque, | ||
215 | + customTransition: r.customTransition, | ||
216 | + bindings: r.bindings, | ||
217 | + binding: r.binding, | ||
218 | + binds: r.binds, | ||
219 | + transitionDuration: r.transitionDuration ?? Get.defaultTransitionDuration, | ||
221 | reverseTransitionDuration: | 220 | reverseTransitionDuration: |
222 | - _r.reverseTransitionDuration ?? Get.defaultTransitionDuration, | 221 | + r.reverseTransitionDuration ?? Get.defaultTransitionDuration, |
223 | // performIncomeAnimation: _r.performIncomeAnimation, | 222 | // performIncomeAnimation: _r.performIncomeAnimation, |
224 | // performOutGoingAnimation: _r.performOutGoingAnimation, | 223 | // performOutGoingAnimation: _r.performOutGoingAnimation, |
225 | - transition: _r.transition, | ||
226 | - popGesture: _r.popGesture, | ||
227 | - fullscreenDialog: _r.fullscreenDialog, | ||
228 | - middlewares: _r.middlewares, | 224 | + transition: r.transition, |
225 | + popGesture: r.popGesture, | ||
226 | + fullscreenDialog: r.fullscreenDialog, | ||
227 | + middlewares: r.middlewares, | ||
229 | ); | 228 | ); |
230 | } | 229 | } |
231 | 230 |
@@ -4,14 +4,14 @@ import '../router_report.dart'; | @@ -4,14 +4,14 @@ import '../router_report.dart'; | ||
4 | import 'default_route.dart'; | 4 | import 'default_route.dart'; |
5 | 5 | ||
6 | class RouteReport extends StatefulWidget { | 6 | class RouteReport extends StatefulWidget { |
7 | - RouteReport({Key? key, required this.builder}) : super(key: key); | 7 | + const RouteReport({Key? key, required this.builder}) : super(key: key); |
8 | final WidgetBuilder builder; | 8 | final WidgetBuilder builder; |
9 | 9 | ||
10 | @override | 10 | @override |
11 | - _RouteReportState createState() => _RouteReportState(); | 11 | + RouteReportState createState() => RouteReportState(); |
12 | } | 12 | } |
13 | 13 | ||
14 | -class _RouteReportState extends State<RouteReport> with RouteReportMixin { | 14 | +class RouteReportState extends State<RouteReport> with RouteReportMixin { |
15 | @override | 15 | @override |
16 | void initState() { | 16 | void initState() { |
17 | RouterReportManager.instance.reportCurrentRoute(this); | 17 | RouterReportManager.instance.reportCurrentRoute(this); |
@@ -9,12 +9,13 @@ class RouterOutlet<TDelegate extends RouterDelegate<T>, T extends Object> | @@ -9,12 +9,13 @@ class RouterOutlet<TDelegate extends RouterDelegate<T>, T extends Object> | ||
9 | 9 | ||
10 | //keys | 10 | //keys |
11 | RouterOutlet.builder({ | 11 | RouterOutlet.builder({ |
12 | + super.key, | ||
12 | TDelegate? delegate, | 13 | TDelegate? delegate, |
13 | required this.builder, | 14 | required this.builder, |
14 | - }) : routerDelegate = delegate ?? Get.delegate<TDelegate, T>()!, | ||
15 | - super(); | 15 | + }) : routerDelegate = delegate ?? Get.delegate<TDelegate, T>()!; |
16 | 16 | ||
17 | RouterOutlet({ | 17 | RouterOutlet({ |
18 | + Key? key, | ||
18 | TDelegate? delegate, | 19 | TDelegate? delegate, |
19 | required Iterable<GetPage> Function(T currentNavStack) pickPages, | 20 | required Iterable<GetPage> Function(T currentNavStack) pickPages, |
20 | required Widget Function( | 21 | required Widget Function( |
@@ -24,6 +25,7 @@ class RouterOutlet<TDelegate extends RouterDelegate<T>, T extends Object> | @@ -24,6 +25,7 @@ class RouterOutlet<TDelegate extends RouterDelegate<T>, T extends Object> | ||
24 | ) | 25 | ) |
25 | pageBuilder, | 26 | pageBuilder, |
26 | }) : this.builder( | 27 | }) : this.builder( |
28 | + key: key, | ||
27 | builder: (context) { | 29 | builder: (context) { |
28 | final currentConfig = context.delegate.currentConfiguration as T?; | 30 | final currentConfig = context.delegate.currentConfiguration as T?; |
29 | final rDelegate = context.delegate as TDelegate; | 31 | final rDelegate = context.delegate as TDelegate; |
@@ -37,11 +39,11 @@ class RouterOutlet<TDelegate extends RouterDelegate<T>, T extends Object> | @@ -37,11 +39,11 @@ class RouterOutlet<TDelegate extends RouterDelegate<T>, T extends Object> | ||
37 | delegate: delegate, | 39 | delegate: delegate, |
38 | ); | 40 | ); |
39 | @override | 41 | @override |
40 | - _RouterOutletState<TDelegate, T> createState() => | ||
41 | - _RouterOutletState<TDelegate, T>(); | 42 | + RouterOutletState<TDelegate, T> createState() => |
43 | + RouterOutletState<TDelegate, T>(); | ||
42 | } | 44 | } |
43 | 45 | ||
44 | -class _RouterOutletState<TDelegate extends RouterDelegate<T>, T extends Object> | 46 | +class RouterOutletState<TDelegate extends RouterDelegate<T>, T extends Object> |
45 | extends State<RouterOutlet<TDelegate, T>> { | 47 | extends State<RouterOutlet<TDelegate, T>> { |
46 | RouterDelegate? delegate; | 48 | RouterDelegate? delegate; |
47 | late ChildBackButtonDispatcher _backButtonDispatcher; | 49 | late ChildBackButtonDispatcher _backButtonDispatcher; |
@@ -80,7 +82,7 @@ class _RouterOutletState<TDelegate extends RouterDelegate<T>, T extends Object> | @@ -80,7 +82,7 @@ class _RouterOutletState<TDelegate extends RouterDelegate<T>, T extends Object> | ||
80 | } | 82 | } |
81 | } | 83 | } |
82 | 84 | ||
83 | -// class _RouterOutletState<TDelegate extends RouterDelegate<T>, | 85 | +// class RouterOutletState<TDelegate extends RouterDelegate<T>, |
84 | //T extends Object> | 86 | //T extends Object> |
85 | // extends State<RouterOutlet<TDelegate, T>> { | 87 | // extends State<RouterOutlet<TDelegate, T>> { |
86 | // TDelegate get delegate => context.delegate as TDelegate; | 88 | // TDelegate get delegate => context.delegate as TDelegate; |
@@ -152,11 +154,11 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, RouteDecoder> { | @@ -152,11 +154,11 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, RouteDecoder> { | ||
152 | delegate: delegate, | 154 | delegate: delegate, |
153 | ); | 155 | ); |
154 | GetRouterOutlet.pickPages({ | 156 | GetRouterOutlet.pickPages({ |
157 | + super.key, | ||
155 | Widget Function(GetDelegate delegate)? emptyWidget, | 158 | Widget Function(GetDelegate delegate)? emptyWidget, |
156 | GetPage Function(GetDelegate delegate)? emptyPage, | 159 | GetPage Function(GetDelegate delegate)? emptyPage, |
157 | required Iterable<GetPage> Function(RouteDecoder currentNavStack) pickPages, | 160 | required Iterable<GetPage> Function(RouteDecoder currentNavStack) pickPages, |
158 | bool Function(Route<dynamic>, dynamic)? onPopPage, | 161 | bool Function(Route<dynamic>, dynamic)? onPopPage, |
159 | - GlobalKey<NavigatorState>? key, | ||
160 | GetDelegate? delegate, | 162 | GetDelegate? delegate, |
161 | }) : super( | 163 | }) : super( |
162 | pageBuilder: (context, rDelegate, pages) { | 164 | pageBuilder: (context, rDelegate, pages) { |
@@ -179,13 +181,14 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, RouteDecoder> { | @@ -179,13 +181,14 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, RouteDecoder> { | ||
179 | key: key, | 181 | key: key, |
180 | ); | 182 | ); |
181 | } | 183 | } |
182 | - return (emptyWidget?.call(rDelegate) ?? SizedBox.shrink()); | 184 | + return (emptyWidget?.call(rDelegate) ?? const SizedBox.shrink()); |
183 | }, | 185 | }, |
184 | pickPages: pickPages, | 186 | pickPages: pickPages, |
185 | delegate: delegate ?? Get.rootController.rootDelegate, | 187 | delegate: delegate ?? Get.rootController.rootDelegate, |
186 | ); | 188 | ); |
187 | 189 | ||
188 | GetRouterOutlet.builder({ | 190 | GetRouterOutlet.builder({ |
191 | + super.key, | ||
189 | required Widget Function( | 192 | required Widget Function( |
190 | BuildContext context, | 193 | BuildContext context, |
191 | ) | 194 | ) |
@@ -12,7 +12,7 @@ typedef SnackbarStatusCallback = void Function(SnackbarStatus? status); | @@ -12,7 +12,7 @@ typedef SnackbarStatusCallback = void Function(SnackbarStatus? status); | ||
12 | 12 | ||
13 | @Deprecated('use GetSnackBar') | 13 | @Deprecated('use GetSnackBar') |
14 | class GetBar extends GetSnackBar { | 14 | class GetBar extends GetSnackBar { |
15 | - GetBar({ | 15 | + const GetBar({ |
16 | Key? key, | 16 | Key? key, |
17 | String? title, | 17 | String? title, |
18 | String? message, | 18 | String? message, |
@@ -293,11 +293,11 @@ class GetSnackBarState extends State<GetSnackBar> | @@ -293,11 +293,11 @@ class GetSnackBarState extends State<GetSnackBar> | ||
293 | AnimationController? _fadeController; | 293 | AnimationController? _fadeController; |
294 | late Animation<double> _fadeAnimation; | 294 | late Animation<double> _fadeAnimation; |
295 | 295 | ||
296 | - final Widget _emptyWidget = SizedBox(width: 0.0, height: 0.0); | 296 | + final Widget _emptyWidget = const SizedBox(width: 0.0, height: 0.0); |
297 | final double _initialOpacity = 1.0; | 297 | final double _initialOpacity = 1.0; |
298 | final double _finalOpacity = 0.4; | 298 | final double _finalOpacity = 0.4; |
299 | 299 | ||
300 | - final Duration _pulseAnimationDuration = Duration(seconds: 1); | 300 | + final Duration _pulseAnimationDuration = const Duration(seconds: 1); |
301 | 301 | ||
302 | late bool _isTitlePresent; | 302 | late bool _isTitlePresent; |
303 | late double _messageTopMargin; | 303 | late double _messageTopMargin; |
@@ -513,9 +513,9 @@ You need to either use message[String], or messageText[Widget] or define a userI | @@ -513,9 +513,9 @@ You need to either use message[String], or messageText[Widget] or define a userI | ||
513 | padding: const EdgeInsets.only( | 513 | padding: const EdgeInsets.only( |
514 | left: 8.0, right: 8.0, bottom: 8.0, top: 16.0), | 514 | left: 8.0, right: 8.0, bottom: 8.0, top: 16.0), |
515 | child: FocusScope( | 515 | child: FocusScope( |
516 | - child: widget.userInputForm!, | ||
517 | node: _focusNode, | 516 | node: _focusNode, |
518 | autofocus: true, | 517 | autofocus: true, |
518 | + child: widget.userInputForm!, | ||
519 | ), | 519 | ), |
520 | ), | 520 | ), |
521 | ); | 521 | ); |
@@ -581,7 +581,7 @@ You need to either use message[String], or messageText[Widget] or define a userI | @@ -581,7 +581,7 @@ You need to either use message[String], or messageText[Widget] or define a userI | ||
581 | child: widget.titleText ?? | 581 | child: widget.titleText ?? |
582 | Text( | 582 | Text( |
583 | widget.title ?? "", | 583 | widget.title ?? "", |
584 | - style: TextStyle( | 584 | + style: const TextStyle( |
585 | fontSize: 16.0, | 585 | fontSize: 16.0, |
586 | color: Colors.white, | 586 | color: Colors.white, |
587 | fontWeight: FontWeight.bold, | 587 | fontWeight: FontWeight.bold, |
@@ -600,8 +600,8 @@ You need to either use message[String], or messageText[Widget] or define a userI | @@ -600,8 +600,8 @@ You need to either use message[String], or messageText[Widget] or define a userI | ||
600 | child: widget.messageText ?? | 600 | child: widget.messageText ?? |
601 | Text( | 601 | Text( |
602 | widget.message ?? "", | 602 | widget.message ?? "", |
603 | - style: | ||
604 | - TextStyle(fontSize: 14.0, color: Colors.white), | 603 | + style: const TextStyle( |
604 | + fontSize: 14.0, color: Colors.white), | ||
605 | ), | 605 | ), |
606 | ), | 606 | ), |
607 | ], | 607 | ], |
@@ -220,15 +220,15 @@ class SnackbarController { | @@ -220,15 +220,15 @@ class SnackbarController { | ||
220 | ], | 220 | ], |
221 | OverlayEntry( | 221 | OverlayEntry( |
222 | builder: (context) => Semantics( | 222 | builder: (context) => Semantics( |
223 | + focused: false, | ||
224 | + container: true, | ||
225 | + explicitChildNodes: true, | ||
223 | child: AlignTransition( | 226 | child: AlignTransition( |
224 | alignment: _animation, | 227 | alignment: _animation, |
225 | child: snackbar.isDismissible | 228 | child: snackbar.isDismissible |
226 | ? _getDismissibleSnack(child) | 229 | ? _getDismissibleSnack(child) |
227 | : _getSnackbarContainer(child), | 230 | : _getSnackbarContainer(child), |
228 | ), | 231 | ), |
229 | - focused: false, | ||
230 | - container: true, | ||
231 | - explicitChildNodes: true, | ||
232 | ), | 232 | ), |
233 | maintainState: false, | 233 | maintainState: false, |
234 | opaque: false, | 234 | opaque: false, |
@@ -239,10 +239,10 @@ class SnackbarController { | @@ -239,10 +239,10 @@ class SnackbarController { | ||
239 | Widget _getBodyWidget() { | 239 | Widget _getBodyWidget() { |
240 | return Builder(builder: (_) { | 240 | return Builder(builder: (_) { |
241 | return GestureDetector( | 241 | return GestureDetector( |
242 | - child: snackbar, | ||
243 | onTap: snackbar.onTap != null | 242 | onTap: snackbar.onTap != null |
244 | ? () => snackbar.onTap?.call(snackbar) | 243 | ? () => snackbar.onTap?.call(snackbar) |
245 | : null, | 244 | : null, |
245 | + child: snackbar, | ||
246 | ); | 246 | ); |
247 | }); | 247 | }); |
248 | } | 248 | } |
@@ -226,11 +226,11 @@ Worker debounce<T>( | @@ -226,11 +226,11 @@ Worker debounce<T>( | ||
226 | void Function()? onDone, | 226 | void Function()? onDone, |
227 | bool? cancelOnError, | 227 | bool? cancelOnError, |
228 | }) { | 228 | }) { |
229 | - final _debouncer = | 229 | + final newDebouncer = |
230 | Debouncer(delay: time ?? const Duration(milliseconds: 800)); | 230 | Debouncer(delay: time ?? const Duration(milliseconds: 800)); |
231 | StreamSubscription sub = listener.listen( | 231 | StreamSubscription sub = listener.listen( |
232 | (event) { | 232 | (event) { |
233 | - _debouncer(() { | 233 | + newDebouncer(() { |
234 | callback(event); | 234 | callback(event); |
235 | }); | 235 | }); |
236 | }, | 236 | }, |
@@ -22,6 +22,7 @@ class GetX<T extends GetLifeCycleMixin> extends StatefulWidget { | @@ -22,6 +22,7 @@ class GetX<T extends GetLifeCycleMixin> extends StatefulWidget { | ||
22 | final String? tag; | 22 | final String? tag; |
23 | 23 | ||
24 | const GetX({ | 24 | const GetX({ |
25 | + super.key, | ||
25 | this.tag, | 26 | this.tag, |
26 | required this.builder, | 27 | required this.builder, |
27 | this.global = true, | 28 | this.global = true, |
@@ -32,7 +32,7 @@ mixin StateMixin<T> on ListNotifier { | @@ -32,7 +32,7 @@ mixin StateMixin<T> on ListNotifier { | ||
32 | void _fillInitialStatus() { | 32 | void _fillInitialStatus() { |
33 | _status = (_value == null || _value!._isEmpty()) | 33 | _status = (_value == null || _value!._isEmpty()) |
34 | ? GetStatus<T>.loading() | 34 | ? GetStatus<T>.loading() |
35 | - : GetStatus<T>.success(_value!); | 35 | + : GetStatus<T>.success(_value as T); |
36 | } | 36 | } |
37 | 37 | ||
38 | GetStatus<T> get status { | 38 | GetStatus<T> get status { |
@@ -231,12 +231,12 @@ extension StateExt<T> on StateMixin<T> { | @@ -231,12 +231,12 @@ extension StateExt<T> on StateMixin<T> { | ||
231 | : Center(child: Text('A error occurred: ${status.errorMessage}')); | 231 | : Center(child: Text('A error occurred: ${status.errorMessage}')); |
232 | } else if (status.isEmpty) { | 232 | } else if (status.isEmpty) { |
233 | return onEmpty ?? | 233 | return onEmpty ?? |
234 | - SizedBox.shrink(); // Also can be widget(null); but is risky | 234 | + const SizedBox.shrink(); // Also can be widget(null); but is risky |
235 | } else if (status.isSuccess) { | 235 | } else if (status.isSuccess) { |
236 | return widget(value); | 236 | return widget(value); |
237 | } else if (status.isCustom) { | 237 | } else if (status.isCustom) { |
238 | return onCustom?.call(_) ?? | 238 | return onCustom?.call(_) ?? |
239 | - SizedBox.shrink(); // Also can be widget(null); but is risky | 239 | + const SizedBox.shrink(); // Also can be widget(null); but is risky |
240 | } | 240 | } |
241 | return widget(value); | 241 | return widget(value); |
242 | }); | 242 | }); |
@@ -24,7 +24,7 @@ abstract class ObxWidget extends ObxStatelessWidget { | @@ -24,7 +24,7 @@ abstract class ObxWidget extends ObxStatelessWidget { | ||
24 | class Obx extends ObxWidget { | 24 | class Obx extends ObxWidget { |
25 | final WidgetCallback builder; | 25 | final WidgetCallback builder; |
26 | 26 | ||
27 | - const Obx(this.builder); | 27 | + const Obx(this.builder, {super.key}); |
28 | 28 | ||
29 | @override | 29 | @override |
30 | Widget build(BuildContext context) { | 30 | Widget build(BuildContext context) { |
@@ -482,7 +482,7 @@ class BindElement<T> extends InheritedElement { | @@ -482,7 +482,7 @@ class BindElement<T> extends InheritedElement { | ||
482 | /// setState "link" from the Controller. | 482 | /// setState "link" from the Controller. |
483 | void _subscribeToController() { | 483 | void _subscribeToController() { |
484 | if (widget.filter != null) { | 484 | if (widget.filter != null) { |
485 | - _filter = widget.filter!(_controller!); | 485 | + _filter = widget.filter!(_controller as T); |
486 | } | 486 | } |
487 | final filter = _filter != null ? _filterUpdate : getUpdate; | 487 | final filter = _filter != null ? _filterUpdate : getUpdate; |
488 | final localController = _controller; | 488 | final localController = _controller; |
@@ -510,7 +510,7 @@ class BindElement<T> extends InheritedElement { | @@ -510,7 +510,7 @@ class BindElement<T> extends InheritedElement { | ||
510 | } | 510 | } |
511 | 511 | ||
512 | void _filterUpdate() { | 512 | void _filterUpdate() { |
513 | - var newFilter = widget.filter!(_controller!); | 513 | + var newFilter = widget.filter!(_controller as T); |
514 | if (newFilter != _filter) { | 514 | if (newFilter != _filter) { |
515 | _filter = newFilter; | 515 | _filter = newFilter; |
516 | getUpdate(); | 516 | getUpdate(); |
@@ -176,11 +176,11 @@ class Notifier { | @@ -176,11 +176,11 @@ class Notifier { | ||
176 | _notifyData?.disposers.add(listener); | 176 | _notifyData?.disposers.add(listener); |
177 | } | 177 | } |
178 | 178 | ||
179 | - void read(ListNotifierSingleMixin _updaters) { | 179 | + void read(ListNotifierSingleMixin updaters) { |
180 | final listener = _notifyData?.updater; | 180 | final listener = _notifyData?.updater; |
181 | - if (listener != null && !_updaters.containsListener(listener)) { | ||
182 | - _updaters.addListener(listener); | ||
183 | - add(() => _updaters.removeListener(listener)); | 181 | + if (listener != null && !updaters.containsListener(listener)) { |
182 | + updaters.addListener(listener); | ||
183 | + add(() => updaters.removeListener(listener)); | ||
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
@@ -188,7 +188,7 @@ class Notifier { | @@ -188,7 +188,7 @@ class Notifier { | ||
188 | _notifyData = data; | 188 | _notifyData = data; |
189 | final result = builder(); | 189 | final result = builder(); |
190 | if (data.disposers.isEmpty && data.throwException) { | 190 | if (data.disposers.isEmpty && data.throwException) { |
191 | - throw ObxError(); | 191 | + throw const ObxError(); |
192 | } | 192 | } |
193 | _notifyData = null; | 193 | _notifyData = null; |
194 | return result; | 194 | return result; |
@@ -38,12 +38,16 @@ class ValueBuilder<T> extends StatefulWidget { | @@ -38,12 +38,16 @@ class ValueBuilder<T> extends StatefulWidget { | ||
38 | }) : super(key: key); | 38 | }) : super(key: key); |
39 | 39 | ||
40 | @override | 40 | @override |
41 | - _ValueBuilderState<T> createState() => _ValueBuilderState<T>(initialValue); | 41 | + ValueBuilderState<T> createState() => ValueBuilderState<T>(); |
42 | } | 42 | } |
43 | 43 | ||
44 | -class _ValueBuilderState<T> extends State<ValueBuilder<T>> { | ||
45 | - T value; | ||
46 | - _ValueBuilderState(this.value); | 44 | +class ValueBuilderState<T> extends State<ValueBuilder<T>> { |
45 | + late T value; | ||
46 | + @override | ||
47 | + void initState() { | ||
48 | + value = widget.initialValue; | ||
49 | + super.initState(); | ||
50 | + } | ||
47 | 51 | ||
48 | @override | 52 | @override |
49 | Widget build(BuildContext context) => widget.builder(value, updater); | 53 | Widget build(BuildContext context) => widget.builder(value, updater); |
1 | import 'dart:math'; | 1 | import 'dart:math'; |
2 | 2 | ||
3 | -extension Precision on double { | 3 | +extension DoubleExt on double { |
4 | double toPrecision(int fractionDigits) { | 4 | double toPrecision(int fractionDigits) { |
5 | var mod = pow(10, fractionDigits.toDouble()).toDouble(); | 5 | var mod = pow(10, fractionDigits.toDouble()).toDouble(); |
6 | return ((this * mod).round().toDouble() / mod); | 6 | return ((this * mod).round().toDouble() / mod); |
7 | } | 7 | } |
8 | + | ||
9 | + Duration get milliseconds => Duration(microseconds: (this * 1000).round()); | ||
10 | + | ||
11 | + Duration get ms => milliseconds; | ||
12 | + | ||
13 | + Duration get seconds => Duration(milliseconds: (this * 1000).round()); | ||
14 | + | ||
15 | + Duration get minutes => | ||
16 | + Duration(seconds: (this * Duration.secondsPerMinute).round()); | ||
17 | + | ||
18 | + Duration get hours => | ||
19 | + Duration(minutes: (this * Duration.minutesPerHour).round()); | ||
20 | + | ||
21 | + Duration get days => Duration(hours: (this * Duration.hoursPerDay).round()); | ||
8 | } | 22 | } |
@@ -3,6 +3,7 @@ export 'double_extensions.dart'; | @@ -3,6 +3,7 @@ export 'double_extensions.dart'; | ||
3 | export 'duration_extensions.dart'; | 3 | export 'duration_extensions.dart'; |
4 | export 'dynamic_extensions.dart'; | 4 | export 'dynamic_extensions.dart'; |
5 | export 'event_loop_extensions.dart'; | 5 | export 'event_loop_extensions.dart'; |
6 | +export 'int_extensions.dart'; | ||
6 | export 'internacionalization.dart' hide FirstWhereExt; | 7 | export 'internacionalization.dart' hide FirstWhereExt; |
7 | export 'iterable_extensions.dart'; | 8 | export 'iterable_extensions.dart'; |
8 | export 'num_extensions.dart'; | 9 | export 'num_extensions.dart'; |
1 | +extension DurationExt on int { | ||
2 | + Duration get seconds => Duration(seconds: this); | ||
3 | + | ||
4 | + Duration get days => Duration(days: this); | ||
5 | + | ||
6 | + Duration get hours => Duration(hours: this); | ||
7 | + | ||
8 | + Duration get minutes => Duration(minutes: this); | ||
9 | + | ||
10 | + Duration get milliseconds => Duration(milliseconds: this); | ||
11 | + | ||
12 | + Duration get microseconds => Duration(microseconds: this); | ||
13 | + | ||
14 | + Duration get ms => milliseconds; | ||
15 | +} |
@@ -28,40 +28,4 @@ extension GetNumUtils on num { | @@ -28,40 +28,4 @@ extension GetNumUtils on num { | ||
28 | Duration(milliseconds: (this * 1000).round()), | 28 | Duration(milliseconds: (this * 1000).round()), |
29 | callback, | 29 | callback, |
30 | ); | 30 | ); |
31 | - | ||
32 | - /// Easy way to make Durations from numbers. | ||
33 | - /// | ||
34 | - /// Sample: | ||
35 | - /// ``` | ||
36 | - /// print(1.seconds + 200.milliseconds); | ||
37 | - /// print(1.hours + 30.minutes); | ||
38 | - /// print(1.5.hours); | ||
39 | - ///``` | ||
40 | - Duration get milliseconds => Duration(microseconds: (this * 1000).round()); | ||
41 | - | ||
42 | - Duration get seconds => Duration(milliseconds: (this * 1000).round()); | ||
43 | - | ||
44 | - Duration get minutes => | ||
45 | - Duration(seconds: (this * Duration.secondsPerMinute).round()); | ||
46 | - | ||
47 | - Duration get hours => | ||
48 | - Duration(minutes: (this * Duration.minutesPerHour).round()); | ||
49 | - | ||
50 | - Duration get days => Duration(hours: (this * Duration.hoursPerDay).round()); | ||
51 | - | ||
52 | -//final _delayMaps = <Function, Future>{}; | ||
53 | -// TODO: create a proper Future and control the Timer. | ||
54 | -// Future delay([double seconds = 0, VoidCallback callback]) async { | ||
55 | -// final ms = (seconds * 1000).round(); | ||
56 | -// return Future.delayed(Duration(milliseconds: ms), callback); | ||
57 | -// return _delayMaps[callback]; | ||
58 | -// } | ||
59 | -//killDelay(VoidCallback callback) { | ||
60 | -// if (_delayMaps.containsKey(callback)) { | ||
61 | -// _delayMaps[callback]?.timeout(Duration.zero, onTimeout: () { | ||
62 | -// print('callbacl eliminado!'); | ||
63 | -// }); | ||
64 | -// _delayMaps.remove(callback); | ||
65 | -// } | ||
66 | -//} | ||
67 | } | 31 | } |
@@ -6,6 +6,11 @@ import 'package:get/state_manager.dart'; | @@ -6,6 +6,11 @@ import 'package:get/state_manager.dart'; | ||
6 | 6 | ||
7 | int times = 30; | 7 | int times = 30; |
8 | 8 | ||
9 | +void printValue(String value) { | ||
10 | + // ignore: avoid_print | ||
11 | + print(value); | ||
12 | +} | ||
13 | + | ||
9 | Future<int> valueNotifier() { | 14 | Future<int> valueNotifier() { |
10 | final c = Completer<int>(); | 15 | final c = Completer<int>(); |
11 | final value = ValueNotifier<int>(0); | 16 | final value = ValueNotifier<int>(0); |
@@ -15,7 +20,7 @@ Future<int> valueNotifier() { | @@ -15,7 +20,7 @@ Future<int> valueNotifier() { | ||
15 | value.addListener(() { | 20 | value.addListener(() { |
16 | if (times == value.value) { | 21 | if (times == value.value) { |
17 | timer.stop(); | 22 | timer.stop(); |
18 | - print( | 23 | + printValue( |
19 | """${value.value} listeners notified | [VALUE_NOTIFIER] time: ${timer.elapsedMicroseconds}ms"""); | 24 | """${value.value} listeners notified | [VALUE_NOTIFIER] time: ${timer.elapsedMicroseconds}ms"""); |
20 | c.complete(timer.elapsedMicroseconds); | 25 | c.complete(timer.elapsedMicroseconds); |
21 | } | 26 | } |
@@ -37,7 +42,7 @@ Future<int> getValue() { | @@ -37,7 +42,7 @@ Future<int> getValue() { | ||
37 | value.addListener(() { | 42 | value.addListener(() { |
38 | if (times == value.value) { | 43 | if (times == value.value) { |
39 | timer.stop(); | 44 | timer.stop(); |
40 | - print( | 45 | + printValue( |
41 | """${value.value} listeners notified | [GETX_VALUE] time: ${timer.elapsedMicroseconds}ms"""); | 46 | """${value.value} listeners notified | [GETX_VALUE] time: ${timer.elapsedMicroseconds}ms"""); |
42 | c.complete(timer.elapsedMicroseconds); | 47 | c.complete(timer.elapsedMicroseconds); |
43 | } | 48 | } |
@@ -60,7 +65,7 @@ Future<int> stream() { | @@ -60,7 +65,7 @@ Future<int> stream() { | ||
60 | value.stream.listen((v) { | 65 | value.stream.listen((v) { |
61 | if (times == v) { | 66 | if (times == v) { |
62 | timer.stop(); | 67 | timer.stop(); |
63 | - print( | 68 | + printValue( |
64 | """$v listeners notified | [STREAM] time: ${timer.elapsedMicroseconds}ms"""); | 69 | """$v listeners notified | [STREAM] time: ${timer.elapsedMicroseconds}ms"""); |
65 | c.complete(timer.elapsedMicroseconds); | 70 | c.complete(timer.elapsedMicroseconds); |
66 | value.close(); | 71 | value.close(); |
@@ -84,7 +89,7 @@ Future<int> stream() { | @@ -84,7 +89,7 @@ Future<int> stream() { | ||
84 | // value.listen((v) { | 89 | // value.listen((v) { |
85 | // if (times == v) { | 90 | // if (times == v) { |
86 | // timer.stop(); | 91 | // timer.stop(); |
87 | -// print( | 92 | +// printValue( |
88 | // """$v listeners notified | | 93 | // """$v listeners notified | |
89 | // [GET_STREAM] time: ${timer.elapsedMicroseconds}ms"""); | 94 | // [GET_STREAM] time: ${timer.elapsedMicroseconds}ms"""); |
90 | // c.complete(timer.elapsedMicroseconds); | 95 | // c.complete(timer.elapsedMicroseconds); |
@@ -108,7 +113,7 @@ Future<int> miniStream() { | @@ -108,7 +113,7 @@ Future<int> miniStream() { | ||
108 | value.listen((v) { | 113 | value.listen((v) { |
109 | if (times == v) { | 114 | if (times == v) { |
110 | timer.stop(); | 115 | timer.stop(); |
111 | - print( | 116 | + printValue( |
112 | """$v listeners notified | [MINI_STREAM] time: ${timer.elapsedMicroseconds}ms"""); | 117 | """$v listeners notified | [MINI_STREAM] time: ${timer.elapsedMicroseconds}ms"""); |
113 | c.complete(timer.elapsedMicroseconds); | 118 | c.complete(timer.elapsedMicroseconds); |
114 | } | 119 | } |
@@ -123,49 +128,49 @@ Future<int> miniStream() { | @@ -123,49 +128,49 @@ Future<int> miniStream() { | ||
123 | 128 | ||
124 | void main() { | 129 | void main() { |
125 | test('percentage test', () { | 130 | test('percentage test', () { |
126 | - print('============================================'); | ||
127 | - print('PERCENTAGE TEST'); | 131 | + printValue('============================================'); |
132 | + printValue('PERCENTAGE TEST'); | ||
128 | 133 | ||
129 | - final referenceValue = 200; | ||
130 | - final requestedValue = 100; | 134 | + const referenceValue = 200; |
135 | + const requestedValue = 100; | ||
131 | 136 | ||
132 | - print(''' | 137 | + printValue(''' |
133 | referenceValue is ${calculePercentage(referenceValue, requestedValue)}% more than requestedValue'''); | 138 | referenceValue is ${calculePercentage(referenceValue, requestedValue)}% more than requestedValue'''); |
134 | expect(calculePercentage(referenceValue, requestedValue), 100); | 139 | expect(calculePercentage(referenceValue, requestedValue), 100); |
135 | }); | 140 | }); |
136 | test('run benchmarks from ValueNotifier', () async { | 141 | test('run benchmarks from ValueNotifier', () async { |
137 | times = 30; | 142 | times = 30; |
138 | - print('============================================'); | ||
139 | - print('VALUE_NOTIFIER X GETX_VALUE TEST'); | ||
140 | - print('-----------'); | 143 | + printValue('============================================'); |
144 | + printValue('VALUE_NOTIFIER X GETX_VALUE TEST'); | ||
145 | + printValue('-----------'); | ||
141 | await getValue(); | 146 | await getValue(); |
142 | await valueNotifier(); | 147 | await valueNotifier(); |
143 | - print('-----------'); | 148 | + printValue('-----------'); |
144 | 149 | ||
145 | times = 30000; | 150 | times = 30000; |
146 | final getx = await getValue(); | 151 | final getx = await getValue(); |
147 | final dart = await valueNotifier(); | 152 | final dart = await valueNotifier(); |
148 | - print('-----------'); | 153 | + printValue('-----------'); |
149 | 154 | ||
150 | - print('ValueNotifier delay $dart ms to made $times requests'); | ||
151 | - print('GetValue delay $getx ms to made $times requests'); | ||
152 | - print('-----------'); | ||
153 | - print(''' | 155 | + printValue('ValueNotifier delay $dart ms to made $times requests'); |
156 | + printValue('GetValue delay $getx ms to made $times requests'); | ||
157 | + printValue('-----------'); | ||
158 | + printValue(''' | ||
154 | GetValue is ${calculePercentage(dart, getx).round()}% faster than Default ValueNotifier with $times requests'''); | 159 | GetValue is ${calculePercentage(dart, getx).round()}% faster than Default ValueNotifier with $times requests'''); |
155 | }); | 160 | }); |
156 | 161 | ||
157 | test('run benchmarks from Streams', () async { | 162 | test('run benchmarks from Streams', () async { |
158 | times = 30; | 163 | times = 30; |
159 | - print('============================================'); | ||
160 | - print('DART STREAM X GET_STREAM X GET_MINI_STREAM TEST'); | ||
161 | - print('-----------'); | 164 | + printValue('============================================'); |
165 | + printValue('DART STREAM X GET_STREAM X GET_MINI_STREAM TEST'); | ||
166 | + printValue('-----------'); | ||
162 | // var getx = await getStream(); | 167 | // var getx = await getStream(); |
163 | var mini = await miniStream(); | 168 | var mini = await miniStream(); |
164 | var dart = await stream(); | 169 | var dart = await stream(); |
165 | - print('-----------'); | ||
166 | - print(''' | 170 | + printValue('-----------'); |
171 | + printValue(''' | ||
167 | GetStream is ${calculePercentage(dart, mini).round()}% faster than Default Stream with $times requests'''); | 172 | GetStream is ${calculePercentage(dart, mini).round()}% faster than Default Stream with $times requests'''); |
168 | - print('-----------'); | 173 | + printValue('-----------'); |
169 | 174 | ||
170 | times = 30000; | 175 | times = 30000; |
171 | dart = await stream(); | 176 | dart = await stream(); |
@@ -176,12 +181,12 @@ GetStream is ${calculePercentage(dart, mini).round()}% faster than Default Strea | @@ -176,12 +181,12 @@ GetStream is ${calculePercentage(dart, mini).round()}% faster than Default Strea | ||
176 | dart = await stream(); | 181 | dart = await stream(); |
177 | // getx = await getStream(); | 182 | // getx = await getStream(); |
178 | mini = await miniStream(); | 183 | mini = await miniStream(); |
179 | - print('-----------'); | ||
180 | - print('dart_stream delay $dart ms to made $times requests'); | ||
181 | - // print('getx_stream delay $getx ms to made $times requests'); | ||
182 | - print('getx_mini_stream delay $mini ms to made $times requests'); | ||
183 | - print('-----------'); | ||
184 | - print(''' | 184 | + printValue('-----------'); |
185 | + printValue('dart_stream delay $dart ms to made $times requests'); | ||
186 | + // printValue('getx_stream delay $getx ms to made $times requests'); | ||
187 | + printValue('getx_mini_stream delay $mini ms to made $times requests'); | ||
188 | + printValue('-----------'); | ||
189 | + printValue(''' | ||
185 | GetStream is ${calculePercentage(dart, mini).round()}% faster than Default Stream with $times requests'''); | 190 | GetStream is ${calculePercentage(dart, mini).round()}% faster than Default Stream with $times requests'''); |
186 | }); | 191 | }); |
187 | } | 192 | } |
@@ -101,7 +101,8 @@ void main() { | @@ -101,7 +101,8 @@ void main() { | ||
101 | 101 | ||
102 | expect(Get.find<Controller>().count, 1); | 102 | expect(Get.find<Controller>().count, 1); |
103 | Get.delete<Controller>(); | 103 | Get.delete<Controller>(); |
104 | - expect(() => Get.find<Controller>(), throwsA(m.TypeMatcher<String>())); | 104 | + expect( |
105 | + () => Get.find<Controller>(), throwsA(const m.TypeMatcher<String>())); | ||
105 | Get.reset(); | 106 | Get.reset(); |
106 | }); | 107 | }); |
107 | 108 | ||
@@ -162,7 +163,7 @@ void main() { | @@ -162,7 +163,7 @@ void main() { | ||
162 | // Get.put(DisposableController()); | 163 | // Get.put(DisposableController()); |
163 | expect(Get.delete<DisposableController>(), true); | 164 | expect(Get.delete<DisposableController>(), true); |
164 | expect(() => Get.find<DisposableController>(), | 165 | expect(() => Get.find<DisposableController>(), |
165 | - throwsA(m.TypeMatcher<String>())); | 166 | + throwsA(const m.TypeMatcher<String>())); |
166 | }); | 167 | }); |
167 | 168 | ||
168 | test('Get.put test after delete with disposable controller and init check', | 169 | test('Get.put test after delete with disposable controller and init check', |
@@ -192,7 +193,7 @@ void main() { | @@ -192,7 +193,7 @@ void main() { | ||
192 | }); | 193 | }); |
193 | 194 | ||
194 | test('tagged temporary', () async { | 195 | test('tagged temporary', () async { |
195 | - final tag = 'tag'; | 196 | + const tag = 'tag'; |
196 | Get.put(DisposableController(), tag: tag); | 197 | Get.put(DisposableController(), tag: tag); |
197 | Get.replace<DisposableController>(Controller(), tag: tag); | 198 | Get.replace<DisposableController>(Controller(), tag: tag); |
198 | final instance = Get.find<DisposableController>(tag: tag); | 199 | final instance = Get.find<DisposableController>(tag: tag); |
@@ -201,7 +202,7 @@ void main() { | @@ -201,7 +202,7 @@ void main() { | ||
201 | }); | 202 | }); |
202 | 203 | ||
203 | test('tagged permanent', () async { | 204 | test('tagged permanent', () async { |
204 | - final tag = 'tag'; | 205 | + const tag = 'tag'; |
205 | Get.put(DisposableController(), permanent: true, tag: tag); | 206 | Get.put(DisposableController(), permanent: true, tag: tag); |
206 | Get.replace<DisposableController>(Controller(), tag: tag); | 207 | Get.replace<DisposableController>(Controller(), tag: tag); |
207 | final instance = Get.find<DisposableController>(tag: tag); | 208 | final instance = Get.find<DisposableController>(tag: tag); |
@@ -210,7 +211,7 @@ void main() { | @@ -210,7 +211,7 @@ void main() { | ||
210 | }); | 211 | }); |
211 | 212 | ||
212 | test('a generic parent type', () async { | 213 | test('a generic parent type', () async { |
213 | - final tag = 'tag'; | 214 | + const tag = 'tag'; |
214 | Get.put<MyController>(DisposableController(), permanent: true, tag: tag); | 215 | Get.put<MyController>(DisposableController(), permanent: true, tag: tag); |
215 | Get.replace<MyController>(Controller(), tag: tag); | 216 | Get.replace<MyController>(Controller(), tag: tag); |
216 | final instance = Get.find<MyController>(tag: tag); | 217 | final instance = Get.find<MyController>(tag: tag); |
@@ -27,10 +27,10 @@ | @@ -27,10 +27,10 @@ | ||
27 | 27 | ||
28 | import 'package:flutter_test/flutter_test.dart'; | 28 | import 'package:flutter_test/flutter_test.dart'; |
29 | 29 | ||
30 | -class _FunctionMatcher<T> extends CustomMatcher { | 30 | +class FunctionMatcher<T> extends CustomMatcher { |
31 | final Object Function(T value) _feature; | 31 | final Object Function(T value) _feature; |
32 | 32 | ||
33 | - _FunctionMatcher(String name, this._feature, matcher) | 33 | + FunctionMatcher(String name, this._feature, matcher) |
34 | : super('`$name`:', '`$name`', matcher); | 34 | : super('`$name`:', '`$name`', matcher); |
35 | 35 | ||
36 | @override | 36 | @override |
@@ -39,15 +39,15 @@ class _FunctionMatcher<T> extends CustomMatcher { | @@ -39,15 +39,15 @@ class _FunctionMatcher<T> extends CustomMatcher { | ||
39 | 39 | ||
40 | class HavingMatcher<T> implements TypeMatcher<T> { | 40 | class HavingMatcher<T> implements TypeMatcher<T> { |
41 | final TypeMatcher<T> _parent; | 41 | final TypeMatcher<T> _parent; |
42 | - final List<_FunctionMatcher<T>> _functionMatchers; | 42 | + final List<FunctionMatcher<T>> _functionMatchers; |
43 | 43 | ||
44 | HavingMatcher(TypeMatcher<T> parent, String description, | 44 | HavingMatcher(TypeMatcher<T> parent, String description, |
45 | Object Function(T) feature, dynamic matcher, | 45 | Object Function(T) feature, dynamic matcher, |
46 | - [Iterable<_FunctionMatcher<T>>? existing]) | 46 | + [Iterable<FunctionMatcher<T>>? existing]) |
47 | : _parent = parent, | 47 | : _parent = parent, |
48 | _functionMatchers = [ | 48 | _functionMatchers = [ |
49 | ...?existing, | 49 | ...?existing, |
50 | - _FunctionMatcher<T>(description, feature, matcher) | 50 | + FunctionMatcher<T>(description, feature, matcher) |
51 | ]; | 51 | ]; |
52 | 52 | ||
53 | @override | 53 | @override |
@@ -16,7 +16,7 @@ void main() { | @@ -16,7 +16,7 @@ void main() { | ||
16 | expect('total_confirmed'.tr, 'Total Confirmed'); | 16 | expect('total_confirmed'.tr, 'Total Confirmed'); |
17 | expect('total_deaths'.tr, 'Total Deaths'); | 17 | expect('total_deaths'.tr, 'Total Deaths'); |
18 | 18 | ||
19 | - Get.updateLocale(Locale('pt', 'BR')); | 19 | + Get.updateLocale(const Locale('pt', 'BR')); |
20 | 20 | ||
21 | await tester.pumpAndSettle(); | 21 | await tester.pumpAndSettle(); |
22 | 22 | ||
@@ -24,7 +24,7 @@ void main() { | @@ -24,7 +24,7 @@ void main() { | ||
24 | expect('total_confirmed'.tr, 'Total confirmado'); | 24 | expect('total_confirmed'.tr, 'Total confirmado'); |
25 | expect('total_deaths'.tr, 'Total de mortes'); | 25 | expect('total_deaths'.tr, 'Total de mortes'); |
26 | 26 | ||
27 | - Get.updateLocale(Locale('en', 'EN')); | 27 | + Get.updateLocale(const Locale('en', 'EN')); |
28 | 28 | ||
29 | await tester.pumpAndSettle(); | 29 | await tester.pumpAndSettle(); |
30 | 30 |
@@ -12,16 +12,14 @@ void main() { | @@ -12,16 +12,14 @@ void main() { | ||
12 | 12 | ||
13 | await tester.pump(); | 13 | await tester.pump(); |
14 | 14 | ||
15 | - Get.bottomSheet(Container( | ||
16 | - child: Wrap( | ||
17 | - children: <Widget>[ | ||
18 | - ListTile( | ||
19 | - leading: Icon(Icons.music_note), | ||
20 | - title: Text('Music'), | ||
21 | - onTap: () {}, | ||
22 | - ), | ||
23 | - ], | ||
24 | - ), | 15 | + Get.bottomSheet(Wrap( |
16 | + children: <Widget>[ | ||
17 | + ListTile( | ||
18 | + leading: const Icon(Icons.music_note), | ||
19 | + title: const Text('Music'), | ||
20 | + onTap: () {}, | ||
21 | + ), | ||
22 | + ], | ||
25 | )); | 23 | )); |
26 | 24 | ||
27 | await tester.pumpAndSettle(); | 25 | await tester.pumpAndSettle(); |
@@ -36,16 +34,14 @@ void main() { | @@ -36,16 +34,14 @@ void main() { | ||
36 | 34 | ||
37 | await tester.pump(); | 35 | await tester.pump(); |
38 | 36 | ||
39 | - Get.bottomSheet(Container( | ||
40 | - child: Wrap( | ||
41 | - children: <Widget>[ | ||
42 | - ListTile( | ||
43 | - leading: Icon(Icons.music_note), | ||
44 | - title: Text('Music'), | ||
45 | - onTap: () {}, | ||
46 | - ), | ||
47 | - ], | ||
48 | - ), | 37 | + Get.bottomSheet(Wrap( |
38 | + children: <Widget>[ | ||
39 | + ListTile( | ||
40 | + leading: const Icon(Icons.music_note), | ||
41 | + title: const Text('Music'), | ||
42 | + onTap: () {}, | ||
43 | + ), | ||
44 | + ], | ||
49 | )); | 45 | )); |
50 | 46 | ||
51 | await tester.pumpAndSettle(); | 47 | await tester.pumpAndSettle(); |
@@ -13,8 +13,7 @@ void main() { | @@ -13,8 +13,7 @@ void main() { | ||
13 | await tester.pump(); | 13 | await tester.pump(); |
14 | 14 | ||
15 | Get.defaultDialog( | 15 | Get.defaultDialog( |
16 | - onConfirm: () => print("Ok"), | ||
17 | - middleText: "Dialog made in 3 lines of code"); | 16 | + onConfirm: () {}, middleText: "Dialog made in 3 lines of code"); |
18 | 17 | ||
19 | await tester.pumpAndSettle(); | 18 | await tester.pumpAndSettle(); |
20 | 19 | ||
@@ -28,7 +27,7 @@ void main() { | @@ -28,7 +27,7 @@ void main() { | ||
28 | 27 | ||
29 | await tester.pump(); | 28 | await tester.pump(); |
30 | 29 | ||
31 | - Get.dialog(YourDialogWidget()); | 30 | + Get.dialog(const YourDialogWidget()); |
32 | 31 | ||
33 | await tester.pumpAndSettle(); | 32 | await tester.pumpAndSettle(); |
34 | 33 | ||
@@ -42,7 +41,7 @@ void main() { | @@ -42,7 +41,7 @@ void main() { | ||
42 | 41 | ||
43 | await tester.pump(); | 42 | await tester.pump(); |
44 | 43 | ||
45 | - Get.dialog(YourDialogWidget()); | 44 | + Get.dialog(const YourDialogWidget()); |
46 | await tester.pumpAndSettle(); | 45 | await tester.pumpAndSettle(); |
47 | 46 | ||
48 | expect(find.byType(YourDialogWidget), findsOneWidget); | 47 | expect(find.byType(YourDialogWidget), findsOneWidget); |
@@ -13,7 +13,7 @@ void main() { | @@ -13,7 +13,7 @@ void main() { | ||
13 | expect(Get.isRegistered<Controller2>(), false); | 13 | expect(Get.isRegistered<Controller2>(), false); |
14 | expect(Get.isRegistered<Controller>(), false); | 14 | expect(Get.isRegistered<Controller>(), false); |
15 | 15 | ||
16 | - Get.to(() => First()); | 16 | + Get.to(() => const First()); |
17 | 17 | ||
18 | await tester.pumpAndSettle(); | 18 | await tester.pumpAndSettle(); |
19 | 19 | ||
@@ -21,7 +21,7 @@ void main() { | @@ -21,7 +21,7 @@ void main() { | ||
21 | 21 | ||
22 | expect(Get.isRegistered<Controller>(), true); | 22 | expect(Get.isRegistered<Controller>(), true); |
23 | 23 | ||
24 | - Get.to(() => Second()); | 24 | + Get.to(() => const Second()); |
25 | 25 | ||
26 | await tester.pumpAndSettle(); | 26 | await tester.pumpAndSettle(); |
27 | 27 | ||
@@ -53,20 +53,24 @@ class Controller extends GetxController {} | @@ -53,20 +53,24 @@ class Controller extends GetxController {} | ||
53 | class Controller2 extends GetxController {} | 53 | class Controller2 extends GetxController {} |
54 | 54 | ||
55 | class First extends StatelessWidget { | 55 | class First extends StatelessWidget { |
56 | + const First({super.key}); | ||
57 | + | ||
56 | @override | 58 | @override |
57 | Widget build(BuildContext context) { | 59 | Widget build(BuildContext context) { |
58 | Get.put(Controller()); | 60 | Get.put(Controller()); |
59 | - return Center( | 61 | + return const Center( |
60 | child: Text("first"), | 62 | child: Text("first"), |
61 | ); | 63 | ); |
62 | } | 64 | } |
63 | } | 65 | } |
64 | 66 | ||
65 | class Second extends StatelessWidget { | 67 | class Second extends StatelessWidget { |
68 | + const Second({super.key}); | ||
69 | + | ||
66 | @override | 70 | @override |
67 | Widget build(BuildContext context) { | 71 | Widget build(BuildContext context) { |
68 | Get.put(Controller2()); | 72 | Get.put(Controller2()); |
69 | - return Center( | 73 | + return const Center( |
70 | child: Text("second"), | 74 | child: Text("second"), |
71 | ); | 75 | ); |
72 | } | 76 | } |
@@ -8,7 +8,7 @@ void main() { | @@ -8,7 +8,7 @@ void main() { | ||
8 | testWidgets("Get.to navigates to provided route", (tester) async { | 8 | testWidgets("Get.to navigates to provided route", (tester) async { |
9 | await tester.pumpWidget(Wrapper(child: Container())); | 9 | await tester.pumpWidget(Wrapper(child: Container())); |
10 | 10 | ||
11 | - Get.to(() => FirstScreen()); | 11 | + Get.to(() => const FirstScreen()); |
12 | 12 | ||
13 | await tester.pumpAndSettle(); | 13 | await tester.pumpAndSettle(); |
14 | 14 | ||
@@ -19,9 +19,9 @@ void main() { | @@ -19,9 +19,9 @@ void main() { | ||
19 | await tester.pumpWidget(GetMaterialApp( | 19 | await tester.pumpWidget(GetMaterialApp( |
20 | initialRoute: '/first', | 20 | initialRoute: '/first', |
21 | getPages: [ | 21 | getPages: [ |
22 | - GetPage(page: () => FirstScreen(), name: '/first'), | ||
23 | - GetPage(page: () => SecondScreen(), name: '/second'), | ||
24 | - GetPage(page: () => ThirdScreen(), name: '/third') | 22 | + GetPage(page: () => const FirstScreen(), name: '/first'), |
23 | + GetPage(page: () => const SecondScreen(), name: '/second'), | ||
24 | + GetPage(page: () => const ThirdScreen(), name: '/third') | ||
25 | ], | 25 | ], |
26 | )); | 26 | )); |
27 | 27 | ||
@@ -35,11 +35,11 @@ void main() { | @@ -35,11 +35,11 @@ void main() { | ||
35 | testWidgets("unknowroute", (tester) async { | 35 | testWidgets("unknowroute", (tester) async { |
36 | await tester.pumpWidget(GetMaterialApp( | 36 | await tester.pumpWidget(GetMaterialApp( |
37 | initialRoute: '/first', | 37 | initialRoute: '/first', |
38 | - unknownRoute: GetPage(name: '/404', page: () => Scaffold()), | 38 | + unknownRoute: GetPage(name: '/404', page: () => const Scaffold()), |
39 | getPages: [ | 39 | getPages: [ |
40 | - GetPage(page: () => FirstScreen(), name: '/first'), | ||
41 | - GetPage(page: () => SecondScreen(), name: '/second'), | ||
42 | - GetPage(page: () => ThirdScreen(), name: '/third') | 40 | + GetPage(page: () => const FirstScreen(), name: '/first'), |
41 | + GetPage(page: () => const SecondScreen(), name: '/second'), | ||
42 | + GetPage(page: () => const ThirdScreen(), name: '/third') | ||
43 | ], | 43 | ], |
44 | )); | 44 | )); |
45 | 45 | ||
@@ -52,10 +52,10 @@ void main() { | @@ -52,10 +52,10 @@ void main() { | ||
52 | }); | 52 | }); |
53 | 53 | ||
54 | testWidgets("Get.off navigates to provided route", (tester) async { | 54 | testWidgets("Get.off navigates to provided route", (tester) async { |
55 | - await tester.pumpWidget(Wrapper(child: FirstScreen())); | 55 | + await tester.pumpWidget(const Wrapper(child: FirstScreen())); |
56 | // await tester.pump(); | 56 | // await tester.pump(); |
57 | 57 | ||
58 | - Get.off(() => SecondScreen()); | 58 | + Get.off(() => const SecondScreen()); |
59 | 59 | ||
60 | await tester.pumpAndSettle(); | 60 | await tester.pumpAndSettle(); |
61 | 61 | ||
@@ -63,10 +63,10 @@ void main() { | @@ -63,10 +63,10 @@ void main() { | ||
63 | }); | 63 | }); |
64 | 64 | ||
65 | testWidgets("Get.off removes current route", (tester) async { | 65 | testWidgets("Get.off removes current route", (tester) async { |
66 | - await tester.pumpWidget(Wrapper(child: FirstScreen())); | 66 | + await tester.pumpWidget(const Wrapper(child: FirstScreen())); |
67 | await tester.pump(); | 67 | await tester.pump(); |
68 | 68 | ||
69 | - Get.off(() => SecondScreen()); | 69 | + Get.off(() => const SecondScreen()); |
70 | Get.back(); | 70 | Get.back(); |
71 | 71 | ||
72 | await tester.pumpAndSettle(); | 72 | await tester.pumpAndSettle(); |
@@ -78,9 +78,9 @@ void main() { | @@ -78,9 +78,9 @@ void main() { | ||
78 | await tester.pumpWidget(GetMaterialApp( | 78 | await tester.pumpWidget(GetMaterialApp( |
79 | initialRoute: '/first', | 79 | initialRoute: '/first', |
80 | getPages: [ | 80 | getPages: [ |
81 | - GetPage(name: '/first', page: () => FirstScreen()), | ||
82 | - GetPage(name: '/second', page: () => SecondScreen()), | ||
83 | - GetPage(name: '/third', page: () => ThirdScreen()), | 81 | + GetPage(name: '/first', page: () => const FirstScreen()), |
82 | + GetPage(name: '/second', page: () => const SecondScreen()), | ||
83 | + GetPage(name: '/third', page: () => const ThirdScreen()), | ||
84 | ], | 84 | ], |
85 | )); | 85 | )); |
86 | 86 | ||
@@ -97,9 +97,9 @@ void main() { | @@ -97,9 +97,9 @@ void main() { | ||
97 | await tester.pumpWidget(GetMaterialApp( | 97 | await tester.pumpWidget(GetMaterialApp( |
98 | initialRoute: '/first', | 98 | initialRoute: '/first', |
99 | getPages: [ | 99 | getPages: [ |
100 | - GetPage(name: '/first', page: () => FirstScreen()), | ||
101 | - GetPage(name: '/second', page: () => SecondScreen()), | ||
102 | - GetPage(name: '/third', page: () => ThirdScreen()), | 100 | + GetPage(name: '/first', page: () => const FirstScreen()), |
101 | + GetPage(name: '/second', page: () => const SecondScreen()), | ||
102 | + GetPage(name: '/third', page: () => const ThirdScreen()), | ||
103 | ], | 103 | ], |
104 | )); | 104 | )); |
105 | 105 | ||
@@ -118,9 +118,9 @@ void main() { | @@ -118,9 +118,9 @@ void main() { | ||
118 | await tester.pumpWidget(GetMaterialApp( | 118 | await tester.pumpWidget(GetMaterialApp( |
119 | initialRoute: '/first', | 119 | initialRoute: '/first', |
120 | getPages: [ | 120 | getPages: [ |
121 | - GetPage(name: '/first', page: () => FirstScreen()), | ||
122 | - GetPage(name: '/second', page: () => SecondScreen()), | ||
123 | - GetPage(name: '/third', page: () => ThirdScreen()), | 121 | + GetPage(name: '/first', page: () => const FirstScreen()), |
122 | + GetPage(name: '/second', page: () => const SecondScreen()), | ||
123 | + GetPage(name: '/third', page: () => const ThirdScreen()), | ||
124 | ], | 124 | ], |
125 | )); | 125 | )); |
126 | 126 | ||
@@ -138,10 +138,10 @@ void main() { | @@ -138,10 +138,10 @@ void main() { | ||
138 | }); | 138 | }); |
139 | 139 | ||
140 | testWidgets("Get.offAll navigates to provided route", (tester) async { | 140 | testWidgets("Get.offAll navigates to provided route", (tester) async { |
141 | - await tester.pumpWidget(Wrapper(child: FirstScreen())); | 141 | + await tester.pumpWidget(const Wrapper(child: FirstScreen())); |
142 | await tester.pump(); | 142 | await tester.pump(); |
143 | 143 | ||
144 | - Get.offAll(() => SecondScreen()); | 144 | + Get.offAll(() => const SecondScreen()); |
145 | 145 | ||
146 | await tester.pumpAndSettle(); | 146 | await tester.pumpAndSettle(); |
147 | 147 | ||
@@ -149,12 +149,12 @@ void main() { | @@ -149,12 +149,12 @@ void main() { | ||
149 | }); | 149 | }); |
150 | 150 | ||
151 | testWidgets("Get.offAll removes all previous routes", (tester) async { | 151 | testWidgets("Get.offAll removes all previous routes", (tester) async { |
152 | - await tester.pumpWidget(Wrapper(child: FirstScreen())); | 152 | + await tester.pumpWidget(const Wrapper(child: FirstScreen())); |
153 | await tester.pump(); | 153 | await tester.pump(); |
154 | 154 | ||
155 | - Get.to(() => SecondScreen()); | 155 | + Get.to(() => const SecondScreen()); |
156 | await tester.pumpAndSettle(); | 156 | await tester.pumpAndSettle(); |
157 | - Get.offAll(() => ThirdScreen()); | 157 | + Get.offAll(() => const ThirdScreen()); |
158 | await tester.pumpAndSettle(); | 158 | await tester.pumpAndSettle(); |
159 | Get.back(); | 159 | Get.back(); |
160 | await tester.pumpAndSettle(); | 160 | await tester.pumpAndSettle(); |
@@ -173,9 +173,9 @@ void main() { | @@ -173,9 +173,9 @@ void main() { | ||
173 | await tester.pumpWidget(WrapperNamed( | 173 | await tester.pumpWidget(WrapperNamed( |
174 | initialRoute: '/first', | 174 | initialRoute: '/first', |
175 | namedRoutes: [ | 175 | namedRoutes: [ |
176 | - GetPage(page: () => FirstScreen(), name: '/first'), | ||
177 | - GetPage(page: () => SecondScreen(), name: '/second'), | ||
178 | - GetPage(page: () => ThirdScreen(), name: '/third') | 176 | + GetPage(page: () => const FirstScreen(), name: '/first'), |
177 | + GetPage(page: () => const SecondScreen(), name: '/second'), | ||
178 | + GetPage(page: () => const ThirdScreen(), name: '/third') | ||
179 | ], | 179 | ], |
180 | )); | 180 | )); |
181 | 181 | ||
@@ -192,9 +192,9 @@ void main() { | @@ -192,9 +192,9 @@ void main() { | ||
192 | await tester.pumpWidget(WrapperNamed( | 192 | await tester.pumpWidget(WrapperNamed( |
193 | initialRoute: '/first', | 193 | initialRoute: '/first', |
194 | namedRoutes: [ | 194 | namedRoutes: [ |
195 | - GetPage(page: () => FirstScreen(), name: '/first'), | ||
196 | - GetPage(page: () => SecondScreen(), name: '/second'), | ||
197 | - GetPage(page: () => ThirdScreen(), name: '/third') | 195 | + GetPage(page: () => const FirstScreen(), name: '/first'), |
196 | + GetPage(page: () => const SecondScreen(), name: '/second'), | ||
197 | + GetPage(page: () => const ThirdScreen(), name: '/third') | ||
198 | ], | 198 | ], |
199 | )); | 199 | )); |
200 | 200 | ||
@@ -220,9 +220,9 @@ void main() { | @@ -220,9 +220,9 @@ void main() { | ||
220 | await tester.pumpWidget(WrapperNamed( | 220 | await tester.pumpWidget(WrapperNamed( |
221 | initialRoute: '/first', | 221 | initialRoute: '/first', |
222 | namedRoutes: [ | 222 | namedRoutes: [ |
223 | - GetPage(page: () => FirstScreen(), name: '/first'), | ||
224 | - GetPage(page: () => SecondScreen(), name: '/second'), | ||
225 | - GetPage(page: () => ThirdScreen(), name: '/third') | 223 | + GetPage(page: () => const FirstScreen(), name: '/first'), |
224 | + GetPage(page: () => const SecondScreen(), name: '/second'), | ||
225 | + GetPage(page: () => const ThirdScreen(), name: '/third') | ||
226 | ], | 226 | ], |
227 | )); | 227 | )); |
228 | 228 | ||
@@ -237,9 +237,9 @@ void main() { | @@ -237,9 +237,9 @@ void main() { | ||
237 | await tester.pumpWidget(WrapperNamed( | 237 | await tester.pumpWidget(WrapperNamed( |
238 | initialRoute: '/first', | 238 | initialRoute: '/first', |
239 | namedRoutes: [ | 239 | namedRoutes: [ |
240 | - GetPage(page: () => FirstScreen(), name: '/first'), | ||
241 | - GetPage(page: () => SecondScreen(), name: '/second'), | ||
242 | - GetPage(page: () => ThirdScreen(), name: '/third') | 240 | + GetPage(page: () => const FirstScreen(), name: '/first'), |
241 | + GetPage(page: () => const SecondScreen(), name: '/second'), | ||
242 | + GetPage(page: () => const ThirdScreen(), name: '/third') | ||
243 | ], | 243 | ], |
244 | )); | 244 | )); |
245 | 245 | ||
@@ -256,11 +256,12 @@ void main() { | @@ -256,11 +256,12 @@ void main() { | ||
256 | testWidgets("Get.offUntil navigates to provided route", (tester) async { | 256 | testWidgets("Get.offUntil navigates to provided route", (tester) async { |
257 | await tester.pumpWidget(Wrapper(child: Container())); | 257 | await tester.pumpWidget(Wrapper(child: Container())); |
258 | 258 | ||
259 | - Get.to(() => FirstScreen()); | 259 | + Get.to(() => const FirstScreen()); |
260 | 260 | ||
261 | await tester.pumpAndSettle(); | 261 | await tester.pumpAndSettle(); |
262 | 262 | ||
263 | - Get.offUntil(() => ThirdScreen(), (route) => route.name == '/FirstScreen'); | 263 | + Get.offUntil( |
264 | + () => const ThirdScreen(), (route) => route.name == '/FirstScreen'); | ||
264 | 265 | ||
265 | await tester.pumpAndSettle(); | 266 | await tester.pumpAndSettle(); |
266 | 267 | ||
@@ -272,11 +273,12 @@ void main() { | @@ -272,11 +273,12 @@ void main() { | ||
272 | (tester) async { | 273 | (tester) async { |
273 | await tester.pumpWidget(Wrapper(child: Container())); | 274 | await tester.pumpWidget(Wrapper(child: Container())); |
274 | 275 | ||
275 | - Get.to(() => FirstScreen()); | 276 | + Get.to(() => const FirstScreen()); |
276 | await tester.pumpAndSettle(); | 277 | await tester.pumpAndSettle(); |
277 | - Get.to(() => SecondScreen()); | 278 | + Get.to(() => const SecondScreen()); |
278 | await tester.pumpAndSettle(); | 279 | await tester.pumpAndSettle(); |
279 | - Get.offUntil(() => ThirdScreen(), (route) => route.name == '/FirstScreen'); | 280 | + Get.offUntil( |
281 | + () => const ThirdScreen(), (route) => route.name == '/FirstScreen'); | ||
280 | await tester.pumpAndSettle(); | 282 | await tester.pumpAndSettle(); |
281 | Get.back(); | 283 | Get.back(); |
282 | 284 | ||
@@ -290,11 +292,12 @@ void main() { | @@ -290,11 +292,12 @@ void main() { | ||
290 | (tester) async { | 292 | (tester) async { |
291 | await tester.pumpWidget(Wrapper(child: Container())); | 293 | await tester.pumpWidget(Wrapper(child: Container())); |
292 | 294 | ||
293 | - Get.to(() => FirstScreen()); | 295 | + Get.to(() => const FirstScreen()); |
294 | await tester.pumpAndSettle(); | 296 | await tester.pumpAndSettle(); |
295 | - Get.to(() => SecondScreen()); | 297 | + Get.to(() => const SecondScreen()); |
296 | await tester.pumpAndSettle(); | 298 | await tester.pumpAndSettle(); |
297 | - Get.offUntil(() => ThirdScreen(), (route) => route.name == '/FirstScreen'); | 299 | + Get.offUntil( |
300 | + () => const ThirdScreen(), (route) => route.name == '/FirstScreen'); | ||
298 | await tester.pumpAndSettle(); | 301 | await tester.pumpAndSettle(); |
299 | Get.back(); | 302 | Get.back(); |
300 | 303 | ||
@@ -307,9 +310,9 @@ void main() { | @@ -307,9 +310,9 @@ void main() { | ||
307 | await tester.pumpWidget(WrapperNamed( | 310 | await tester.pumpWidget(WrapperNamed( |
308 | initialRoute: '/first', | 311 | initialRoute: '/first', |
309 | namedRoutes: [ | 312 | namedRoutes: [ |
310 | - GetPage(page: () => FirstScreen(), name: '/first'), | ||
311 | - GetPage(page: () => SecondScreen(), name: '/second'), | ||
312 | - GetPage(page: () => ThirdScreen(), name: '/third') | 313 | + GetPage(page: () => const FirstScreen(), name: '/first'), |
314 | + GetPage(page: () => const SecondScreen(), name: '/second'), | ||
315 | + GetPage(page: () => const ThirdScreen(), name: '/third') | ||
313 | ], | 316 | ], |
314 | )); | 317 | )); |
315 | 318 | ||
@@ -326,9 +329,9 @@ void main() { | @@ -326,9 +329,9 @@ void main() { | ||
326 | await tester.pumpWidget(WrapperNamed( | 329 | await tester.pumpWidget(WrapperNamed( |
327 | initialRoute: '/first', | 330 | initialRoute: '/first', |
328 | namedRoutes: [ | 331 | namedRoutes: [ |
329 | - GetPage(page: () => FirstScreen(), name: '/first'), | ||
330 | - GetPage(page: () => SecondScreen(), name: '/second'), | ||
331 | - GetPage(page: () => ThirdScreen(), name: '/third') | 332 | + GetPage(page: () => const FirstScreen(), name: '/first'), |
333 | + GetPage(page: () => const SecondScreen(), name: '/second'), | ||
334 | + GetPage(page: () => const ThirdScreen(), name: '/third') | ||
332 | ], | 335 | ], |
333 | )); | 336 | )); |
334 | 337 | ||
@@ -347,9 +350,9 @@ void main() { | @@ -347,9 +350,9 @@ void main() { | ||
347 | await tester.pumpWidget(WrapperNamed( | 350 | await tester.pumpWidget(WrapperNamed( |
348 | initialRoute: '/first', | 351 | initialRoute: '/first', |
349 | namedRoutes: [ | 352 | namedRoutes: [ |
350 | - GetPage(page: () => FirstScreen(), name: '/first'), | ||
351 | - GetPage(page: () => SecondScreen(), name: '/second'), | ||
352 | - GetPage(page: () => ThirdScreen(), name: '/third'), | 353 | + GetPage(page: () => const FirstScreen(), name: '/first'), |
354 | + GetPage(page: () => const SecondScreen(), name: '/second'), | ||
355 | + GetPage(page: () => const ThirdScreen(), name: '/third'), | ||
353 | ], | 356 | ], |
354 | )); | 357 | )); |
355 | 358 | ||
@@ -367,17 +370,17 @@ void main() { | @@ -367,17 +370,17 @@ void main() { | ||
367 | testWidgets("Get.back navigates back", (tester) async { | 370 | testWidgets("Get.back navigates back", (tester) async { |
368 | await tester.pumpWidget( | 371 | await tester.pumpWidget( |
369 | Wrapper( | 372 | Wrapper( |
370 | - child: Container(), | ||
371 | defaultTransition: Transition.circularReveal, | 373 | defaultTransition: Transition.circularReveal, |
374 | + child: Container(), | ||
372 | ), | 375 | ), |
373 | ); | 376 | ); |
374 | 377 | ||
375 | // await tester.pump(); | 378 | // await tester.pump(); |
376 | 379 | ||
377 | - Get.to(() => FirstScreen()); | 380 | + Get.to(() => const FirstScreen()); |
378 | await tester.pumpAndSettle(); | 381 | await tester.pumpAndSettle(); |
379 | 382 | ||
380 | - Get.to(() => SecondScreen()); | 383 | + Get.to(() => const SecondScreen()); |
381 | await tester.pumpAndSettle(); | 384 | await tester.pumpAndSettle(); |
382 | Get.back(); | 385 | Get.back(); |
383 | 386 | ||
@@ -391,16 +394,16 @@ void main() { | @@ -391,16 +394,16 @@ void main() { | ||
391 | (tester) async { | 394 | (tester) async { |
392 | await tester.pumpWidget( | 395 | await tester.pumpWidget( |
393 | Wrapper( | 396 | Wrapper( |
394 | - child: Container(), | ||
395 | defaultTransition: Transition.circularReveal, | 397 | defaultTransition: Transition.circularReveal, |
398 | + child: Container(), | ||
396 | ), | 399 | ), |
397 | ); | 400 | ); |
398 | 401 | ||
399 | // await tester.pump(); | 402 | // await tester.pump(); |
400 | 403 | ||
401 | - Get.to(() => FirstScreen()); | 404 | + Get.to(() => const FirstScreen()); |
402 | await tester.pumpAndSettle(); | 405 | await tester.pumpAndSettle(); |
403 | - Get.to(() => SecondScreen()); | 406 | + Get.to(() => const SecondScreen()); |
404 | await tester.pumpAndSettle(); | 407 | await tester.pumpAndSettle(); |
405 | Get.snackbar('title', "message"); | 408 | Get.snackbar('title', "message"); |
406 | await tester.pumpAndSettle(); | 409 | await tester.pumpAndSettle(); |
@@ -417,12 +420,12 @@ void main() { | @@ -417,12 +420,12 @@ void main() { | ||
417 | testWidgets("fadeIn", (tester) async { | 420 | testWidgets("fadeIn", (tester) async { |
418 | await tester.pumpWidget( | 421 | await tester.pumpWidget( |
419 | Wrapper( | 422 | Wrapper( |
420 | - child: Container(), | ||
421 | defaultTransition: Transition.fadeIn, | 423 | defaultTransition: Transition.fadeIn, |
424 | + child: Container(), | ||
422 | ), | 425 | ), |
423 | ); | 426 | ); |
424 | 427 | ||
425 | - Get.to(() => FirstScreen()); | 428 | + Get.to(() => const FirstScreen()); |
426 | 429 | ||
427 | await tester.pumpAndSettle(); | 430 | await tester.pumpAndSettle(); |
428 | 431 | ||
@@ -432,12 +435,12 @@ void main() { | @@ -432,12 +435,12 @@ void main() { | ||
432 | testWidgets("downToUp", (tester) async { | 435 | testWidgets("downToUp", (tester) async { |
433 | await tester.pumpWidget( | 436 | await tester.pumpWidget( |
434 | Wrapper( | 437 | Wrapper( |
435 | - child: Container(), | ||
436 | defaultTransition: Transition.downToUp, | 438 | defaultTransition: Transition.downToUp, |
439 | + child: Container(), | ||
437 | ), | 440 | ), |
438 | ); | 441 | ); |
439 | 442 | ||
440 | - Get.to(() => FirstScreen()); | 443 | + Get.to(() => const FirstScreen()); |
441 | 444 | ||
442 | await tester.pumpAndSettle(); | 445 | await tester.pumpAndSettle(); |
443 | 446 | ||
@@ -447,12 +450,12 @@ void main() { | @@ -447,12 +450,12 @@ void main() { | ||
447 | testWidgets("fade", (tester) async { | 450 | testWidgets("fade", (tester) async { |
448 | await tester.pumpWidget( | 451 | await tester.pumpWidget( |
449 | Wrapper( | 452 | Wrapper( |
450 | - child: Container(), | ||
451 | defaultTransition: Transition.fade, | 453 | defaultTransition: Transition.fade, |
454 | + child: Container(), | ||
452 | ), | 455 | ), |
453 | ); | 456 | ); |
454 | 457 | ||
455 | - Get.to(() => FirstScreen()); | 458 | + Get.to(() => const FirstScreen()); |
456 | 459 | ||
457 | await tester.pumpAndSettle(); | 460 | await tester.pumpAndSettle(); |
458 | 461 | ||
@@ -462,12 +465,12 @@ void main() { | @@ -462,12 +465,12 @@ void main() { | ||
462 | testWidgets("leftToRight", (tester) async { | 465 | testWidgets("leftToRight", (tester) async { |
463 | await tester.pumpWidget( | 466 | await tester.pumpWidget( |
464 | Wrapper( | 467 | Wrapper( |
465 | - child: Container(), | ||
466 | defaultTransition: Transition.leftToRight, | 468 | defaultTransition: Transition.leftToRight, |
469 | + child: Container(), | ||
467 | ), | 470 | ), |
468 | ); | 471 | ); |
469 | 472 | ||
470 | - Get.to(() => FirstScreen()); | 473 | + Get.to(() => const FirstScreen()); |
471 | 474 | ||
472 | await tester.pumpAndSettle(); | 475 | await tester.pumpAndSettle(); |
473 | 476 | ||
@@ -477,12 +480,12 @@ void main() { | @@ -477,12 +480,12 @@ void main() { | ||
477 | testWidgets("leftToRightWithFade", (tester) async { | 480 | testWidgets("leftToRightWithFade", (tester) async { |
478 | await tester.pumpWidget( | 481 | await tester.pumpWidget( |
479 | Wrapper( | 482 | Wrapper( |
480 | - child: Container(), | ||
481 | defaultTransition: Transition.leftToRightWithFade, | 483 | defaultTransition: Transition.leftToRightWithFade, |
484 | + child: Container(), | ||
482 | ), | 485 | ), |
483 | ); | 486 | ); |
484 | 487 | ||
485 | - Get.to(() => FirstScreen()); | 488 | + Get.to(() => const FirstScreen()); |
486 | 489 | ||
487 | await tester.pumpAndSettle(); | 490 | await tester.pumpAndSettle(); |
488 | 491 | ||
@@ -492,12 +495,12 @@ void main() { | @@ -492,12 +495,12 @@ void main() { | ||
492 | testWidgets("leftToRightWithFade", (tester) async { | 495 | testWidgets("leftToRightWithFade", (tester) async { |
493 | await tester.pumpWidget( | 496 | await tester.pumpWidget( |
494 | Wrapper( | 497 | Wrapper( |
495 | - child: Container(), | ||
496 | defaultTransition: Transition.rightToLeft, | 498 | defaultTransition: Transition.rightToLeft, |
499 | + child: Container(), | ||
497 | ), | 500 | ), |
498 | ); | 501 | ); |
499 | 502 | ||
500 | - Get.to(() => FirstScreen()); | 503 | + Get.to(() => const FirstScreen()); |
501 | 504 | ||
502 | await tester.pumpAndSettle(); | 505 | await tester.pumpAndSettle(); |
503 | 506 | ||
@@ -507,12 +510,12 @@ void main() { | @@ -507,12 +510,12 @@ void main() { | ||
507 | testWidgets("defaultTransition", (tester) async { | 510 | testWidgets("defaultTransition", (tester) async { |
508 | await tester.pumpWidget( | 511 | await tester.pumpWidget( |
509 | Wrapper( | 512 | Wrapper( |
510 | - child: Container(), | ||
511 | defaultTransition: Transition.rightToLeft, | 513 | defaultTransition: Transition.rightToLeft, |
514 | + child: Container(), | ||
512 | ), | 515 | ), |
513 | ); | 516 | ); |
514 | 517 | ||
515 | - Get.to(() => FirstScreen()); | 518 | + Get.to(() => const FirstScreen()); |
516 | 519 | ||
517 | await tester.pumpAndSettle(); | 520 | await tester.pumpAndSettle(); |
518 | 521 | ||
@@ -522,12 +525,12 @@ void main() { | @@ -522,12 +525,12 @@ void main() { | ||
522 | testWidgets("rightToLeftWithFade", (tester) async { | 525 | testWidgets("rightToLeftWithFade", (tester) async { |
523 | await tester.pumpWidget( | 526 | await tester.pumpWidget( |
524 | Wrapper( | 527 | Wrapper( |
525 | - child: Container(), | ||
526 | defaultTransition: Transition.rightToLeftWithFade, | 528 | defaultTransition: Transition.rightToLeftWithFade, |
529 | + child: Container(), | ||
527 | ), | 530 | ), |
528 | ); | 531 | ); |
529 | 532 | ||
530 | - Get.to(() => FirstScreen()); | 533 | + Get.to(() => const FirstScreen()); |
531 | 534 | ||
532 | await tester.pumpAndSettle(); | 535 | await tester.pumpAndSettle(); |
533 | 536 | ||
@@ -537,12 +540,12 @@ void main() { | @@ -537,12 +540,12 @@ void main() { | ||
537 | testWidgets("cupertino", (tester) async { | 540 | testWidgets("cupertino", (tester) async { |
538 | await tester.pumpWidget( | 541 | await tester.pumpWidget( |
539 | Wrapper( | 542 | Wrapper( |
540 | - child: Container(), | ||
541 | defaultTransition: Transition.cupertino, | 543 | defaultTransition: Transition.cupertino, |
544 | + child: Container(), | ||
542 | ), | 545 | ), |
543 | ); | 546 | ); |
544 | 547 | ||
545 | - Get.to(() => FirstScreen()); | 548 | + Get.to(() => const FirstScreen()); |
546 | 549 | ||
547 | await tester.pumpAndSettle(); | 550 | await tester.pumpAndSettle(); |
548 | 551 | ||
@@ -552,12 +555,12 @@ void main() { | @@ -552,12 +555,12 @@ void main() { | ||
552 | testWidgets("size", (tester) async { | 555 | testWidgets("size", (tester) async { |
553 | await tester.pumpWidget( | 556 | await tester.pumpWidget( |
554 | Wrapper( | 557 | Wrapper( |
555 | - child: Container(), | ||
556 | defaultTransition: Transition.size, | 558 | defaultTransition: Transition.size, |
559 | + child: Container(), | ||
557 | ), | 560 | ), |
558 | ); | 561 | ); |
559 | 562 | ||
560 | - Get.to(() => FirstScreen()); | 563 | + Get.to(() => const FirstScreen()); |
561 | 564 | ||
562 | await tester.pumpAndSettle(); | 565 | await tester.pumpAndSettle(); |
563 | 566 | ||
@@ -571,7 +574,8 @@ class FirstScreen extends StatelessWidget { | @@ -571,7 +574,8 @@ class FirstScreen extends StatelessWidget { | ||
571 | 574 | ||
572 | @override | 575 | @override |
573 | Widget build(BuildContext context) { | 576 | Widget build(BuildContext context) { |
574 | - return Container(child: Text('FirstScreen')); | 577 | + // ignore: avoid_unnecessary_containers |
578 | + return Container(child: const Text('FirstScreen')); | ||
575 | } | 579 | } |
576 | } | 580 | } |
577 | 581 |
@@ -35,11 +35,14 @@ void main() { | @@ -35,11 +35,14 @@ void main() { | ||
35 | initialRoute: '/', | 35 | initialRoute: '/', |
36 | getPages: [ | 36 | getPages: [ |
37 | GetPage(name: '/', page: () => Container()), | 37 | GetPage(name: '/', page: () => Container()), |
38 | - GetPage(name: '/first', page: () => FirstScreen(), middlewares: [ | ||
39 | - RedirectMiddleware(), | ||
40 | - ]), | ||
41 | - GetPage(name: '/second', page: () => SecondScreen()), | ||
42 | - GetPage(name: '/third', page: () => ThirdScreen()), | 38 | + GetPage( |
39 | + name: '/first', | ||
40 | + page: () => const FirstScreen(), | ||
41 | + middlewares: [ | ||
42 | + RedirectMiddleware(), | ||
43 | + ]), | ||
44 | + GetPage(name: '/second', page: () => const SecondScreen()), | ||
45 | + GetPage(name: '/third', page: () => const ThirdScreen()), | ||
43 | ], | 46 | ], |
44 | ), | 47 | ), |
45 | ); | 48 | ); |
@@ -47,7 +50,6 @@ void main() { | @@ -47,7 +50,6 @@ void main() { | ||
47 | Get.toNamed('/first'); | 50 | Get.toNamed('/first'); |
48 | 51 | ||
49 | await tester.pumpAndSettle(); | 52 | await tester.pumpAndSettle(); |
50 | - print(Get.rootController.rootDelegate.currentConfiguration?.route?.name); | ||
51 | expect(find.byType(SecondScreen), findsOneWidget); | 53 | expect(find.byType(SecondScreen), findsOneWidget); |
52 | }); | 54 | }); |
53 | 55 | ||
@@ -57,11 +59,14 @@ void main() { | @@ -57,11 +59,14 @@ void main() { | ||
57 | initialRoute: '/', | 59 | initialRoute: '/', |
58 | getPages: [ | 60 | getPages: [ |
59 | GetPage(name: '/', page: () => Container()), | 61 | GetPage(name: '/', page: () => Container()), |
60 | - GetPage(name: '/first', page: () => FirstScreen(), middlewares: [ | ||
61 | - RedirectMiddlewareNull(), | ||
62 | - ]), | ||
63 | - GetPage(name: '/second', page: () => SecondScreen()), | ||
64 | - GetPage(name: '/third', page: () => ThirdScreen()), | 62 | + GetPage( |
63 | + name: '/first', | ||
64 | + page: () => const FirstScreen(), | ||
65 | + middlewares: [ | ||
66 | + RedirectMiddlewareNull(), | ||
67 | + ]), | ||
68 | + GetPage(name: '/second', page: () => const SecondScreen()), | ||
69 | + GetPage(name: '/third', page: () => const ThirdScreen()), | ||
65 | ], | 70 | ], |
66 | ), | 71 | ), |
67 | ); | 72 | ); |
@@ -71,7 +76,6 @@ void main() { | @@ -71,7 +76,6 @@ void main() { | ||
71 | Get.toNamed('/first'); | 76 | Get.toNamed('/first'); |
72 | 77 | ||
73 | await tester.pumpAndSettle(); | 78 | await tester.pumpAndSettle(); |
74 | - print(Get.rootController.rootDelegate.currentConfiguration?.route?.name); | ||
75 | expect(find.byType(FirstScreen), findsOneWidget); | 79 | expect(find.byType(FirstScreen), findsOneWidget); |
76 | }); | 80 | }); |
77 | } | 81 | } |
@@ -64,7 +64,7 @@ void main() { | @@ -64,7 +64,7 @@ void main() { | ||
64 | tree.addRoute(pageTree); | 64 | tree.addRoute(pageTree); |
65 | 65 | ||
66 | // tree.addRoute(pageTree); | 66 | // tree.addRoute(pageTree); |
67 | - final searchRoute = '/city/work/office/pen'; | 67 | + const searchRoute = '/city/work/office/pen'; |
68 | final match = tree.matchRoute(searchRoute); | 68 | final match = tree.matchRoute(searchRoute); |
69 | expect(match, isNotNull); | 69 | expect(match, isNotNull); |
70 | expect(match.route!.name, searchRoute); | 70 | expect(match.route!.name, searchRoute); |
@@ -120,7 +120,7 @@ void main() { | @@ -120,7 +120,7 @@ void main() { | ||
120 | // tree.addRoute(p); | 120 | // tree.addRoute(p); |
121 | // } | 121 | // } |
122 | 122 | ||
123 | - final searchRoute = '/city/work/office/pen'; | 123 | + const searchRoute = '/city/work/office/pen'; |
124 | final match = tree.matchRoute(searchRoute); | 124 | final match = tree.matchRoute(searchRoute); |
125 | expect(match, isNotNull); | 125 | expect(match, isNotNull); |
126 | expect(match.route!.name, searchRoute); | 126 | expect(match.route!.name, searchRoute); |
@@ -166,7 +166,6 @@ void main() { | @@ -166,7 +166,6 @@ void main() { | ||
166 | testWidgets( | 166 | testWidgets( |
167 | 'params in url by parameters', | 167 | 'params in url by parameters', |
168 | (tester) async { | 168 | (tester) async { |
169 | - print("Iniciando test"); | ||
170 | await tester.pumpWidget(GetMaterialApp( | 169 | await tester.pumpWidget(GetMaterialApp( |
171 | initialRoute: '/first/juan', | 170 | initialRoute: '/first/juan', |
172 | getPages: [ | 171 | getPages: [ |
@@ -9,13 +9,14 @@ void main() { | @@ -9,13 +9,14 @@ void main() { | ||
9 | GetMaterialApp( | 9 | GetMaterialApp( |
10 | popGesture: true, | 10 | popGesture: true, |
11 | home: ElevatedButton( | 11 | home: ElevatedButton( |
12 | - child: Text('Open Snackbar'), | 12 | + child: const Text('Open Snackbar'), |
13 | onPressed: () { | 13 | onPressed: () { |
14 | Get.snackbar( | 14 | Get.snackbar( |
15 | 'title', | 15 | 'title', |
16 | "message", | 16 | "message", |
17 | - duration: Duration(seconds: 1), | ||
18 | - mainButton: TextButton(onPressed: () {}, child: Text('button')), | 17 | + duration: const Duration(seconds: 1), |
18 | + mainButton: | ||
19 | + TextButton(onPressed: () {}, child: const Text('button')), | ||
19 | isDismissible: false, | 20 | isDismissible: false, |
20 | ); | 21 | ); |
21 | }, | 22 | }, |
@@ -38,18 +39,16 @@ void main() { | @@ -38,18 +39,16 @@ void main() { | ||
38 | GetMaterialApp( | 39 | GetMaterialApp( |
39 | popGesture: true, | 40 | popGesture: true, |
40 | home: ElevatedButton( | 41 | home: ElevatedButton( |
41 | - child: Text('Open Snackbar'), | 42 | + child: const Text('Open Snackbar'), |
42 | onPressed: () { | 43 | onPressed: () { |
43 | Get.rawSnackbar( | 44 | Get.rawSnackbar( |
44 | title: 'title', | 45 | title: 'title', |
45 | message: "message", | 46 | message: "message", |
46 | - onTap: (_) { | ||
47 | - print('snackbar tapped'); | ||
48 | - }, | 47 | + onTap: (_) {}, |
49 | shouldIconPulse: true, | 48 | shouldIconPulse: true, |
50 | - icon: Icon(Icons.alarm), | 49 | + icon: const Icon(Icons.alarm), |
51 | showProgressIndicator: true, | 50 | showProgressIndicator: true, |
52 | - duration: Duration(seconds: 1), | 51 | + duration: const Duration(seconds: 1), |
53 | isDismissible: true, | 52 | isDismissible: true, |
54 | leftBarIndicatorColor: Colors.amber, | 53 | leftBarIndicatorColor: Colors.amber, |
55 | overlayBlur: 1.0, | 54 | overlayBlur: 1.0, |
@@ -72,20 +71,20 @@ void main() { | @@ -72,20 +71,20 @@ void main() { | ||
72 | }); | 71 | }); |
73 | 72 | ||
74 | testWidgets("test snackbar queue", (tester) async { | 73 | testWidgets("test snackbar queue", (tester) async { |
75 | - final messageOne = Text('title'); | 74 | + const messageOne = Text('title'); |
76 | 75 | ||
77 | - final messageTwo = Text('titleTwo'); | 76 | + const messageTwo = Text('titleTwo'); |
78 | 77 | ||
79 | await tester.pumpWidget( | 78 | await tester.pumpWidget( |
80 | GetMaterialApp( | 79 | GetMaterialApp( |
81 | popGesture: true, | 80 | popGesture: true, |
82 | home: ElevatedButton( | 81 | home: ElevatedButton( |
83 | - child: Text('Open Snackbar'), | 82 | + child: const Text('Open Snackbar'), |
84 | onPressed: () { | 83 | onPressed: () { |
85 | Get.rawSnackbar( | 84 | Get.rawSnackbar( |
86 | - messageText: messageOne, duration: Duration(seconds: 1)); | 85 | + messageText: messageOne, duration: const Duration(seconds: 1)); |
87 | Get.rawSnackbar( | 86 | Get.rawSnackbar( |
88 | - messageText: messageTwo, duration: Duration(seconds: 1)); | 87 | + messageText: messageTwo, duration: const Duration(seconds: 1)); |
89 | }, | 88 | }, |
90 | ), | 89 | ), |
91 | ), | 90 | ), |
@@ -122,9 +121,9 @@ void main() { | @@ -122,9 +121,9 @@ void main() { | ||
122 | GestureDetector( | 121 | GestureDetector( |
123 | key: snackBarTapTarget, | 122 | key: snackBarTapTarget, |
124 | onTap: () { | 123 | onTap: () { |
125 | - getBar = GetSnackBar( | 124 | + getBar = const GetSnackBar( |
126 | message: 'bar1', | 125 | message: 'bar1', |
127 | - duration: const Duration(seconds: 2), | 126 | + duration: Duration(seconds: 2), |
128 | isDismissible: true, | 127 | isDismissible: true, |
129 | dismissDirection: dismissDirection, | 128 | dismissDirection: dismissDirection, |
130 | ); | 129 | ); |
@@ -155,7 +154,7 @@ void main() { | @@ -155,7 +154,7 @@ void main() { | ||
155 | await tester.pump(const Duration(milliseconds: 500)); | 154 | await tester.pump(const Duration(milliseconds: 500)); |
156 | expect(find.byWidget(getBar), findsOneWidget); | 155 | expect(find.byWidget(getBar), findsOneWidget); |
157 | await tester.ensureVisible(find.byWidget(getBar)); | 156 | await tester.ensureVisible(find.byWidget(getBar)); |
158 | - await tester.drag(find.byWidget(getBar), Offset(0.0, 50.0)); | 157 | + await tester.drag(find.byWidget(getBar), const Offset(0.0, 50.0)); |
159 | await tester.pump(const Duration(milliseconds: 500)); | 158 | await tester.pump(const Duration(milliseconds: 500)); |
160 | 159 | ||
161 | expect(Get.isSnackbarOpen, false); | 160 | expect(Get.isSnackbarOpen, false); |
@@ -222,12 +221,12 @@ void main() { | @@ -222,12 +221,12 @@ void main() { | ||
222 | }); | 221 | }); |
223 | 222 | ||
224 | testWidgets("Get test actions and icon", (tester) async { | 223 | testWidgets("Get test actions and icon", (tester) async { |
225 | - final icon = Icon(Icons.alarm); | ||
226 | - final action = TextButton(onPressed: () {}, child: Text('button')); | 224 | + const icon = Icon(Icons.alarm); |
225 | + final action = TextButton(onPressed: () {}, child: const Text('button')); | ||
227 | 226 | ||
228 | late final GetSnackBar getBar; | 227 | late final GetSnackBar getBar; |
229 | 228 | ||
230 | - await tester.pumpWidget(GetMaterialApp(home: Scaffold())); | 229 | + await tester.pumpWidget(const GetMaterialApp(home: Scaffold())); |
231 | 230 | ||
232 | await tester.pump(); | 231 | await tester.pump(); |
233 | 232 |
@@ -57,8 +57,8 @@ class WrapperNamed extends StatelessWidget { | @@ -57,8 +57,8 @@ class WrapperNamed extends StatelessWidget { | ||
57 | } | 57 | } |
58 | 58 | ||
59 | class WrapperTranslations extends Translations { | 59 | class WrapperTranslations extends Translations { |
60 | - static final fallbackLocale = Locale('en', 'US'); | ||
61 | - static Locale? get locale => Locale('en', 'US'); | 60 | + static const fallbackLocale = Locale('en', 'US'); |
61 | + static Locale? get locale => const Locale('en', 'US'); | ||
62 | @override | 62 | @override |
63 | Map<String, Map<String, String>> get keys => { | 63 | Map<String, Map<String, String>> get keys => { |
64 | 'en_US': { | 64 | 'en_US': { |
@@ -44,7 +44,7 @@ void main() { | @@ -44,7 +44,7 @@ void main() { | ||
44 | debounce(count, (dynamic _) { | 44 | debounce(count, (dynamic _) { |
45 | // print(_); | 45 | // print(_); |
46 | result = _ as int?; | 46 | result = _ as int?; |
47 | - }, time: Duration(milliseconds: 100)); | 47 | + }, time: const Duration(milliseconds: 100)); |
48 | 48 | ||
49 | count.value++; | 49 | count.value++; |
50 | count.value++; | 50 | count.value++; |
@@ -52,7 +52,7 @@ void main() { | @@ -52,7 +52,7 @@ void main() { | ||
52 | count.value++; | 52 | count.value++; |
53 | await Future.delayed(Duration.zero); | 53 | await Future.delayed(Duration.zero); |
54 | expect(-1, result); | 54 | expect(-1, result); |
55 | - await Future.delayed(Duration(milliseconds: 100)); | 55 | + await Future.delayed(const Duration(milliseconds: 100)); |
56 | expect(4, result); | 56 | expect(4, result); |
57 | }); | 57 | }); |
58 | 58 | ||
@@ -60,23 +60,22 @@ void main() { | @@ -60,23 +60,22 @@ void main() { | ||
60 | final count = 0.obs; | 60 | final count = 0.obs; |
61 | int? result = -1; | 61 | int? result = -1; |
62 | interval<int>(count, (v) { | 62 | interval<int>(count, (v) { |
63 | - print(v); | ||
64 | result = v; | 63 | result = v; |
65 | - }, time: Duration(milliseconds: 100)); | 64 | + }, time: const Duration(milliseconds: 100)); |
66 | 65 | ||
67 | count.value++; | 66 | count.value++; |
68 | await Future.delayed(Duration.zero); | 67 | await Future.delayed(Duration.zero); |
69 | - await Future.delayed(Duration(milliseconds: 100)); | 68 | + await Future.delayed(const Duration(milliseconds: 100)); |
70 | expect(result, 1); | 69 | expect(result, 1); |
71 | count.value++; | 70 | count.value++; |
72 | count.value++; | 71 | count.value++; |
73 | count.value++; | 72 | count.value++; |
74 | await Future.delayed(Duration.zero); | 73 | await Future.delayed(Duration.zero); |
75 | - await Future.delayed(Duration(milliseconds: 100)); | 74 | + await Future.delayed(const Duration(milliseconds: 100)); |
76 | expect(result, 2); | 75 | expect(result, 2); |
77 | count.value++; | 76 | count.value++; |
78 | await Future.delayed(Duration.zero); | 77 | await Future.delayed(Duration.zero); |
79 | - await Future.delayed(Duration(milliseconds: 100)); | 78 | + await Future.delayed(const Duration(milliseconds: 100)); |
80 | expect(result, 5); | 79 | expect(result, 5); |
81 | }); | 80 | }); |
82 | 81 | ||
@@ -110,7 +109,7 @@ void main() { | @@ -110,7 +109,7 @@ void main() { | ||
110 | reactiveInteger.call(3); | 109 | reactiveInteger.call(3); |
111 | reactiveInteger.call(3); | 110 | reactiveInteger.call(3); |
112 | 111 | ||
113 | - await Future.delayed(Duration(milliseconds: 100)); | 112 | + await Future.delayed(const Duration(milliseconds: 100)); |
114 | expect(1, timesCalled); | 113 | expect(1, timesCalled); |
115 | }); | 114 | }); |
116 | 115 | ||
@@ -127,8 +126,8 @@ void main() { | @@ -127,8 +126,8 @@ void main() { | ||
127 | reactiveInteger.trigger(2); | 126 | reactiveInteger.trigger(2); |
128 | reactiveInteger.trigger(3); | 127 | reactiveInteger.trigger(3); |
129 | 128 | ||
130 | - await Future.delayed(Duration(milliseconds: 100)); | ||
131 | - print(timesCalled); | 129 | + await Future.delayed(const Duration(milliseconds: 100)); |
130 | + | ||
132 | expect(3, timesCalled); | 131 | expect(3, timesCalled); |
133 | }); | 132 | }); |
134 | 133 | ||
@@ -146,7 +145,7 @@ void main() { | @@ -146,7 +145,7 @@ void main() { | ||
146 | reactiveInteger.trigger(3); | 145 | reactiveInteger.trigger(3); |
147 | reactiveInteger.trigger(1); | 146 | reactiveInteger.trigger(1); |
148 | 147 | ||
149 | - await Future.delayed(Duration(milliseconds: 100)); | 148 | + await Future.delayed(const Duration(milliseconds: 100)); |
150 | expect(4, timesCalled); | 149 | expect(4, timesCalled); |
151 | }); | 150 | }); |
152 | 151 |
@@ -34,11 +34,11 @@ void main() { | @@ -34,11 +34,11 @@ void main() { | ||
34 | 'Map: ${controller.map.length}', | 34 | 'Map: ${controller.map.length}', |
35 | ), | 35 | ), |
36 | TextButton( | 36 | TextButton( |
37 | - child: Text("increment"), | 37 | + child: const Text("increment"), |
38 | onPressed: () => controller.increment(), | 38 | onPressed: () => controller.increment(), |
39 | ), | 39 | ), |
40 | TextButton( | 40 | TextButton( |
41 | - child: Text("increment2"), | 41 | + child: const Text("increment2"), |
42 | onPressed: () => controller.increment2(), | 42 | onPressed: () => controller.increment2(), |
43 | ) | 43 | ) |
44 | ], | 44 | ], |
@@ -18,8 +18,8 @@ void main() { | @@ -18,8 +18,8 @@ void main() { | ||
18 | Text('Bool: ${controller.boolean.value}'), | 18 | Text('Bool: ${controller.boolean.value}'), |
19 | Text('Map: ${controller.map.length}'), | 19 | Text('Map: ${controller.map.length}'), |
20 | TextButton( | 20 | TextButton( |
21 | - child: Text("increment"), | ||
22 | onPressed: controller.increment, | 21 | onPressed: controller.increment, |
22 | + child: const Text("increment"), | ||
23 | ), | 23 | ), |
24 | Obx(() => Text('Obx: ${controller.map.length}')) | 24 | Obx(() => Text('Obx: ${controller.map.length}')) |
25 | ]), | 25 | ]), |
@@ -31,7 +31,7 @@ void main() { | @@ -31,7 +31,7 @@ void main() { | ||
31 | 'Map: ${controller.map.length}', | 31 | 'Map: ${controller.map.length}', |
32 | ), | 32 | ), |
33 | TextButton( | 33 | TextButton( |
34 | - child: Text("increment"), | 34 | + child: const Text("increment"), |
35 | onPressed: () => controller.increment(), | 35 | onPressed: () => controller.increment(), |
36 | ), | 36 | ), |
37 | GetX<Controller2>(builder: (controller) { | 37 | GetX<Controller2>(builder: (controller) { |
@@ -15,11 +15,11 @@ void main() { | @@ -15,11 +15,11 @@ void main() { | ||
15 | '${controller.counter}', | 15 | '${controller.counter}', |
16 | ), | 16 | ), |
17 | TextButton( | 17 | TextButton( |
18 | - child: Text("increment"), | 18 | + child: const Text("increment"), |
19 | onPressed: () => controller.increment(), | 19 | onPressed: () => controller.increment(), |
20 | ), | 20 | ), |
21 | TextButton( | 21 | TextButton( |
22 | - child: Text("incrementWithId"), | 22 | + child: const Text("incrementWithId"), |
23 | onPressed: () => controller.incrementWithId(), | 23 | onPressed: () => controller.incrementWithId(), |
24 | ), | 24 | ), |
25 | GetBuilder<Controller>( | 25 | GetBuilder<Controller>( |
@@ -2,8 +2,44 @@ import 'package:flutter_test/flutter_test.dart'; | @@ -2,8 +2,44 @@ import 'package:flutter_test/flutter_test.dart'; | ||
2 | import 'package:get/utils.dart'; | 2 | import 'package:get/utils.dart'; |
3 | 3 | ||
4 | void main() { | 4 | void main() { |
5 | - test('Test for toPrecision on Double', () { | ||
6 | - var testVar = 5.4545454; | ||
7 | - expect(testVar.toPrecision(2), equals(5.45)); | 5 | + group('DoubleExt', () { |
6 | + test('toPrecision', () { | ||
7 | + expect(3.14159.toPrecision(2), equals(3.14)); | ||
8 | + expect(3.14159.toPrecision(4), equals(3.1416)); | ||
9 | + expect(1.0.toPrecision(0), equals(1.0)); | ||
10 | + expect(123456789.123456789.toPrecision(4), equals(123456789.1235)); | ||
11 | + expect((-3.14159).toPrecision(2), equals(-3.14)); | ||
12 | + }); | ||
13 | + | ||
14 | + test('milliseconds', () { | ||
15 | + expect(1000.0.ms, equals(const Duration(milliseconds: 1000))); | ||
16 | + expect( | ||
17 | + 1.5.ms, equals(const Duration(milliseconds: 1, microseconds: 500))); | ||
18 | + expect((-2000.0).ms, equals(const Duration(milliseconds: -2000))); | ||
19 | + }); | ||
20 | + | ||
21 | + test('seconds', () { | ||
22 | + expect(60.0.seconds, equals(const Duration(seconds: 60))); | ||
23 | + expect(1.5.seconds, equals(const Duration(milliseconds: 1500))); | ||
24 | + expect((-120.0).seconds, equals(const Duration(seconds: -120))); | ||
25 | + }); | ||
26 | + | ||
27 | + test('minutes', () { | ||
28 | + expect(2.5.minutes, equals(const Duration(minutes: 2, seconds: 30))); | ||
29 | + expect(1.2.minutes, equals(const Duration(seconds: 72))); | ||
30 | + expect((-3.0).minutes, equals(const Duration(minutes: -3))); | ||
31 | + }); | ||
32 | + | ||
33 | + test('hours', () { | ||
34 | + expect(1.5.hours, equals(const Duration(hours: 1, minutes: 30))); | ||
35 | + expect(0.25.hours, equals(const Duration(minutes: 15))); | ||
36 | + expect((-2.0).hours, equals(const Duration(hours: -2))); | ||
37 | + }); | ||
38 | + | ||
39 | + test('days', () { | ||
40 | + expect(1.5.days, equals(const Duration(days: 1, hours: 12))); | ||
41 | + expect(0.25.days, equals(const Duration(hours: 6))); | ||
42 | + expect((-3.0).days, equals(const Duration(days: -3))); | ||
43 | + }); | ||
8 | }); | 44 | }); |
9 | } | 45 | } |
1 | +import 'package:flutter_test/flutter_test.dart'; | ||
2 | +import 'package:get/get.dart'; | ||
3 | + | ||
4 | +void main() { | ||
5 | + group('DurationExt', () { | ||
6 | + test('seconds', () { | ||
7 | + expect(1.seconds, equals(const Duration(seconds: 1))); | ||
8 | + expect( | ||
9 | + 2.5.seconds, equals(const Duration(seconds: 2, milliseconds: 500))); | ||
10 | + expect((-1).seconds, equals(const Duration(seconds: -1))); | ||
11 | + }); | ||
12 | + | ||
13 | + test('days', () { | ||
14 | + expect(1.days, equals(const Duration(days: 1))); | ||
15 | + expect((-1).days, equals(const Duration(days: -1))); | ||
16 | + }); | ||
17 | + | ||
18 | + test('hours', () { | ||
19 | + expect(1.hours, equals(const Duration(hours: 1))); | ||
20 | + expect((-1).hours, equals(const Duration(hours: -1))); | ||
21 | + }); | ||
22 | + | ||
23 | + test('minutes', () { | ||
24 | + expect(1.minutes, equals(const Duration(minutes: 1))); | ||
25 | + expect((-1).minutes, equals(const Duration(minutes: -1))); | ||
26 | + }); | ||
27 | + | ||
28 | + test('milliseconds', () { | ||
29 | + expect(1.milliseconds, equals(const Duration(milliseconds: 1))); | ||
30 | + expect((-1).milliseconds, equals(const Duration(milliseconds: -1))); | ||
31 | + }); | ||
32 | + | ||
33 | + test('microseconds', () { | ||
34 | + expect(1.microseconds, equals(const Duration(microseconds: 1))); | ||
35 | + expect((-1).microseconds, equals(const Duration(microseconds: -1))); | ||
36 | + }); | ||
37 | + | ||
38 | + test('ms', () { | ||
39 | + expect(1.ms, equals(const Duration(milliseconds: 1))); | ||
40 | + expect((-1).ms, equals(const Duration(milliseconds: -1))); | ||
41 | + }); | ||
42 | + }); | ||
43 | +} |
@@ -3,12 +3,12 @@ import 'package:get/utils.dart'; | @@ -3,12 +3,12 @@ import 'package:get/utils.dart'; | ||
3 | 3 | ||
4 | void main() { | 4 | void main() { |
5 | group('String extensions', () { | 5 | group('String extensions', () { |
6 | - final text = "oi"; | ||
7 | - final digit = "5"; | ||
8 | - final specialCaracters = "#\$!%@"; | ||
9 | - final alphaNumeric = "123asd"; | ||
10 | - final numbers = "123"; | ||
11 | - final letters = "foo"; | 6 | + const text = "oi"; |
7 | + const digit = "5"; | ||
8 | + const specialCaracters = "#\$!%@"; | ||
9 | + const alphaNumeric = "123asd"; | ||
10 | + const numbers = "123"; | ||
11 | + const letters = "foo"; | ||
12 | // String notInitializedVar; | 12 | // String notInitializedVar; |
13 | 13 | ||
14 | test('var.isNum', () { | 14 | test('var.isNum', () { |
@@ -66,27 +66,27 @@ void main() { | @@ -66,27 +66,27 @@ void main() { | ||
66 | }); | 66 | }); |
67 | 67 | ||
68 | test('var.isBool', () { | 68 | test('var.isBool', () { |
69 | - final trueString = 'true'; | 69 | + const trueString = 'true'; |
70 | // expect(notInitializedVar.isBool, false); | 70 | // expect(notInitializedVar.isBool, false); |
71 | expect(letters.isBool, false); | 71 | expect(letters.isBool, false); |
72 | expect(trueString.isBool, true); | 72 | expect(trueString.isBool, true); |
73 | }); | 73 | }); |
74 | 74 | ||
75 | test('var.isVectorFileName', () { | 75 | test('var.isVectorFileName', () { |
76 | - final path = "logo.svg"; | ||
77 | - final fullPath = "C:/Users/Getx/Documents/logo.svg"; | 76 | + const path = "logo.svg"; |
77 | + const fullPath = "C:/Users/Getx/Documents/logo.svg"; | ||
78 | expect(path.isVectorFileName, true); | 78 | expect(path.isVectorFileName, true); |
79 | expect(fullPath.isVectorFileName, true); | 79 | expect(fullPath.isVectorFileName, true); |
80 | expect(alphaNumeric.isVectorFileName, false); | 80 | expect(alphaNumeric.isVectorFileName, false); |
81 | }); | 81 | }); |
82 | 82 | ||
83 | test('var.isImageFileName', () { | 83 | test('var.isImageFileName', () { |
84 | - final jpgPath = "logo.jpg"; | ||
85 | - final jpegPath = "logo.jpeg"; | ||
86 | - final pngPath = "logo.png"; | ||
87 | - final gifPath = "logo.gif"; | ||
88 | - final bmpPath = "logo.bmp"; | ||
89 | - final svgPath = "logo.svg"; | 84 | + const jpgPath = "logo.jpg"; |
85 | + const jpegPath = "logo.jpeg"; | ||
86 | + const pngPath = "logo.png"; | ||
87 | + const gifPath = "logo.gif"; | ||
88 | + const bmpPath = "logo.bmp"; | ||
89 | + const svgPath = "logo.svg"; | ||
90 | 90 | ||
91 | expect(jpgPath.isImageFileName, true); | 91 | expect(jpgPath.isImageFileName, true); |
92 | expect(jpegPath.isImageFileName, true); | 92 | expect(jpegPath.isImageFileName, true); |
@@ -97,12 +97,12 @@ void main() { | @@ -97,12 +97,12 @@ void main() { | ||
97 | }); | 97 | }); |
98 | 98 | ||
99 | test('var.isAudioFileName', () { | 99 | test('var.isAudioFileName', () { |
100 | - final mp3Path = "logo.mp3"; | ||
101 | - final wavPath = "logo.wav"; | ||
102 | - final wmaPath = "logo.wma"; | ||
103 | - final amrPath = "logo.amr"; | ||
104 | - final oggPath = "logo.ogg"; | ||
105 | - final svgPath = "logo.svg"; | 100 | + const mp3Path = "logo.mp3"; |
101 | + const wavPath = "logo.wav"; | ||
102 | + const wmaPath = "logo.wma"; | ||
103 | + const amrPath = "logo.amr"; | ||
104 | + const oggPath = "logo.ogg"; | ||
105 | + const svgPath = "logo.svg"; | ||
106 | 106 | ||
107 | expect(mp3Path.isAudioFileName, true); | 107 | expect(mp3Path.isAudioFileName, true); |
108 | expect(wavPath.isAudioFileName, true); | 108 | expect(wavPath.isAudioFileName, true); |
@@ -113,14 +113,14 @@ void main() { | @@ -113,14 +113,14 @@ void main() { | ||
113 | }); | 113 | }); |
114 | 114 | ||
115 | test('var.isVideoFileName', () { | 115 | test('var.isVideoFileName', () { |
116 | - final mp4Path = "logo.mp4"; | ||
117 | - final aviPath = "logo.avi"; | ||
118 | - final wmvPath = "logo.wmv"; | ||
119 | - final rmvbPath = "logo.rmvb"; | ||
120 | - final mpgPath = "logo.mpg"; | ||
121 | - final mpegPath = "logo.mpeg"; | ||
122 | - final threegpPath = "logo.3gp"; | ||
123 | - final svgPath = "logo.svg"; | 116 | + const mp4Path = "logo.mp4"; |
117 | + const aviPath = "logo.avi"; | ||
118 | + const wmvPath = "logo.wmv"; | ||
119 | + const rmvbPath = "logo.rmvb"; | ||
120 | + const mpgPath = "logo.mpg"; | ||
121 | + const mpegPath = "logo.mpeg"; | ||
122 | + const threegpPath = "logo.3gp"; | ||
123 | + const svgPath = "logo.svg"; | ||
124 | 124 | ||
125 | expect(mp4Path.isVideoFileName, true); | 125 | expect(mp4Path.isVideoFileName, true); |
126 | expect(aviPath.isVideoFileName, true); | 126 | expect(aviPath.isVideoFileName, true); |
@@ -139,8 +139,8 @@ void main() { | @@ -139,8 +139,8 @@ void main() { | ||
139 | }); | 139 | }); |
140 | 140 | ||
141 | test('var.isDocumentFileName', () { | 141 | test('var.isDocumentFileName', () { |
142 | - final docPath = "file.doc"; | ||
143 | - final docxPath = "file.docx"; | 142 | + const docPath = "file.doc"; |
143 | + const docxPath = "file.docx"; | ||
144 | 144 | ||
145 | expect(docPath.isDocumentFileName, true); | 145 | expect(docPath.isDocumentFileName, true); |
146 | expect(docxPath.isDocumentFileName, true); | 146 | expect(docxPath.isDocumentFileName, true); |
@@ -148,8 +148,8 @@ void main() { | @@ -148,8 +148,8 @@ void main() { | ||
148 | }); | 148 | }); |
149 | 149 | ||
150 | test('var.isExcelFileName', () { | 150 | test('var.isExcelFileName', () { |
151 | - final xlsPath = "file.xls"; | ||
152 | - final xlsxPath = "file.xlsx"; | 151 | + const xlsPath = "file.xls"; |
152 | + const xlsxPath = "file.xlsx"; | ||
153 | 153 | ||
154 | expect(xlsPath.isExcelFileName, true); | 154 | expect(xlsPath.isExcelFileName, true); |
155 | expect(xlsxPath.isExcelFileName, true); | 155 | expect(xlsxPath.isExcelFileName, true); |
@@ -157,8 +157,8 @@ void main() { | @@ -157,8 +157,8 @@ void main() { | ||
157 | }); | 157 | }); |
158 | 158 | ||
159 | test('var.isPPTFileName', () { | 159 | test('var.isPPTFileName', () { |
160 | - final pptPath = "file.ppt"; | ||
161 | - final pptxPath = "file.pptx"; | 160 | + const pptPath = "file.ppt"; |
161 | + const pptxPath = "file.pptx"; | ||
162 | 162 | ||
163 | expect(pptPath.isPPTFileName, true); | 163 | expect(pptPath.isPPTFileName, true); |
164 | expect(pptxPath.isPPTFileName, true); | 164 | expect(pptxPath.isPPTFileName, true); |
@@ -166,20 +166,20 @@ void main() { | @@ -166,20 +166,20 @@ void main() { | ||
166 | }); | 166 | }); |
167 | 167 | ||
168 | test('var.isAPKFileName', () { | 168 | test('var.isAPKFileName', () { |
169 | - final apkPath = "file.apk"; | 169 | + const apkPath = "file.apk"; |
170 | 170 | ||
171 | expect(apkPath.isAPKFileName, true); | 171 | expect(apkPath.isAPKFileName, true); |
172 | expect(alphaNumeric.isAPKFileName, false); | 172 | expect(alphaNumeric.isAPKFileName, false); |
173 | }); | 173 | }); |
174 | 174 | ||
175 | test('var.isPDFFileName', () { | 175 | test('var.isPDFFileName', () { |
176 | - final pdfPath = "file.pdf"; | 176 | + const pdfPath = "file.pdf"; |
177 | 177 | ||
178 | expect(pdfPath.isPDFFileName, true); | 178 | expect(pdfPath.isPDFFileName, true); |
179 | expect(alphaNumeric.isPDFFileName, false); | 179 | expect(alphaNumeric.isPDFFileName, false); |
180 | }); | 180 | }); |
181 | test('var.isHTMLFileName', () { | 181 | test('var.isHTMLFileName', () { |
182 | - final htmlPath = "file.html"; | 182 | + const htmlPath = "file.html"; |
183 | 183 | ||
184 | expect(htmlPath.isHTMLFileName, true); | 184 | expect(htmlPath.isHTMLFileName, true); |
185 | expect(alphaNumeric.isHTMLFileName, false); | 185 | expect(alphaNumeric.isHTMLFileName, false); |
@@ -296,7 +296,7 @@ void main() { | @@ -296,7 +296,7 @@ void main() { | ||
296 | expect(phone.isPhoneNumber, true); | 296 | expect(phone.isPhoneNumber, true); |
297 | } | 297 | } |
298 | 298 | ||
299 | - final bigRandomNumber = '168468468465241327987624987327987'; | 299 | + const bigRandomNumber = '168468468465241327987624987327987'; |
300 | expect(bigRandomNumber.isPhoneNumber, false); | 300 | expect(bigRandomNumber.isPhoneNumber, false); |
301 | 301 | ||
302 | expect(alphaNumeric.isPhoneNumber, false); | 302 | expect(alphaNumeric.isPhoneNumber, false); |
@@ -693,7 +693,7 @@ void main() { | @@ -693,7 +693,7 @@ void main() { | ||
693 | }); | 693 | }); |
694 | 694 | ||
695 | test('var.isCaseInsensitiveContains(string)', () { | 695 | test('var.isCaseInsensitiveContains(string)', () { |
696 | - final phrase = 'Back to Square One'; | 696 | + const phrase = 'Back to Square One'; |
697 | 697 | ||
698 | expect(phrase.isCaseInsensitiveContains('to'), true); | 698 | expect(phrase.isCaseInsensitiveContains('to'), true); |
699 | expect(phrase.isCaseInsensitiveContains('square'), true); | 699 | expect(phrase.isCaseInsensitiveContains('square'), true); |
@@ -702,7 +702,7 @@ void main() { | @@ -702,7 +702,7 @@ void main() { | ||
702 | }); | 702 | }); |
703 | 703 | ||
704 | test('var.isCaseInsensitiveContainsAny(string)', () { | 704 | test('var.isCaseInsensitiveContainsAny(string)', () { |
705 | - final phrase = 'Back to Square One'; | 705 | + const phrase = 'Back to Square One'; |
706 | 706 | ||
707 | expect(phrase.isCaseInsensitiveContainsAny('to'), true); | 707 | expect(phrase.isCaseInsensitiveContainsAny('to'), true); |
708 | expect(phrase.isCaseInsensitiveContainsAny('square'), true); | 708 | expect(phrase.isCaseInsensitiveContainsAny('square'), true); |
@@ -3,16 +3,18 @@ import 'package:flutter_test/flutter_test.dart'; | @@ -3,16 +3,18 @@ import 'package:flutter_test/flutter_test.dart'; | ||
3 | import 'package:get/utils.dart'; | 3 | import 'package:get/utils.dart'; |
4 | 4 | ||
5 | class Foo extends StatelessWidget { | 5 | class Foo extends StatelessWidget { |
6 | + const Foo({super.key}); | ||
7 | + | ||
6 | @override | 8 | @override |
7 | Widget build(BuildContext context) { | 9 | Widget build(BuildContext context) { |
8 | - return SizedBox.shrink(); | 10 | + return const SizedBox.shrink(); |
9 | } | 11 | } |
10 | } | 12 | } |
11 | 13 | ||
12 | void main() { | 14 | void main() { |
13 | group('Group test for PaddingX Extension', () { | 15 | group('Group test for PaddingX Extension', () { |
14 | testWidgets('Test of paddingAll', (tester) async { | 16 | testWidgets('Test of paddingAll', (tester) async { |
15 | - Widget containerTest = Foo(); | 17 | + Widget containerTest = const Foo(); |
16 | 18 | ||
17 | expect(find.byType(Padding), findsNothing); | 19 | expect(find.byType(Padding), findsNothing); |
18 | 20 | ||
@@ -22,7 +24,7 @@ void main() { | @@ -22,7 +24,7 @@ void main() { | ||
22 | }); | 24 | }); |
23 | 25 | ||
24 | testWidgets('Test of paddingOnly', (tester) async { | 26 | testWidgets('Test of paddingOnly', (tester) async { |
25 | - Widget containerTest = Foo(); | 27 | + Widget containerTest = const Foo(); |
26 | 28 | ||
27 | expect(find.byType(Padding), findsNothing); | 29 | expect(find.byType(Padding), findsNothing); |
28 | 30 | ||
@@ -32,7 +34,7 @@ void main() { | @@ -32,7 +34,7 @@ void main() { | ||
32 | }); | 34 | }); |
33 | 35 | ||
34 | testWidgets('Test of paddingSymmetric', (tester) async { | 36 | testWidgets('Test of paddingSymmetric', (tester) async { |
35 | - Widget containerTest = Foo(); | 37 | + Widget containerTest = const Foo(); |
36 | 38 | ||
37 | expect(find.byType(Padding), findsNothing); | 39 | expect(find.byType(Padding), findsNothing); |
38 | 40 | ||
@@ -42,7 +44,7 @@ void main() { | @@ -42,7 +44,7 @@ void main() { | ||
42 | }); | 44 | }); |
43 | 45 | ||
44 | testWidgets('Test of paddingZero', (tester) async { | 46 | testWidgets('Test of paddingZero', (tester) async { |
45 | - Widget containerTest = Foo(); | 47 | + Widget containerTest = const Foo(); |
46 | 48 | ||
47 | expect(find.byType(Padding), findsNothing); | 49 | expect(find.byType(Padding), findsNothing); |
48 | 50 | ||
@@ -54,7 +56,7 @@ void main() { | @@ -54,7 +56,7 @@ void main() { | ||
54 | 56 | ||
55 | group('Group test for MarginX Extension', () { | 57 | group('Group test for MarginX Extension', () { |
56 | testWidgets('Test of marginAll', (tester) async { | 58 | testWidgets('Test of marginAll', (tester) async { |
57 | - Widget containerTest = Foo(); | 59 | + Widget containerTest = const Foo(); |
58 | 60 | ||
59 | await tester.pumpWidget(containerTest.marginAll(16)); | 61 | await tester.pumpWidget(containerTest.marginAll(16)); |
60 | 62 | ||
@@ -62,7 +64,7 @@ void main() { | @@ -62,7 +64,7 @@ void main() { | ||
62 | }); | 64 | }); |
63 | 65 | ||
64 | testWidgets('Test of marginOnly', (tester) async { | 66 | testWidgets('Test of marginOnly', (tester) async { |
65 | - Widget containerTest = Foo(); | 67 | + Widget containerTest = const Foo(); |
66 | 68 | ||
67 | await tester.pumpWidget(containerTest.marginOnly(top: 16)); | 69 | await tester.pumpWidget(containerTest.marginOnly(top: 16)); |
68 | 70 | ||
@@ -70,7 +72,7 @@ void main() { | @@ -70,7 +72,7 @@ void main() { | ||
70 | }); | 72 | }); |
71 | 73 | ||
72 | testWidgets('Test of marginSymmetric', (tester) async { | 74 | testWidgets('Test of marginSymmetric', (tester) async { |
73 | - Widget containerTest = Foo(); | 75 | + Widget containerTest = const Foo(); |
74 | 76 | ||
75 | await tester.pumpWidget(containerTest.marginSymmetric(vertical: 16)); | 77 | await tester.pumpWidget(containerTest.marginSymmetric(vertical: 16)); |
76 | 78 | ||
@@ -78,7 +80,7 @@ void main() { | @@ -78,7 +80,7 @@ void main() { | ||
78 | }); | 80 | }); |
79 | 81 | ||
80 | testWidgets('Test of marginZero', (tester) async { | 82 | testWidgets('Test of marginZero', (tester) async { |
81 | - Widget containerTest = Foo(); | 83 | + Widget containerTest = const Foo(); |
82 | 84 | ||
83 | await tester.pumpWidget(containerTest.marginZero); | 85 | await tester.pumpWidget(containerTest.marginZero); |
84 | 86 |
@@ -8,7 +8,7 @@ class TestClass { | @@ -8,7 +8,7 @@ class TestClass { | ||
8 | class EmptyClass {} | 8 | class EmptyClass {} |
9 | 9 | ||
10 | void main() { | 10 | void main() { |
11 | - dynamic _id(dynamic e) => e; | 11 | + dynamic newId(dynamic e) => e; |
12 | 12 | ||
13 | test('null isNullOrBlank should be true for null', () { | 13 | test('null isNullOrBlank should be true for null', () { |
14 | expect(GetUtils.isNullOrBlank(null), true); | 14 | expect(GetUtils.isNullOrBlank(null), true); |
@@ -38,8 +38,8 @@ void main() { | @@ -38,8 +38,8 @@ void main() { | ||
38 | }); | 38 | }); |
39 | 39 | ||
40 | test('isNullOrBlank should validate iterables', () { | 40 | test('isNullOrBlank should validate iterables', () { |
41 | - expect(GetUtils.isNullOrBlank([].map(_id)), true); | ||
42 | - expect(GetUtils.isNullOrBlank([1].map(_id)), false); | 41 | + expect(GetUtils.isNullOrBlank([].map(newId)), true); |
42 | + expect(GetUtils.isNullOrBlank([1].map(newId)), false); | ||
43 | }); | 43 | }); |
44 | 44 | ||
45 | test('isNullOrBlank should validate lists', () { | 45 | test('isNullOrBlank should validate lists', () { |
@@ -67,8 +67,8 @@ void main() { | @@ -67,8 +67,8 @@ void main() { | ||
67 | group('GetUtils.isLength* functions', () { | 67 | group('GetUtils.isLength* functions', () { |
68 | test('isLengthEqualTo should validate iterable lengths', () { | 68 | test('isLengthEqualTo should validate iterable lengths', () { |
69 | // iterables should cover list and set | 69 | // iterables should cover list and set |
70 | - expect(GetUtils.isLengthEqualTo([].map(_id), 0), true); | ||
71 | - expect(GetUtils.isLengthEqualTo([1, 2].map(_id), 2), true); | 70 | + expect(GetUtils.isLengthEqualTo([].map(newId), 0), true); |
71 | + expect(GetUtils.isLengthEqualTo([1, 2].map(newId), 2), true); | ||
72 | 72 | ||
73 | expect(GetUtils.isLengthEqualTo({}, 0), true); | 73 | expect(GetUtils.isLengthEqualTo({}, 0), true); |
74 | expect(GetUtils.isLengthEqualTo({1: 1, 2: 1}, 2), true); | 74 | expect(GetUtils.isLengthEqualTo({1: 1, 2: 1}, 2), true); |
@@ -81,9 +81,9 @@ void main() { | @@ -81,9 +81,9 @@ void main() { | ||
81 | 81 | ||
82 | test('isLengthGreaterOrEqual should validate lengths', () { | 82 | test('isLengthGreaterOrEqual should validate lengths', () { |
83 | // iterables should cover list and set | 83 | // iterables should cover list and set |
84 | - expect(GetUtils.isLengthGreaterOrEqual([].map(_id), 0), true); | ||
85 | - expect(GetUtils.isLengthGreaterOrEqual([1, 2].map(_id), 2), true); | ||
86 | - expect(GetUtils.isLengthGreaterOrEqual([1, 2].map(_id), 1), true); | 84 | + expect(GetUtils.isLengthGreaterOrEqual([].map(newId), 0), true); |
85 | + expect(GetUtils.isLengthGreaterOrEqual([1, 2].map(newId), 2), true); | ||
86 | + expect(GetUtils.isLengthGreaterOrEqual([1, 2].map(newId), 1), true); | ||
87 | 87 | ||
88 | expect(GetUtils.isLengthGreaterOrEqual({}, 0), true); | 88 | expect(GetUtils.isLengthGreaterOrEqual({}, 0), true); |
89 | expect(GetUtils.isLengthGreaterOrEqual({1: 1, 2: 1}, 1), true); | 89 | expect(GetUtils.isLengthGreaterOrEqual({1: 1, 2: 1}, 1), true); |
@@ -97,9 +97,9 @@ void main() { | @@ -97,9 +97,9 @@ void main() { | ||
97 | 97 | ||
98 | test('isLengthLessOrEqual should validate lengths', () { | 98 | test('isLengthLessOrEqual should validate lengths', () { |
99 | // iterables should cover list and set | 99 | // iterables should cover list and set |
100 | - expect(GetUtils.isLengthLessOrEqual([].map(_id), 0), true); | ||
101 | - expect(GetUtils.isLengthLessOrEqual([1, 2].map(_id), 2), true); | ||
102 | - expect(GetUtils.isLengthLessOrEqual([1, 2].map(_id), 1), false); | 100 | + expect(GetUtils.isLengthLessOrEqual([].map(newId), 0), true); |
101 | + expect(GetUtils.isLengthLessOrEqual([1, 2].map(newId), 2), true); | ||
102 | + expect(GetUtils.isLengthLessOrEqual([1, 2].map(newId), 1), false); | ||
103 | 103 | ||
104 | expect(GetUtils.isLengthLessOrEqual({}, 0), true); | 104 | expect(GetUtils.isLengthLessOrEqual({}, 0), true); |
105 | expect(GetUtils.isLengthLessOrEqual({1: 1, 2: 1}, 1), false); | 105 | expect(GetUtils.isLengthLessOrEqual({1: 1, 2: 1}, 1), false); |
-
Please register or login to post a comment