Jonny Borges

refactor the project to follow flutter lint recommendations

Showing 81 changed files with 705 additions and 601 deletions
## [5.0.0-release-candidate]
Refactor StateManager, RouteManager and InstanceManager from scratch
Fixed Bugs
Added a Scopped DI
Api now uses Navigator 2
Added new RouteOutlet
Added a new futurize method to StateMixin, that tracks updates, errors, and states programatically,
## [4.6.1]
Fix GetConnect on Flutter web
... ...
... ... @@ -22,6 +22,8 @@ linter:
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
camel_case_types: false
constant_identifier_names: false
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
... ...
... ... @@ -6,7 +6,7 @@ import 'pt_br.dart';
class TranslationService extends Translations {
static Locale? get locale => Get.deviceLocale;
static final fallbackLocale = Locale('en', 'US');
static const fallbackLocale = Locale('en', 'US');
@override
Map<String, Map<String, String>> get keys => {
'en_US': en_US,
... ...
... ... @@ -6,7 +6,7 @@ import 'routes/app_pages.dart';
import 'shared/logger/logger_utils.dart';
void main() {
runApp(MyApp());
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
... ...
... ... @@ -10,7 +10,7 @@ class CountryView extends GetView<HomeController> {
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
decoration: const BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
colorFilter: ColorFilter.linearToSrgbGamma(),
... ... @@ -18,38 +18,36 @@ class CountryView extends GetView<HomeController> {
"https://images.pexels.com/photos/3902882/pexels-photo-3902882.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940"))),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0),
child: Container(
child: Scaffold(
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
title: Text('corona_by_country'.tr),
backgroundColor: Colors.transparent,
appBar: AppBar(
title: Text('corona_by_country'.tr),
backgroundColor: Colors.transparent,
elevation: 0,
centerTitle: true,
),
body: Center(
child: ListView.builder(
itemCount: controller.state.countries.length,
itemBuilder: (context, index) {
final country = controller.state.countries[index];
return ListTile(
onTap: () async {
//Get.rootDelegate.toNamed('/home/country');
final data = await Get.toNamed(
'/home/country/details?id=$index');
print(data);
},
trailing: CircleAvatar(
backgroundImage: NetworkImage(
"https://flagpedia.net/data/flags/normal/${country.countryCode.toLowerCase()}.png"),
),
title: Text(country.country),
subtitle: Text(
// ignore: lines_longer_than_80_chars
'${'total_infecteds'.tr}${' ${country.totalConfirmed}'}'),
);
}),
),
elevation: 0,
centerTitle: true,
),
body: Center(
child: ListView.builder(
itemCount: controller.state.countries.length,
itemBuilder: (context, index) {
final country = controller.state.countries[index];
return ListTile(
onTap: () async {
//Get.rootDelegate.toNamed('/home/country');
final data =
await Get.toNamed('/home/country/details?id=$index');
Get.log(data);
},
trailing: CircleAvatar(
backgroundImage: NetworkImage(
"https://flagpedia.net/data/flags/normal/${country.countryCode.toLowerCase()}.png"),
),
title: Text(country.country),
subtitle: Text(
// ignore: lines_longer_than_80_chars
'${'total_infecteds'.tr}${' ${country.totalConfirmed}'}'),
);
}),
),
),
),
... ...
... ... @@ -15,77 +15,79 @@ class DetailsView extends GetView<HomeController> {
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
colorFilter: ColorFilter.linearToSrgbGamma(),
colorFilter: const ColorFilter.linearToSrgbGamma(),
image: NetworkImage(
"https://flagpedia.net/data/flags/normal/${country.countryCode.toLowerCase()}.png"),
),
),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 15.0, sigmaY: 15.0),
child: Container(
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
title: Text('details'.tr),
backgroundColor: Colors.black12,
elevation: 0,
centerTitle: true,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${country.country}',
style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold),
),
SizedBox(
height: 35,
),
Text(
'total_confirmed'.tr,
style: TextStyle(
fontSize: 25,
),
),
Text(
'${country.totalConfirmed}',
style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
Text(
'total_deaths'.tr,
style: TextStyle(
fontSize: 25,
),
),
Text(
'${country.totalDeaths}',
style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
title: Text('details'.tr),
backgroundColor: Colors.black12,
elevation: 0,
centerTitle: true,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
country.country,
style:
const TextStyle(fontSize: 45, fontWeight: FontWeight.bold),
),
const SizedBox(
height: 35,
),
Text(
'total_confirmed'.tr,
style: const TextStyle(
fontSize: 25,
),
Text(
'total_recovered'.tr,
style: TextStyle(
fontSize: 25,
),
),
Text(
'${country.totalConfirmed}',
style:
const TextStyle(fontSize: 35, fontWeight: FontWeight.bold),
),
const SizedBox(
height: 10,
),
Text(
'total_deaths'.tr,
style: const TextStyle(
fontSize: 25,
),
Text(
'${country.totalRecovered}',
style: TextStyle(fontSize: 35, fontWeight: FontWeight.bold),
),
Text(
'${country.totalDeaths}',
style:
const TextStyle(fontSize: 35, fontWeight: FontWeight.bold),
),
const SizedBox(
height: 10,
),
Text(
'total_recovered'.tr,
style: const TextStyle(
fontSize: 25,
),
TextButton(
onPressed: () {
Get.back(result: 'djsoidjsoidj');
},
child: Text('back'))
],
)),
),
),
Text(
'${country.totalRecovered}',
style:
const TextStyle(fontSize: 35, fontWeight: FontWeight.bold),
),
TextButton(
onPressed: () {
Get.back(result: 'djsoidjsoidj');
},
child: const Text('back'))
],
)),
),
),
);
... ...
... ... @@ -9,7 +9,7 @@ class HomeView extends GetView<HomeController> {
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
decoration: const BoxDecoration(
color: Colors.white,
image: DecorationImage(
fit: BoxFit.cover,
... ... @@ -22,7 +22,7 @@ class HomeView extends GetView<HomeController> {
backgroundColor: Colors.transparent,
appBar: AppBar(
leading: IconButton(
icon: Icon(Icons.add),
icon: const Icon(Icons.add),
onPressed: () {
Get.snackbar('title', 'message');
},
... ... @@ -38,43 +38,45 @@ class HomeView extends GetView<HomeController> {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
const SizedBox(
height: 100,
),
Text(
'total_confirmed'.tr,
style: TextStyle(
style: const TextStyle(
fontSize: 30,
),
),
Text(
'${state!.global.totalConfirmed}',
style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold),
style: const TextStyle(
fontSize: 45, fontWeight: FontWeight.bold),
),
SizedBox(
const SizedBox(
height: 10,
),
Text(
'total_deaths'.tr,
style: TextStyle(
style: const TextStyle(
fontSize: 30,
),
),
Text(
'${state.global.totalDeaths}',
style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold),
style: const TextStyle(
fontSize: 45, fontWeight: FontWeight.bold),
),
SizedBox(
const SizedBox(
height: 10,
),
OutlinedButton(
style: OutlinedButton.styleFrom(
textStyle: TextStyle(color: Colors.black),
side: BorderSide(
textStyle: const TextStyle(color: Colors.black),
side: const BorderSide(
color: Colors.deepPurple,
width: 3,
),
shape: StadiumBorder(),
shape: const StadiumBorder(),
),
onPressed: () async {
//await Navigation Get.rootDelegate.toNamed('/home/country');
... ... @@ -82,7 +84,7 @@ class HomeView extends GetView<HomeController> {
},
child: Text(
'fetch_country'.tr,
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
),
... ... @@ -90,17 +92,17 @@ class HomeView extends GetView<HomeController> {
),
OutlinedButton(
style: OutlinedButton.styleFrom(
textStyle: TextStyle(color: Colors.black),
side: BorderSide(
textStyle: const TextStyle(color: Colors.black),
side: const BorderSide(
color: Colors.deepPurple,
width: 3,
),
shape: StadiumBorder(),
shape: const StadiumBorder(),
),
onPressed: () {
Get.updateLocale(Locale('pt', 'BR'));
Get.updateLocale(const Locale('pt', 'BR'));
},
child: Text(
child: const Text(
'Update language to Portuguese',
style: TextStyle(
fontWeight: FontWeight.bold,
... ...
... ... @@ -14,16 +14,16 @@ class AppPages {
static final routes = [
GetPage(
name: Routes.HOME,
page: () => HomeView(),
page: () => const HomeView(),
binding: HomeBinding(),
children: [
GetPage(
name: Routes.COUNTRY,
page: () => CountryView(),
page: () => const CountryView(),
children: [
GetPage(
name: Routes.DETAILS,
page: () => DetailsView(),
page: () => const DetailsView(),
),
],
),
... ...
mixin Logger {
// Sample of abstract logging function
static void write(String text, {bool isError = false}) {
// ignore: avoid_print
Future.microtask(() => print('** $text. isError: [$isError]'));
}
}
... ...
... ... @@ -3,13 +3,11 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:get_demo/pages/home/domain/adapters/repository_adapter.dart';
import 'package:get_demo/pages/home/domain/entity/cases_model.dart';
import 'package:get_demo/pages/home/presentation/controllers/home_controller.dart';
// import 'package:get_demo/routes/app_pages.dart';
// import 'package:get_test/get_test.dart';
import 'package:matcher/matcher.dart' as m;
import '../lib/pages/home/domain/adapters/repository_adapter.dart';
import '../lib/pages/home/domain/entity/cases_model.dart';
import '../lib/pages/home/presentation/controllers/home_controller.dart';
class MockRepositorySuccess implements IHomeRepository {
@override
... ... @@ -57,7 +55,7 @@ void main() {
test('Test Controller', () async {
/// Controller can't be on memory
expect(() => Get.find<HomeController>(tag: 'success'),
throwsA(m.TypeMatcher<String>()));
throwsA(const TypeMatcher<String>()));
/// binding will put the controller on memory
binding.dependencies();
... ... @@ -72,7 +70,7 @@ void main() {
expect(controller.status.isLoading, true);
/// await time request
await Future.delayed(Duration(milliseconds: 100));
await Future.delayed(const Duration(milliseconds: 100));
/// test if status is success
expect(controller.status.isSuccess, true);
... ...
... ... @@ -8,7 +8,7 @@ class DashboardController extends GetxController {
void onReady() {
super.onReady();
Timer.periodic(
Duration(seconds: 1),
const Duration(seconds: 1),
(timer) {
now.value = DateTime.now();
},
... ...
... ... @@ -4,6 +4,8 @@ import 'package:get/get.dart';
import '../controllers/dashboard_controller.dart';
class DashboardView extends GetView<DashboardController> {
const DashboardView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
... ... @@ -12,7 +14,7 @@ class DashboardView extends GetView<DashboardController> {
() => Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
const Text(
'DashboardView is working',
style: TextStyle(fontSize: 20),
),
... ...
... ... @@ -14,7 +14,6 @@ class HomeView extends GetView<HomeController> {
final delegate = context.navigation;
//This router outlet handles the appbar and the bottom navigation bar
final currentLocation = context.location;
print(currentLocation);
var currentIndex = 0;
if (currentLocation.startsWith(Routes.products) == true) {
currentIndex = 2;
... ... @@ -46,7 +45,7 @@ class HomeView extends GetView<HomeController> {
default:
}
},
items: [
items: const [
// _Paths.HOME + [Empty]
BottomNavigationBarItem(
icon: Icon(Icons.home),
... ...
... ... @@ -6,6 +6,8 @@ import '../../../routes/app_pages.dart';
import '../controllers/login_controller.dart';
class LoginView extends GetView<LoginController> {
const LoginView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
... ... @@ -25,7 +27,7 @@ class LoginView extends GetView<LoginController> {
},
),
MaterialButton(
child: Text(
child: const Text(
'Do LOGIN !!',
style: TextStyle(color: Colors.blue, fontSize: 20),
),
... ...
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controllers/product_details_controller.dart';
class ProductDetailsView extends GetWidget<ProductDetailsController> {
const ProductDetailsView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
... ... @@ -12,7 +13,7 @@ class ProductDetailsView extends GetWidget<ProductDetailsController> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
const Text(
'ProductDetailsView is working',
style: TextStyle(fontSize: 20),
),
... ...
... ... @@ -11,13 +11,13 @@ class ProductsView extends GetView<ProductsController> {
return Scaffold(
floatingActionButton: FloatingActionButton.extended(
onPressed: () => controller.loadDemoProductsFromSomeWhere(),
label: Text('Add'),
label: const Text('Add'),
),
body: Column(
children: [
Hero(
const Hero(
tag: 'heroLogo',
child: const FlutterLogo(),
child: FlutterLogo(),
),
Expanded(
child: Obx(
... ...
... ... @@ -5,6 +5,8 @@ import '../../../routes/app_pages.dart';
import '../controllers/profile_controller.dart';
class ProfileView extends GetView<ProfileController> {
const ProfileView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
... ... @@ -13,16 +15,16 @@ class ProfileView extends GetView<ProfileController> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
const Text(
'ProfileView is working',
style: TextStyle(fontSize: 20),
),
Hero(
const Hero(
tag: 'heroLogo',
child: const FlutterLogo(),
child: FlutterLogo(),
),
MaterialButton(
child: Text('Show a test dialog'),
child: const Text('Show a test dialog'),
onPressed: () {
//shows a dialog
Get.defaultDialog(
... ... @@ -32,7 +34,7 @@ class ProfileView extends GetView<ProfileController> {
},
),
MaterialButton(
child: Text('Show a test dialog in Home router outlet'),
child: const Text('Show a test dialog in Home router outlet'),
onPressed: () {
//shows a dialog
... ...
... ... @@ -19,7 +19,7 @@ class DrawerWidget extends StatelessWidget {
color: Colors.red,
),
ListTile(
title: Text('Home'),
title: const Text('Home'),
onTap: () {
Get.toNamed(Routes.home);
//to close the drawer
... ... @@ -28,7 +28,7 @@ class DrawerWidget extends StatelessWidget {
},
),
ListTile(
title: Text('Settings'),
title: const Text('Settings'),
onTap: () {
Get.toNamed(Routes.settings);
//to close the drawer
... ... @@ -38,7 +38,7 @@ class DrawerWidget extends StatelessWidget {
),
if (AuthService.to.isLoggedInValue)
ListTile(
title: Text(
title: const Text(
'Logout',
style: TextStyle(
color: Colors.red,
... ... @@ -54,7 +54,7 @@ class DrawerWidget extends StatelessWidget {
),
if (!AuthService.to.isLoggedInValue)
ListTile(
title: Text(
title: const Text(
'Login',
style: TextStyle(
color: Colors.blue,
... ...
... ... @@ -6,6 +6,8 @@ import '../controllers/root_controller.dart';
import 'drawer.dart';
class RootView extends GetView<RootController> {
const RootView({super.key});
@override
Widget build(BuildContext context) {
return RouterOutlet.builder(
... ... @@ -13,7 +15,7 @@ class RootView extends GetView<RootController> {
builder: (context) {
final title = context.location;
return Scaffold(
drawer: DrawerWidget(),
drawer: const DrawerWidget(),
appBar: AppBar(
title: Text(title),
centerTitle: true,
... ...
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controllers/settings_controller.dart';
class SettingsView extends GetView<SettingsController> {
const SettingsView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
return const Scaffold(
body: Center(
child: Text(
'SettingsView is working',
... ...
... ... @@ -18,11 +18,11 @@ class SplashService extends GetxService {
Future<void> _initFunction() async {
final t = Timer.periodic(
Duration(milliseconds: 500),
const Duration(milliseconds: 500),
(t) => _changeActiveString(),
);
//simulate some long running operation
await Future.delayed(Duration(seconds: 5));
await Future.delayed(const Duration(seconds: 5));
//cancel the timer once we are done
t.cancel();
}
... ...
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controllers/splash_service.dart';
class SplashView extends GetView<SplashService> {
const SplashView({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
... ... @@ -15,10 +16,10 @@ class SplashView extends GetView<SplashService> {
Obx(
() => Text(
controller.welcomeStr[controller.activeStr.value],
style: TextStyle(fontSize: 20),
style: const TextStyle(fontSize: 20),
),
),
CircularProgressIndicator(),
const CircularProgressIndicator(),
],
),
),
... ...
... ... @@ -28,7 +28,7 @@ class AppPages {
static final routes = [
GetPage(
name: '/',
page: () => RootView(),
page: () => const RootView(),
bindings: [RootBinding()],
participatesInRootNavigator: true,
preventDuplicates: true,
... ... @@ -39,7 +39,7 @@ class AppPages {
EnsureNotAuthedMiddleware(),
],
name: _Paths.login,
page: () => LoginView(),
page: () => const LoginView(),
bindings: [LoginBinding()],
),
GetPage(
... ... @@ -53,7 +53,7 @@ class AppPages {
children: [
GetPage(
name: _Paths.dashboard,
page: () => DashboardView(),
page: () => const DashboardView(),
bindings: [
DashboardBinding(),
],
... ... @@ -64,7 +64,7 @@ class AppPages {
EnsureAuthMiddleware(),
],
name: _Paths.profile,
page: () => ProfileView(),
page: () => const ProfileView(),
title: 'Profile',
transition: Transition.size,
bindings: [ProfileBinding()],
... ... @@ -82,8 +82,8 @@ class AppPages {
name: _Paths.productDetails,
transition: Transition.cupertino,
showCupertinoParallax: true,
page: () => ProductDetailsView(),
bindings: [],
page: () => const ProductDetailsView(),
bindings: const [],
middlewares: [
//only enter this route when authed
EnsureAuthMiddleware(),
... ... @@ -95,7 +95,7 @@ class AppPages {
),
GetPage(
name: _Paths.settings,
page: () => SettingsView(),
page: () => const SettingsView(),
bindings: [
SettingsBinding(),
],
... ...
... ... @@ -268,9 +268,9 @@ class GetConnect extends GetConnectInterface {
}) {
_checkIfDisposed(isHttp: false);
final _socket = GetSocket(_concatUrl(url)!, ping: ping);
sockets.add(_socket);
return _socket;
final newSocket = GetSocket(_concatUrl(url)!, ping: ping);
sockets.add(newSocket);
return newSocket;
}
String? _concatUrl(String? url) {
... ...
... ... @@ -4,7 +4,8 @@ List<int> fileToBytes(dynamic data) {
if (data is List<int>) {
return data;
} else {
throw FormatException('File is not "File" or "String" or "List<int>"');
throw const FormatException(
'File is not "File" or "String" or "List<int>"');
}
}
... ...
... ... @@ -12,7 +12,8 @@ List<int> fileToBytes(dynamic data) {
} else if (data is List<int>) {
return data;
} else {
throw FormatException('File is not "File" or "String" or "List<int>"');
throw const FormatException(
'File is not "File" or "String" or "List<int>"');
}
}
... ...
... ... @@ -25,9 +25,9 @@ class FormData {
static const int _maxBoundaryLength = 70;
static String _getBoundary() {
final _random = Random();
final newRandom = Random();
var list = List<int>.generate(_maxBoundaryLength - GET_BOUNDARY.length,
(_) => boundaryCharacters[_random.nextInt(boundaryCharacters.length)],
(_) => boundaryCharacters[newRandom.nextInt(boundaryCharacters.length)],
growable: false);
return '$GET_BOUNDARY${String.fromCharCodes(list)}';
}
... ...
... ... @@ -161,11 +161,11 @@ extension Inst on GetInterface {
_InstanceBuilderFactory<S>? dep;
if (_singl.containsKey(key)) {
final _dep = _singl[key];
if (_dep == null || !_dep.isDirty) {
final newDep = _singl[key];
if (newDep == null || !newDep.isDirty) {
return;
} else {
dep = _dep as _InstanceBuilderFactory<S>;
dep = newDep as _InstanceBuilderFactory<S>;
}
}
_singl[key] = _InstanceBuilderFactory<S>(
... ...
... ... @@ -44,7 +44,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
final bool removeTop;
@override
Duration get transitionDuration => Duration(milliseconds: 700);
Duration get transitionDuration => const Duration(milliseconds: 700);
@override
bool get barrierDismissible => isDismissible;
... ...
... ... @@ -51,9 +51,9 @@ class GetDialogRoute<T> extends PopupRoute<T> {
Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return Semantics(
child: widget(context, animation, secondaryAnimation),
scopesRoute: true,
explicitChildNodes: true,
child: widget(context, animation, secondaryAnimation),
);
}
... ...
... ... @@ -187,7 +187,7 @@ extension ExtensionDialog on GetInterface {
actions.add(TextButton(
style: TextButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 8),
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
shape: RoundedRectangleBorder(
side: BorderSide(
color: buttonColor ?? theme.colorScheme.secondary,
... ... @@ -230,8 +230,8 @@ extension ExtensionDialog on GetInterface {
}
Widget baseAlertDialog = AlertDialog(
titlePadding: titlePadding ?? EdgeInsets.all(8),
contentPadding: contentPadding ?? EdgeInsets.all(8),
titlePadding: titlePadding ?? const EdgeInsets.all(8),
contentPadding: contentPadding ?? const EdgeInsets.all(8),
backgroundColor: backgroundColor ?? theme.dialogBackgroundColor,
shape: RoundedRectangleBorder(
... ... @@ -244,7 +244,7 @@ extension ExtensionDialog on GetInterface {
content ??
Text(middleText,
textAlign: TextAlign.center, style: middleTextStyle),
SizedBox(height: 16),
const SizedBox(height: 16),
ButtonTheme(
minWidth: 78.0,
height: 34.0,
... ... @@ -433,14 +433,14 @@ extension ExtensionSnackbar on GetInterface {
),
snackPosition: snackPosition ?? SnackPosition.top,
borderRadius: borderRadius ?? 15,
margin: margin ?? EdgeInsets.symmetric(horizontal: 10),
margin: margin ?? const EdgeInsets.symmetric(horizontal: 10),
duration: duration,
barBlur: barBlur ?? 7.0,
backgroundColor: backgroundColor ?? Colors.grey.withOpacity(0.2),
icon: icon,
shouldIconPulse: shouldIconPulse ?? true,
maxWidth: maxWidth,
padding: padding ?? EdgeInsets.all(16),
padding: padding ?? const EdgeInsets.all(16),
borderColor: borderColor,
borderWidth: borderWidth,
leftBarIndicatorColor: leftBarIndicatorColor,
... ... @@ -457,7 +457,7 @@ extension ExtensionSnackbar on GetInterface {
snackStyle: snackStyle ?? SnackStyle.floating,
forwardAnimationCurve: forwardAnimationCurve ?? Curves.easeOutCirc,
reverseAnimationCurve: reverseAnimationCurve ?? Curves.easeOutCirc,
animationDuration: animationDuration ?? Duration(seconds: 1),
animationDuration: animationDuration ?? const Duration(seconds: 1),
overlayBlur: overlayBlur ?? 0.0,
overlayColor: overlayColor ?? Colors.transparent,
userInputForm: userInputForm);
... ... @@ -1082,14 +1082,14 @@ extension GetNavigationExt on GetInterface {
}
GetDelegate searchDelegate(dynamic k) {
GetDelegate _key;
GetDelegate key;
if (k == null) {
_key = Get.rootController.rootDelegate;
key = Get.rootController.rootDelegate;
} else {
if (!keys.containsKey(k)) {
throw 'Route id ($k) not found';
}
_key = keys[k]!;
key = keys[k]!;
}
// if (_key.listenersLength == 0 && !testMode) {
... ... @@ -1102,7 +1102,7 @@ extension GetNavigationExt on GetInterface {
// """;
// }
return _key;
return key;
}
/// give current arguments
... ... @@ -1156,11 +1156,11 @@ extension GetNavigationExt on GetInterface {
/// give access to Theme.of(context)
ThemeData get theme {
var _theme = ThemeData.fallback();
var theme = ThemeData.fallback();
if (context != null) {
_theme = Theme.of(context!);
theme = Theme.of(context!);
}
return _theme;
return theme;
}
/// The current null safe [WidgetsBinding]
... ... @@ -1283,8 +1283,8 @@ extension OverlayExt on GetInterface {
});
final overlayEntryLoader = OverlayEntry(builder: (context) {
return loadingWidget ??
Center(
child: Container(
const Center(
child: SizedBox(
height: 90,
width: 90,
child: Text('Loading...'),
... ...
... ... @@ -65,7 +65,7 @@ class GetCupertinoApp extends StatelessWidget {
final List<Bind> binds;
final ScrollBehavior? scrollBehavior;
GetCupertinoApp({
const GetCupertinoApp({
Key? key,
this.theme,
this.navigatorKey,
... ... @@ -125,18 +125,7 @@ class GetCupertinoApp extends StatelessWidget {
routerDelegate = null,
super(key: key);
static String _cleanRouteName(String name) {
name = name.replaceAll('() => ', '');
/// uncommonent for URL styling.
// name = name.paramCase!;
if (!name.startsWith('/')) {
name = '/$name';
}
return Uri.tryParse(name)?.toString() ?? name;
}
GetCupertinoApp.router({
const GetCupertinoApp.router({
Key? key,
this.theme,
this.routeInformationProvider,
... ... @@ -240,8 +229,8 @@ class GetCupertinoApp extends StatelessWidget {
? TextDirection.rtl
: TextDirection.ltr),
child: builder == null
? (child ?? Material())
: builder!(context, child ?? Material()),
? (child ?? const Material())
: builder!(context, child ?? const Material()),
),
title: title,
onGenerateTitle: onGenerateTitle,
... ...
... ... @@ -129,7 +129,7 @@ class GetMaterialApp extends StatelessWidget {
routerDelegate = null,
super(key: key);
GetMaterialApp.router({
const GetMaterialApp.router({
Key? key,
this.routeInformationProvider,
this.scaffoldMessengerKey,
... ... @@ -240,7 +240,6 @@ class GetMaterialApp extends StatelessWidget {
// ],
child: Builder(builder: (context) {
final controller = GetRoot.of(context);
print('ROUTERRRR ${controller.config.routerDelegate}');
return MaterialApp.router(
routerDelegate: controller.config.routerDelegate,
routeInformationParser: controller.config.routeInformationParser,
... ... @@ -253,8 +252,8 @@ class GetMaterialApp extends StatelessWidget {
? TextDirection.rtl
: TextDirection.ltr),
child: builder == null
? (child ?? Material())
: builder!(context, child ?? Material()),
? (child ?? const Material())
: builder!(context, child ?? const Material()),
),
title: title,
onGenerateTitle: onGenerateTitle,
... ...
... ... @@ -276,7 +276,7 @@ class ConfigData {
}
class GetRoot extends StatefulWidget {
GetRoot({
const GetRoot({
Key? key,
required this.config,
required this.child,
... ...
... ... @@ -132,15 +132,15 @@ class GetPageRoute<T> extends PageRoute<T>
final dep = item.dependencies();
if (dep is List<Bind>) {
_child = Binds(
child: middlewareRunner.runOnPageBuilt(pageToBuild()),
binds: dep,
child: middlewareRunner.runOnPageBuilt(pageToBuild()),
);
}
}
} else if (bindingsToBind is List<Bind>) {
_child = Binds(
child: middlewareRunner.runOnPageBuilt(pageToBuild()),
binds: bindingsToBind,
child: middlewareRunner.runOnPageBuilt(pageToBuild()),
);
}
}
... ...
... ... @@ -89,7 +89,7 @@ class SlideDownTransition {
Widget child) {
return SlideTransition(
position: Tween<Offset>(
begin: Offset(0.0, 1.0),
begin: const Offset(0.0, 1.0),
end: Offset.zero,
).animate(animation),
child: child,
... ... @@ -107,7 +107,7 @@ class SlideLeftTransition {
Widget child) {
return SlideTransition(
position: Tween<Offset>(
begin: Offset(-1.0, 0.0),
begin: const Offset(-1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: child,
... ... @@ -125,7 +125,7 @@ class SlideRightTransition {
Widget child) {
return SlideTransition(
position: Tween<Offset>(
begin: Offset(1.0, 0.0),
begin: const Offset(1.0, 0.0),
end: Offset.zero,
).animate(animation),
child: child,
... ... @@ -143,7 +143,7 @@ class SlideTopTransition {
Widget child) {
return SlideTransition(
position: Tween<Offset>(
begin: Offset(0.0, -1.0),
begin: const Offset(0.0, -1.0),
end: Offset.zero,
).animate(animation),
child: child,
... ...
... ... @@ -48,7 +48,7 @@ class GetNavigator extends Navigator {
);
GetNavigator({
GlobalKey<NavigatorState>? key,
Key? key,
bool Function(Route<dynamic>, dynamic)? onPopPage,
required List<GetPage> pages,
List<NavigatorObserver>? observers,
... ...
... ... @@ -164,19 +164,19 @@ class GetPage<T> extends Page<T> {
@override
Route<T> createRoute(BuildContext context) {
// return GetPageRoute<T>(settings: this, page: page);
final _page = PageRedirect(
final page = PageRedirect(
route: this,
settings: this,
unknownRoute: unknownRoute,
).getPageToRoute<T>(this, unknownRoute, context);
return _page;
return page;
}
static PathDecoded _nameToRegex(String path) {
var keys = <String?>[];
String _replace(Match pattern) {
String recursiveReplace(Match pattern) {
var buffer = StringBuffer('(?:');
if (pattern[1] != null) buffer.write('.');
... ... @@ -188,7 +188,7 @@ class GetPage<T> extends Page<T> {
}
var stringPath = '$path/?'
.replaceAllMapped(RegExp(r'(\.)?:(\w+)(\?)?'), _replace)
.replaceAllMapped(RegExp(r'(\.)?:(\w+)(\?)?'), recursiveReplace)
.replaceAll('//', '/');
return PathDecoded(RegExp('^$stringPath\$'), keys);
... ...
... ... @@ -93,7 +93,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder>
}) : navigatorKey = navigatorKey ?? GlobalKey<NavigatorState>(),
notFoundRoute = notFoundRoute ??= GetPage(
name: '/404',
page: () => Scaffold(
page: () => const Scaffold(
body: Center(child: Text('Route not found')),
),
) {
... ...
... ... @@ -380,8 +380,8 @@ Cannot read the previousTitle for a route that has not yet been installed''',
? CurvedAnimation(parent: animation, curve: finalCurve)
: animation,
secondaryRouteAnimation: secondaryAnimation,
child: child,
linearTransition: linearTransition,
child: child,
);
} else {
if (route.customTransition != null) {
... ... @@ -636,7 +636,7 @@ Cannot read the previousTitle for a route that has not yet been installed''',
));
case Transition.fade:
return FadeUpwardsPageTransitionsBuilder().buildTransitions(
return const FadeUpwardsPageTransitionsBuilder().buildTransitions(
route,
context,
animation,
... ... @@ -656,7 +656,7 @@ Cannot read the previousTitle for a route that has not yet been installed''',
));
case Transition.topLevel:
return ZoomPageTransitionsBuilder().buildTransitions(
return const ZoomPageTransitionsBuilder().buildTransitions(
route,
context,
animation,
... ... @@ -676,7 +676,7 @@ Cannot read the previousTitle for a route that has not yet been installed''',
));
case Transition.native:
return PageTransitionsTheme().buildTransitions(
return const PageTransitionsTheme().buildTransitions(
route,
context,
iosAnimation,
... ...
... ... @@ -57,17 +57,17 @@ class Dependencies {
}
abstract class Module extends StatefulWidget {
Module({Key? key}) : super(key: key);
const Module({Key? key}) : super(key: key);
Widget view(BuildContext context);
void dependencies(Dependencies i);
@override
_ModuleState createState() => _ModuleState();
ModuleState createState() => ModuleState();
}
class _ModuleState extends State<Module> {
class ModuleState extends State<Module> {
@override
void initState() {
RouterReportManager.instance.reportCurrentRoute(this);
... ...
... ... @@ -57,10 +57,10 @@ class RouteDecoder {
}
void replaceArguments(Object? arguments) {
final _route = route;
if (_route != null) {
final index = currentTreeBranch.indexOf(_route);
currentTreeBranch[index] = _route.copyWith(arguments: arguments);
final newRoute = route;
if (newRoute != null) {
final index = currentTreeBranch.indexOf(newRoute);
currentTreeBranch[index] = newRoute.copyWith(arguments: arguments);
}
}
... ...
... ... @@ -130,8 +130,8 @@ class MiddlewareRunner {
final List<GetMiddleware>? _middlewares;
List<GetMiddleware> _getMiddlewares() {
final _m = _middlewares ?? <GetMiddleware>[];
return List.of(_m)
final newMiddleware = _middlewares ?? <GetMiddleware>[];
return List.of(newMiddleware)
..sort(
(a, b) => (a.priority ?? 0).compareTo(b.priority ?? 0),
);
... ... @@ -198,34 +198,33 @@ class PageRedirect {
GetPageRoute<T> getPageToRoute<T>(
GetPage rou, GetPage? unk, BuildContext context) {
while (needRecheck(context)) {}
final _r = (isUnknown ? unk : rou)!;
final r = (isUnknown ? unk : rou)!;
return GetPageRoute<T>(
page: _r.page,
parameter: _r.parameters,
alignment: _r.alignment,
title: _r.title,
maintainState: _r.maintainState,
routeName: _r.name,
settings: _r,
curve: _r.curve,
showCupertinoParallax: _r.showCupertinoParallax,
gestureWidth: _r.gestureWidth,
opaque: _r.opaque,
customTransition: _r.customTransition,
bindings: _r.bindings,
binding: _r.binding,
binds: _r.binds,
transitionDuration:
_r.transitionDuration ?? Get.defaultTransitionDuration,
page: r.page,
parameter: r.parameters,
alignment: r.alignment,
title: r.title,
maintainState: r.maintainState,
routeName: r.name,
settings: r,
curve: r.curve,
showCupertinoParallax: r.showCupertinoParallax,
gestureWidth: r.gestureWidth,
opaque: r.opaque,
customTransition: r.customTransition,
bindings: r.bindings,
binding: r.binding,
binds: r.binds,
transitionDuration: r.transitionDuration ?? Get.defaultTransitionDuration,
reverseTransitionDuration:
_r.reverseTransitionDuration ?? Get.defaultTransitionDuration,
r.reverseTransitionDuration ?? Get.defaultTransitionDuration,
// performIncomeAnimation: _r.performIncomeAnimation,
// performOutGoingAnimation: _r.performOutGoingAnimation,
transition: _r.transition,
popGesture: _r.popGesture,
fullscreenDialog: _r.fullscreenDialog,
middlewares: _r.middlewares,
transition: r.transition,
popGesture: r.popGesture,
fullscreenDialog: r.fullscreenDialog,
middlewares: r.middlewares,
);
}
... ...
... ... @@ -4,14 +4,14 @@ import '../router_report.dart';
import 'default_route.dart';
class RouteReport extends StatefulWidget {
RouteReport({Key? key, required this.builder}) : super(key: key);
const RouteReport({Key? key, required this.builder}) : super(key: key);
final WidgetBuilder builder;
@override
_RouteReportState createState() => _RouteReportState();
RouteReportState createState() => RouteReportState();
}
class _RouteReportState extends State<RouteReport> with RouteReportMixin {
class RouteReportState extends State<RouteReport> with RouteReportMixin {
@override
void initState() {
RouterReportManager.instance.reportCurrentRoute(this);
... ...
... ... @@ -9,12 +9,13 @@ class RouterOutlet<TDelegate extends RouterDelegate<T>, T extends Object>
//keys
RouterOutlet.builder({
super.key,
TDelegate? delegate,
required this.builder,
}) : routerDelegate = delegate ?? Get.delegate<TDelegate, T>()!,
super();
}) : routerDelegate = delegate ?? Get.delegate<TDelegate, T>()!;
RouterOutlet({
Key? key,
TDelegate? delegate,
required Iterable<GetPage> Function(T currentNavStack) pickPages,
required Widget Function(
... ... @@ -24,6 +25,7 @@ class RouterOutlet<TDelegate extends RouterDelegate<T>, T extends Object>
)
pageBuilder,
}) : this.builder(
key: key,
builder: (context) {
final currentConfig = context.delegate.currentConfiguration as T?;
final rDelegate = context.delegate as TDelegate;
... ... @@ -37,11 +39,11 @@ class RouterOutlet<TDelegate extends RouterDelegate<T>, T extends Object>
delegate: delegate,
);
@override
_RouterOutletState<TDelegate, T> createState() =>
_RouterOutletState<TDelegate, T>();
RouterOutletState<TDelegate, T> createState() =>
RouterOutletState<TDelegate, T>();
}
class _RouterOutletState<TDelegate extends RouterDelegate<T>, T extends Object>
class RouterOutletState<TDelegate extends RouterDelegate<T>, T extends Object>
extends State<RouterOutlet<TDelegate, T>> {
RouterDelegate? delegate;
late ChildBackButtonDispatcher _backButtonDispatcher;
... ... @@ -80,7 +82,7 @@ class _RouterOutletState<TDelegate extends RouterDelegate<T>, T extends Object>
}
}
// class _RouterOutletState<TDelegate extends RouterDelegate<T>,
// class RouterOutletState<TDelegate extends RouterDelegate<T>,
//T extends Object>
// extends State<RouterOutlet<TDelegate, T>> {
// TDelegate get delegate => context.delegate as TDelegate;
... ... @@ -152,11 +154,11 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, RouteDecoder> {
delegate: delegate,
);
GetRouterOutlet.pickPages({
super.key,
Widget Function(GetDelegate delegate)? emptyWidget,
GetPage Function(GetDelegate delegate)? emptyPage,
required Iterable<GetPage> Function(RouteDecoder currentNavStack) pickPages,
bool Function(Route<dynamic>, dynamic)? onPopPage,
GlobalKey<NavigatorState>? key,
GetDelegate? delegate,
}) : super(
pageBuilder: (context, rDelegate, pages) {
... ... @@ -179,13 +181,14 @@ class GetRouterOutlet extends RouterOutlet<GetDelegate, RouteDecoder> {
key: key,
);
}
return (emptyWidget?.call(rDelegate) ?? SizedBox.shrink());
return (emptyWidget?.call(rDelegate) ?? const SizedBox.shrink());
},
pickPages: pickPages,
delegate: delegate ?? Get.rootController.rootDelegate,
);
GetRouterOutlet.builder({
super.key,
required Widget Function(
BuildContext context,
)
... ...
... ... @@ -12,7 +12,7 @@ typedef SnackbarStatusCallback = void Function(SnackbarStatus? status);
@Deprecated('use GetSnackBar')
class GetBar extends GetSnackBar {
GetBar({
const GetBar({
Key? key,
String? title,
String? message,
... ... @@ -293,11 +293,11 @@ class GetSnackBarState extends State<GetSnackBar>
AnimationController? _fadeController;
late Animation<double> _fadeAnimation;
final Widget _emptyWidget = SizedBox(width: 0.0, height: 0.0);
final Widget _emptyWidget = const SizedBox(width: 0.0, height: 0.0);
final double _initialOpacity = 1.0;
final double _finalOpacity = 0.4;
final Duration _pulseAnimationDuration = Duration(seconds: 1);
final Duration _pulseAnimationDuration = const Duration(seconds: 1);
late bool _isTitlePresent;
late double _messageTopMargin;
... ... @@ -513,9 +513,9 @@ You need to either use message[String], or messageText[Widget] or define a userI
padding: const EdgeInsets.only(
left: 8.0, right: 8.0, bottom: 8.0, top: 16.0),
child: FocusScope(
child: widget.userInputForm!,
node: _focusNode,
autofocus: true,
child: widget.userInputForm!,
),
),
);
... ... @@ -581,7 +581,7 @@ You need to either use message[String], or messageText[Widget] or define a userI
child: widget.titleText ??
Text(
widget.title ?? "",
style: TextStyle(
style: const TextStyle(
fontSize: 16.0,
color: Colors.white,
fontWeight: FontWeight.bold,
... ... @@ -600,8 +600,8 @@ You need to either use message[String], or messageText[Widget] or define a userI
child: widget.messageText ??
Text(
widget.message ?? "",
style:
TextStyle(fontSize: 14.0, color: Colors.white),
style: const TextStyle(
fontSize: 14.0, color: Colors.white),
),
),
],
... ...
... ... @@ -220,15 +220,15 @@ class SnackbarController {
],
OverlayEntry(
builder: (context) => Semantics(
focused: false,
container: true,
explicitChildNodes: true,
child: AlignTransition(
alignment: _animation,
child: snackbar.isDismissible
? _getDismissibleSnack(child)
: _getSnackbarContainer(child),
),
focused: false,
container: true,
explicitChildNodes: true,
),
maintainState: false,
opaque: false,
... ... @@ -239,10 +239,10 @@ class SnackbarController {
Widget _getBodyWidget() {
return Builder(builder: (_) {
return GestureDetector(
child: snackbar,
onTap: snackbar.onTap != null
? () => snackbar.onTap?.call(snackbar)
: null,
child: snackbar,
);
});
}
... ...
... ... @@ -226,11 +226,11 @@ Worker debounce<T>(
void Function()? onDone,
bool? cancelOnError,
}) {
final _debouncer =
final newDebouncer =
Debouncer(delay: time ?? const Duration(milliseconds: 800));
StreamSubscription sub = listener.listen(
(event) {
_debouncer(() {
newDebouncer(() {
callback(event);
});
},
... ...
... ... @@ -22,6 +22,7 @@ class GetX<T extends GetLifeCycleMixin> extends StatefulWidget {
final String? tag;
const GetX({
super.key,
this.tag,
required this.builder,
this.global = true,
... ...
... ... @@ -32,7 +32,7 @@ mixin StateMixin<T> on ListNotifier {
void _fillInitialStatus() {
_status = (_value == null || _value!._isEmpty())
? GetStatus<T>.loading()
: GetStatus<T>.success(_value!);
: GetStatus<T>.success(_value as T);
}
GetStatus<T> get status {
... ... @@ -231,12 +231,12 @@ extension StateExt<T> on StateMixin<T> {
: Center(child: Text('A error occurred: ${status.errorMessage}'));
} else if (status.isEmpty) {
return onEmpty ??
SizedBox.shrink(); // Also can be widget(null); but is risky
const SizedBox.shrink(); // Also can be widget(null); but is risky
} else if (status.isSuccess) {
return widget(value);
} else if (status.isCustom) {
return onCustom?.call(_) ??
SizedBox.shrink(); // Also can be widget(null); but is risky
const SizedBox.shrink(); // Also can be widget(null); but is risky
}
return widget(value);
});
... ...
... ... @@ -24,7 +24,7 @@ abstract class ObxWidget extends ObxStatelessWidget {
class Obx extends ObxWidget {
final WidgetCallback builder;
const Obx(this.builder);
const Obx(this.builder, {super.key});
@override
Widget build(BuildContext context) {
... ...
... ... @@ -482,7 +482,7 @@ class BindElement<T> extends InheritedElement {
/// setState "link" from the Controller.
void _subscribeToController() {
if (widget.filter != null) {
_filter = widget.filter!(_controller!);
_filter = widget.filter!(_controller as T);
}
final filter = _filter != null ? _filterUpdate : getUpdate;
final localController = _controller;
... ... @@ -510,7 +510,7 @@ class BindElement<T> extends InheritedElement {
}
void _filterUpdate() {
var newFilter = widget.filter!(_controller!);
var newFilter = widget.filter!(_controller as T);
if (newFilter != _filter) {
_filter = newFilter;
getUpdate();
... ...
... ... @@ -176,11 +176,11 @@ class Notifier {
_notifyData?.disposers.add(listener);
}
void read(ListNotifierSingleMixin _updaters) {
void read(ListNotifierSingleMixin updaters) {
final listener = _notifyData?.updater;
if (listener != null && !_updaters.containsListener(listener)) {
_updaters.addListener(listener);
add(() => _updaters.removeListener(listener));
if (listener != null && !updaters.containsListener(listener)) {
updaters.addListener(listener);
add(() => updaters.removeListener(listener));
}
}
... ... @@ -188,7 +188,7 @@ class Notifier {
_notifyData = data;
final result = builder();
if (data.disposers.isEmpty && data.throwException) {
throw ObxError();
throw const ObxError();
}
_notifyData = null;
return result;
... ...
... ... @@ -38,12 +38,16 @@ class ValueBuilder<T> extends StatefulWidget {
}) : super(key: key);
@override
_ValueBuilderState<T> createState() => _ValueBuilderState<T>(initialValue);
ValueBuilderState<T> createState() => ValueBuilderState<T>();
}
class _ValueBuilderState<T> extends State<ValueBuilder<T>> {
T value;
_ValueBuilderState(this.value);
class ValueBuilderState<T> extends State<ValueBuilder<T>> {
late T value;
@override
void initState() {
value = widget.initialValue;
super.initState();
}
@override
Widget build(BuildContext context) => widget.builder(value, updater);
... ...
import 'dart:math';
extension Precision on double {
extension DoubleExt on double {
double toPrecision(int fractionDigits) {
var mod = pow(10, fractionDigits.toDouble()).toDouble();
return ((this * mod).round().toDouble() / mod);
}
Duration get milliseconds => Duration(microseconds: (this * 1000).round());
Duration get ms => milliseconds;
Duration get seconds => Duration(milliseconds: (this * 1000).round());
Duration get minutes =>
Duration(seconds: (this * Duration.secondsPerMinute).round());
Duration get hours =>
Duration(minutes: (this * Duration.minutesPerHour).round());
Duration get days => Duration(hours: (this * Duration.hoursPerDay).round());
}
... ...
... ... @@ -3,6 +3,7 @@ export 'double_extensions.dart';
export 'duration_extensions.dart';
export 'dynamic_extensions.dart';
export 'event_loop_extensions.dart';
export 'int_extensions.dart';
export 'internacionalization.dart' hide FirstWhereExt;
export 'iterable_extensions.dart';
export 'num_extensions.dart';
... ...
extension DurationExt on int {
Duration get seconds => Duration(seconds: this);
Duration get days => Duration(days: this);
Duration get hours => Duration(hours: this);
Duration get minutes => Duration(minutes: this);
Duration get milliseconds => Duration(milliseconds: this);
Duration get microseconds => Duration(microseconds: this);
Duration get ms => milliseconds;
}
... ...
... ... @@ -28,40 +28,4 @@ extension GetNumUtils on num {
Duration(milliseconds: (this * 1000).round()),
callback,
);
/// Easy way to make Durations from numbers.
///
/// Sample:
/// ```
/// print(1.seconds + 200.milliseconds);
/// print(1.hours + 30.minutes);
/// print(1.5.hours);
///```
Duration get milliseconds => Duration(microseconds: (this * 1000).round());
Duration get seconds => Duration(milliseconds: (this * 1000).round());
Duration get minutes =>
Duration(seconds: (this * Duration.secondsPerMinute).round());
Duration get hours =>
Duration(minutes: (this * Duration.minutesPerHour).round());
Duration get days => Duration(hours: (this * Duration.hoursPerDay).round());
//final _delayMaps = <Function, Future>{};
// TODO: create a proper Future and control the Timer.
// Future delay([double seconds = 0, VoidCallback callback]) async {
// final ms = (seconds * 1000).round();
// return Future.delayed(Duration(milliseconds: ms), callback);
// return _delayMaps[callback];
// }
//killDelay(VoidCallback callback) {
// if (_delayMaps.containsKey(callback)) {
// _delayMaps[callback]?.timeout(Duration.zero, onTimeout: () {
// print('callbacl eliminado!');
// });
// _delayMaps.remove(callback);
// }
//}
}
... ...
... ... @@ -6,6 +6,11 @@ import 'package:get/state_manager.dart';
int times = 30;
void printValue(String value) {
// ignore: avoid_print
print(value);
}
Future<int> valueNotifier() {
final c = Completer<int>();
final value = ValueNotifier<int>(0);
... ... @@ -15,7 +20,7 @@ Future<int> valueNotifier() {
value.addListener(() {
if (times == value.value) {
timer.stop();
print(
printValue(
"""${value.value} listeners notified | [VALUE_NOTIFIER] time: ${timer.elapsedMicroseconds}ms""");
c.complete(timer.elapsedMicroseconds);
}
... ... @@ -37,7 +42,7 @@ Future<int> getValue() {
value.addListener(() {
if (times == value.value) {
timer.stop();
print(
printValue(
"""${value.value} listeners notified | [GETX_VALUE] time: ${timer.elapsedMicroseconds}ms""");
c.complete(timer.elapsedMicroseconds);
}
... ... @@ -60,7 +65,7 @@ Future<int> stream() {
value.stream.listen((v) {
if (times == v) {
timer.stop();
print(
printValue(
"""$v listeners notified | [STREAM] time: ${timer.elapsedMicroseconds}ms""");
c.complete(timer.elapsedMicroseconds);
value.close();
... ... @@ -84,7 +89,7 @@ Future<int> stream() {
// value.listen((v) {
// if (times == v) {
// timer.stop();
// print(
// printValue(
// """$v listeners notified |
// [GET_STREAM] time: ${timer.elapsedMicroseconds}ms""");
// c.complete(timer.elapsedMicroseconds);
... ... @@ -108,7 +113,7 @@ Future<int> miniStream() {
value.listen((v) {
if (times == v) {
timer.stop();
print(
printValue(
"""$v listeners notified | [MINI_STREAM] time: ${timer.elapsedMicroseconds}ms""");
c.complete(timer.elapsedMicroseconds);
}
... ... @@ -123,49 +128,49 @@ Future<int> miniStream() {
void main() {
test('percentage test', () {
print('============================================');
print('PERCENTAGE TEST');
printValue('============================================');
printValue('PERCENTAGE TEST');
final referenceValue = 200;
final requestedValue = 100;
const referenceValue = 200;
const requestedValue = 100;
print('''
printValue('''
referenceValue is ${calculePercentage(referenceValue, requestedValue)}% more than requestedValue''');
expect(calculePercentage(referenceValue, requestedValue), 100);
});
test('run benchmarks from ValueNotifier', () async {
times = 30;
print('============================================');
print('VALUE_NOTIFIER X GETX_VALUE TEST');
print('-----------');
printValue('============================================');
printValue('VALUE_NOTIFIER X GETX_VALUE TEST');
printValue('-----------');
await getValue();
await valueNotifier();
print('-----------');
printValue('-----------');
times = 30000;
final getx = await getValue();
final dart = await valueNotifier();
print('-----------');
printValue('-----------');
print('ValueNotifier delay $dart ms to made $times requests');
print('GetValue delay $getx ms to made $times requests');
print('-----------');
print('''
printValue('ValueNotifier delay $dart ms to made $times requests');
printValue('GetValue delay $getx ms to made $times requests');
printValue('-----------');
printValue('''
GetValue is ${calculePercentage(dart, getx).round()}% faster than Default ValueNotifier with $times requests''');
});
test('run benchmarks from Streams', () async {
times = 30;
print('============================================');
print('DART STREAM X GET_STREAM X GET_MINI_STREAM TEST');
print('-----------');
printValue('============================================');
printValue('DART STREAM X GET_STREAM X GET_MINI_STREAM TEST');
printValue('-----------');
// var getx = await getStream();
var mini = await miniStream();
var dart = await stream();
print('-----------');
print('''
printValue('-----------');
printValue('''
GetStream is ${calculePercentage(dart, mini).round()}% faster than Default Stream with $times requests''');
print('-----------');
printValue('-----------');
times = 30000;
dart = await stream();
... ... @@ -176,12 +181,12 @@ GetStream is ${calculePercentage(dart, mini).round()}% faster than Default Strea
dart = await stream();
// getx = await getStream();
mini = await miniStream();
print('-----------');
print('dart_stream delay $dart ms to made $times requests');
// print('getx_stream delay $getx ms to made $times requests');
print('getx_mini_stream delay $mini ms to made $times requests');
print('-----------');
print('''
printValue('-----------');
printValue('dart_stream delay $dart ms to made $times requests');
// printValue('getx_stream delay $getx ms to made $times requests');
printValue('getx_mini_stream delay $mini ms to made $times requests');
printValue('-----------');
printValue('''
GetStream is ${calculePercentage(dart, mini).round()}% faster than Default Stream with $times requests''');
});
}
... ...
... ... @@ -101,7 +101,8 @@ void main() {
expect(Get.find<Controller>().count, 1);
Get.delete<Controller>();
expect(() => Get.find<Controller>(), throwsA(m.TypeMatcher<String>()));
expect(
() => Get.find<Controller>(), throwsA(const m.TypeMatcher<String>()));
Get.reset();
});
... ... @@ -162,7 +163,7 @@ void main() {
// Get.put(DisposableController());
expect(Get.delete<DisposableController>(), true);
expect(() => Get.find<DisposableController>(),
throwsA(m.TypeMatcher<String>()));
throwsA(const m.TypeMatcher<String>()));
});
test('Get.put test after delete with disposable controller and init check',
... ... @@ -192,7 +193,7 @@ void main() {
});
test('tagged temporary', () async {
final tag = 'tag';
const tag = 'tag';
Get.put(DisposableController(), tag: tag);
Get.replace<DisposableController>(Controller(), tag: tag);
final instance = Get.find<DisposableController>(tag: tag);
... ... @@ -201,7 +202,7 @@ void main() {
});
test('tagged permanent', () async {
final tag = 'tag';
const tag = 'tag';
Get.put(DisposableController(), permanent: true, tag: tag);
Get.replace<DisposableController>(Controller(), tag: tag);
final instance = Get.find<DisposableController>(tag: tag);
... ... @@ -210,7 +211,7 @@ void main() {
});
test('a generic parent type', () async {
final tag = 'tag';
const tag = 'tag';
Get.put<MyController>(DisposableController(), permanent: true, tag: tag);
Get.replace<MyController>(Controller(), tag: tag);
final instance = Get.find<MyController>(tag: tag);
... ...
... ... @@ -27,10 +27,10 @@
import 'package:flutter_test/flutter_test.dart';
class _FunctionMatcher<T> extends CustomMatcher {
class FunctionMatcher<T> extends CustomMatcher {
final Object Function(T value) _feature;
_FunctionMatcher(String name, this._feature, matcher)
FunctionMatcher(String name, this._feature, matcher)
: super('`$name`:', '`$name`', matcher);
@override
... ... @@ -39,15 +39,15 @@ class _FunctionMatcher<T> extends CustomMatcher {
class HavingMatcher<T> implements TypeMatcher<T> {
final TypeMatcher<T> _parent;
final List<_FunctionMatcher<T>> _functionMatchers;
final List<FunctionMatcher<T>> _functionMatchers;
HavingMatcher(TypeMatcher<T> parent, String description,
Object Function(T) feature, dynamic matcher,
[Iterable<_FunctionMatcher<T>>? existing])
[Iterable<FunctionMatcher<T>>? existing])
: _parent = parent,
_functionMatchers = [
...?existing,
_FunctionMatcher<T>(description, feature, matcher)
FunctionMatcher<T>(description, feature, matcher)
];
@override
... ...
... ... @@ -16,7 +16,7 @@ void main() {
expect('total_confirmed'.tr, 'Total Confirmed');
expect('total_deaths'.tr, 'Total Deaths');
Get.updateLocale(Locale('pt', 'BR'));
Get.updateLocale(const Locale('pt', 'BR'));
await tester.pumpAndSettle();
... ... @@ -24,7 +24,7 @@ void main() {
expect('total_confirmed'.tr, 'Total confirmado');
expect('total_deaths'.tr, 'Total de mortes');
Get.updateLocale(Locale('en', 'EN'));
Get.updateLocale(const Locale('en', 'EN'));
await tester.pumpAndSettle();
... ...
... ... @@ -12,16 +12,14 @@ void main() {
await tester.pump();
Get.bottomSheet(Container(
child: Wrap(
children: <Widget>[
ListTile(
leading: Icon(Icons.music_note),
title: Text('Music'),
onTap: () {},
),
],
),
Get.bottomSheet(Wrap(
children: <Widget>[
ListTile(
leading: const Icon(Icons.music_note),
title: const Text('Music'),
onTap: () {},
),
],
));
await tester.pumpAndSettle();
... ... @@ -36,16 +34,14 @@ void main() {
await tester.pump();
Get.bottomSheet(Container(
child: Wrap(
children: <Widget>[
ListTile(
leading: Icon(Icons.music_note),
title: Text('Music'),
onTap: () {},
),
],
),
Get.bottomSheet(Wrap(
children: <Widget>[
ListTile(
leading: const Icon(Icons.music_note),
title: const Text('Music'),
onTap: () {},
),
],
));
await tester.pumpAndSettle();
... ...
... ... @@ -13,8 +13,7 @@ void main() {
await tester.pump();
Get.defaultDialog(
onConfirm: () => print("Ok"),
middleText: "Dialog made in 3 lines of code");
onConfirm: () {}, middleText: "Dialog made in 3 lines of code");
await tester.pumpAndSettle();
... ... @@ -28,7 +27,7 @@ void main() {
await tester.pump();
Get.dialog(YourDialogWidget());
Get.dialog(const YourDialogWidget());
await tester.pumpAndSettle();
... ... @@ -42,7 +41,7 @@ void main() {
await tester.pump();
Get.dialog(YourDialogWidget());
Get.dialog(const YourDialogWidget());
await tester.pumpAndSettle();
expect(find.byType(YourDialogWidget), findsOneWidget);
... ...
... ... @@ -13,7 +13,7 @@ void main() {
expect(Get.isRegistered<Controller2>(), false);
expect(Get.isRegistered<Controller>(), false);
Get.to(() => First());
Get.to(() => const First());
await tester.pumpAndSettle();
... ... @@ -21,7 +21,7 @@ void main() {
expect(Get.isRegistered<Controller>(), true);
Get.to(() => Second());
Get.to(() => const Second());
await tester.pumpAndSettle();
... ... @@ -53,20 +53,24 @@ class Controller extends GetxController {}
class Controller2 extends GetxController {}
class First extends StatelessWidget {
const First({super.key});
@override
Widget build(BuildContext context) {
Get.put(Controller());
return Center(
return const Center(
child: Text("first"),
);
}
}
class Second extends StatelessWidget {
const Second({super.key});
@override
Widget build(BuildContext context) {
Get.put(Controller2());
return Center(
return const Center(
child: Text("second"),
);
}
... ...
... ... @@ -8,7 +8,7 @@ void main() {
testWidgets("Get.to navigates to provided route", (tester) async {
await tester.pumpWidget(Wrapper(child: Container()));
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
... ... @@ -19,9 +19,9 @@ void main() {
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first',
getPages: [
GetPage(page: () => FirstScreen(), name: '/first'),
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third')
GetPage(page: () => const FirstScreen(), name: '/first'),
GetPage(page: () => const SecondScreen(), name: '/second'),
GetPage(page: () => const ThirdScreen(), name: '/third')
],
));
... ... @@ -35,11 +35,11 @@ void main() {
testWidgets("unknowroute", (tester) async {
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first',
unknownRoute: GetPage(name: '/404', page: () => Scaffold()),
unknownRoute: GetPage(name: '/404', page: () => const Scaffold()),
getPages: [
GetPage(page: () => FirstScreen(), name: '/first'),
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third')
GetPage(page: () => const FirstScreen(), name: '/first'),
GetPage(page: () => const SecondScreen(), name: '/second'),
GetPage(page: () => const ThirdScreen(), name: '/third')
],
));
... ... @@ -52,10 +52,10 @@ void main() {
});
testWidgets("Get.off navigates to provided route", (tester) async {
await tester.pumpWidget(Wrapper(child: FirstScreen()));
await tester.pumpWidget(const Wrapper(child: FirstScreen()));
// await tester.pump();
Get.off(() => SecondScreen());
Get.off(() => const SecondScreen());
await tester.pumpAndSettle();
... ... @@ -63,10 +63,10 @@ void main() {
});
testWidgets("Get.off removes current route", (tester) async {
await tester.pumpWidget(Wrapper(child: FirstScreen()));
await tester.pumpWidget(const Wrapper(child: FirstScreen()));
await tester.pump();
Get.off(() => SecondScreen());
Get.off(() => const SecondScreen());
Get.back();
await tester.pumpAndSettle();
... ... @@ -78,9 +78,9 @@ void main() {
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first',
getPages: [
GetPage(name: '/first', page: () => FirstScreen()),
GetPage(name: '/second', page: () => SecondScreen()),
GetPage(name: '/third', page: () => ThirdScreen()),
GetPage(name: '/first', page: () => const FirstScreen()),
GetPage(name: '/second', page: () => const SecondScreen()),
GetPage(name: '/third', page: () => const ThirdScreen()),
],
));
... ... @@ -97,9 +97,9 @@ void main() {
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first',
getPages: [
GetPage(name: '/first', page: () => FirstScreen()),
GetPage(name: '/second', page: () => SecondScreen()),
GetPage(name: '/third', page: () => ThirdScreen()),
GetPage(name: '/first', page: () => const FirstScreen()),
GetPage(name: '/second', page: () => const SecondScreen()),
GetPage(name: '/third', page: () => const ThirdScreen()),
],
));
... ... @@ -118,9 +118,9 @@ void main() {
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first',
getPages: [
GetPage(name: '/first', page: () => FirstScreen()),
GetPage(name: '/second', page: () => SecondScreen()),
GetPage(name: '/third', page: () => ThirdScreen()),
GetPage(name: '/first', page: () => const FirstScreen()),
GetPage(name: '/second', page: () => const SecondScreen()),
GetPage(name: '/third', page: () => const ThirdScreen()),
],
));
... ... @@ -138,10 +138,10 @@ void main() {
});
testWidgets("Get.offAll navigates to provided route", (tester) async {
await tester.pumpWidget(Wrapper(child: FirstScreen()));
await tester.pumpWidget(const Wrapper(child: FirstScreen()));
await tester.pump();
Get.offAll(() => SecondScreen());
Get.offAll(() => const SecondScreen());
await tester.pumpAndSettle();
... ... @@ -149,12 +149,12 @@ void main() {
});
testWidgets("Get.offAll removes all previous routes", (tester) async {
await tester.pumpWidget(Wrapper(child: FirstScreen()));
await tester.pumpWidget(const Wrapper(child: FirstScreen()));
await tester.pump();
Get.to(() => SecondScreen());
Get.to(() => const SecondScreen());
await tester.pumpAndSettle();
Get.offAll(() => ThirdScreen());
Get.offAll(() => const ThirdScreen());
await tester.pumpAndSettle();
Get.back();
await tester.pumpAndSettle();
... ... @@ -173,9 +173,9 @@ void main() {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: () => FirstScreen(), name: '/first'),
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third')
GetPage(page: () => const FirstScreen(), name: '/first'),
GetPage(page: () => const SecondScreen(), name: '/second'),
GetPage(page: () => const ThirdScreen(), name: '/third')
],
));
... ... @@ -192,9 +192,9 @@ void main() {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: () => FirstScreen(), name: '/first'),
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third')
GetPage(page: () => const FirstScreen(), name: '/first'),
GetPage(page: () => const SecondScreen(), name: '/second'),
GetPage(page: () => const ThirdScreen(), name: '/third')
],
));
... ... @@ -220,9 +220,9 @@ void main() {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: () => FirstScreen(), name: '/first'),
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third')
GetPage(page: () => const FirstScreen(), name: '/first'),
GetPage(page: () => const SecondScreen(), name: '/second'),
GetPage(page: () => const ThirdScreen(), name: '/third')
],
));
... ... @@ -237,9 +237,9 @@ void main() {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: () => FirstScreen(), name: '/first'),
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third')
GetPage(page: () => const FirstScreen(), name: '/first'),
GetPage(page: () => const SecondScreen(), name: '/second'),
GetPage(page: () => const ThirdScreen(), name: '/third')
],
));
... ... @@ -256,11 +256,12 @@ void main() {
testWidgets("Get.offUntil navigates to provided route", (tester) async {
await tester.pumpWidget(Wrapper(child: Container()));
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
Get.offUntil(() => ThirdScreen(), (route) => route.name == '/FirstScreen');
Get.offUntil(
() => const ThirdScreen(), (route) => route.name == '/FirstScreen');
await tester.pumpAndSettle();
... ... @@ -272,11 +273,12 @@ void main() {
(tester) async {
await tester.pumpWidget(Wrapper(child: Container()));
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
Get.to(() => SecondScreen());
Get.to(() => const SecondScreen());
await tester.pumpAndSettle();
Get.offUntil(() => ThirdScreen(), (route) => route.name == '/FirstScreen');
Get.offUntil(
() => const ThirdScreen(), (route) => route.name == '/FirstScreen');
await tester.pumpAndSettle();
Get.back();
... ... @@ -290,11 +292,12 @@ void main() {
(tester) async {
await tester.pumpWidget(Wrapper(child: Container()));
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
Get.to(() => SecondScreen());
Get.to(() => const SecondScreen());
await tester.pumpAndSettle();
Get.offUntil(() => ThirdScreen(), (route) => route.name == '/FirstScreen');
Get.offUntil(
() => const ThirdScreen(), (route) => route.name == '/FirstScreen');
await tester.pumpAndSettle();
Get.back();
... ... @@ -307,9 +310,9 @@ void main() {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: () => FirstScreen(), name: '/first'),
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third')
GetPage(page: () => const FirstScreen(), name: '/first'),
GetPage(page: () => const SecondScreen(), name: '/second'),
GetPage(page: () => const ThirdScreen(), name: '/third')
],
));
... ... @@ -326,9 +329,9 @@ void main() {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: () => FirstScreen(), name: '/first'),
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third')
GetPage(page: () => const FirstScreen(), name: '/first'),
GetPage(page: () => const SecondScreen(), name: '/second'),
GetPage(page: () => const ThirdScreen(), name: '/third')
],
));
... ... @@ -347,9 +350,9 @@ void main() {
await tester.pumpWidget(WrapperNamed(
initialRoute: '/first',
namedRoutes: [
GetPage(page: () => FirstScreen(), name: '/first'),
GetPage(page: () => SecondScreen(), name: '/second'),
GetPage(page: () => ThirdScreen(), name: '/third'),
GetPage(page: () => const FirstScreen(), name: '/first'),
GetPage(page: () => const SecondScreen(), name: '/second'),
GetPage(page: () => const ThirdScreen(), name: '/third'),
],
));
... ... @@ -367,17 +370,17 @@ void main() {
testWidgets("Get.back navigates back", (tester) async {
await tester.pumpWidget(
Wrapper(
child: Container(),
defaultTransition: Transition.circularReveal,
child: Container(),
),
);
// await tester.pump();
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
Get.to(() => SecondScreen());
Get.to(() => const SecondScreen());
await tester.pumpAndSettle();
Get.back();
... ... @@ -391,16 +394,16 @@ void main() {
(tester) async {
await tester.pumpWidget(
Wrapper(
child: Container(),
defaultTransition: Transition.circularReveal,
child: Container(),
),
);
// await tester.pump();
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
Get.to(() => SecondScreen());
Get.to(() => const SecondScreen());
await tester.pumpAndSettle();
Get.snackbar('title', "message");
await tester.pumpAndSettle();
... ... @@ -417,12 +420,12 @@ void main() {
testWidgets("fadeIn", (tester) async {
await tester.pumpWidget(
Wrapper(
child: Container(),
defaultTransition: Transition.fadeIn,
child: Container(),
),
);
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
... ... @@ -432,12 +435,12 @@ void main() {
testWidgets("downToUp", (tester) async {
await tester.pumpWidget(
Wrapper(
child: Container(),
defaultTransition: Transition.downToUp,
child: Container(),
),
);
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
... ... @@ -447,12 +450,12 @@ void main() {
testWidgets("fade", (tester) async {
await tester.pumpWidget(
Wrapper(
child: Container(),
defaultTransition: Transition.fade,
child: Container(),
),
);
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
... ... @@ -462,12 +465,12 @@ void main() {
testWidgets("leftToRight", (tester) async {
await tester.pumpWidget(
Wrapper(
child: Container(),
defaultTransition: Transition.leftToRight,
child: Container(),
),
);
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
... ... @@ -477,12 +480,12 @@ void main() {
testWidgets("leftToRightWithFade", (tester) async {
await tester.pumpWidget(
Wrapper(
child: Container(),
defaultTransition: Transition.leftToRightWithFade,
child: Container(),
),
);
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
... ... @@ -492,12 +495,12 @@ void main() {
testWidgets("leftToRightWithFade", (tester) async {
await tester.pumpWidget(
Wrapper(
child: Container(),
defaultTransition: Transition.rightToLeft,
child: Container(),
),
);
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
... ... @@ -507,12 +510,12 @@ void main() {
testWidgets("defaultTransition", (tester) async {
await tester.pumpWidget(
Wrapper(
child: Container(),
defaultTransition: Transition.rightToLeft,
child: Container(),
),
);
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
... ... @@ -522,12 +525,12 @@ void main() {
testWidgets("rightToLeftWithFade", (tester) async {
await tester.pumpWidget(
Wrapper(
child: Container(),
defaultTransition: Transition.rightToLeftWithFade,
child: Container(),
),
);
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
... ... @@ -537,12 +540,12 @@ void main() {
testWidgets("cupertino", (tester) async {
await tester.pumpWidget(
Wrapper(
child: Container(),
defaultTransition: Transition.cupertino,
child: Container(),
),
);
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
... ... @@ -552,12 +555,12 @@ void main() {
testWidgets("size", (tester) async {
await tester.pumpWidget(
Wrapper(
child: Container(),
defaultTransition: Transition.size,
child: Container(),
),
);
Get.to(() => FirstScreen());
Get.to(() => const FirstScreen());
await tester.pumpAndSettle();
... ... @@ -571,7 +574,8 @@ class FirstScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(child: Text('FirstScreen'));
// ignore: avoid_unnecessary_containers
return Container(child: const Text('FirstScreen'));
}
}
... ...
... ... @@ -35,11 +35,14 @@ void main() {
initialRoute: '/',
getPages: [
GetPage(name: '/', page: () => Container()),
GetPage(name: '/first', page: () => FirstScreen(), middlewares: [
RedirectMiddleware(),
]),
GetPage(name: '/second', page: () => SecondScreen()),
GetPage(name: '/third', page: () => ThirdScreen()),
GetPage(
name: '/first',
page: () => const FirstScreen(),
middlewares: [
RedirectMiddleware(),
]),
GetPage(name: '/second', page: () => const SecondScreen()),
GetPage(name: '/third', page: () => const ThirdScreen()),
],
),
);
... ... @@ -47,7 +50,6 @@ void main() {
Get.toNamed('/first');
await tester.pumpAndSettle();
print(Get.rootController.rootDelegate.currentConfiguration?.route?.name);
expect(find.byType(SecondScreen), findsOneWidget);
});
... ... @@ -57,11 +59,14 @@ void main() {
initialRoute: '/',
getPages: [
GetPage(name: '/', page: () => Container()),
GetPage(name: '/first', page: () => FirstScreen(), middlewares: [
RedirectMiddlewareNull(),
]),
GetPage(name: '/second', page: () => SecondScreen()),
GetPage(name: '/third', page: () => ThirdScreen()),
GetPage(
name: '/first',
page: () => const FirstScreen(),
middlewares: [
RedirectMiddlewareNull(),
]),
GetPage(name: '/second', page: () => const SecondScreen()),
GetPage(name: '/third', page: () => const ThirdScreen()),
],
),
);
... ... @@ -71,7 +76,6 @@ void main() {
Get.toNamed('/first');
await tester.pumpAndSettle();
print(Get.rootController.rootDelegate.currentConfiguration?.route?.name);
expect(find.byType(FirstScreen), findsOneWidget);
});
}
... ...
... ... @@ -64,7 +64,7 @@ void main() {
tree.addRoute(pageTree);
// tree.addRoute(pageTree);
final searchRoute = '/city/work/office/pen';
const searchRoute = '/city/work/office/pen';
final match = tree.matchRoute(searchRoute);
expect(match, isNotNull);
expect(match.route!.name, searchRoute);
... ... @@ -120,7 +120,7 @@ void main() {
// tree.addRoute(p);
// }
final searchRoute = '/city/work/office/pen';
const searchRoute = '/city/work/office/pen';
final match = tree.matchRoute(searchRoute);
expect(match, isNotNull);
expect(match.route!.name, searchRoute);
... ... @@ -166,7 +166,6 @@ void main() {
testWidgets(
'params in url by parameters',
(tester) async {
print("Iniciando test");
await tester.pumpWidget(GetMaterialApp(
initialRoute: '/first/juan',
getPages: [
... ...
... ... @@ -9,13 +9,14 @@ void main() {
GetMaterialApp(
popGesture: true,
home: ElevatedButton(
child: Text('Open Snackbar'),
child: const Text('Open Snackbar'),
onPressed: () {
Get.snackbar(
'title',
"message",
duration: Duration(seconds: 1),
mainButton: TextButton(onPressed: () {}, child: Text('button')),
duration: const Duration(seconds: 1),
mainButton:
TextButton(onPressed: () {}, child: const Text('button')),
isDismissible: false,
);
},
... ... @@ -38,18 +39,16 @@ void main() {
GetMaterialApp(
popGesture: true,
home: ElevatedButton(
child: Text('Open Snackbar'),
child: const Text('Open Snackbar'),
onPressed: () {
Get.rawSnackbar(
title: 'title',
message: "message",
onTap: (_) {
print('snackbar tapped');
},
onTap: (_) {},
shouldIconPulse: true,
icon: Icon(Icons.alarm),
icon: const Icon(Icons.alarm),
showProgressIndicator: true,
duration: Duration(seconds: 1),
duration: const Duration(seconds: 1),
isDismissible: true,
leftBarIndicatorColor: Colors.amber,
overlayBlur: 1.0,
... ... @@ -72,20 +71,20 @@ void main() {
});
testWidgets("test snackbar queue", (tester) async {
final messageOne = Text('title');
const messageOne = Text('title');
final messageTwo = Text('titleTwo');
const messageTwo = Text('titleTwo');
await tester.pumpWidget(
GetMaterialApp(
popGesture: true,
home: ElevatedButton(
child: Text('Open Snackbar'),
child: const Text('Open Snackbar'),
onPressed: () {
Get.rawSnackbar(
messageText: messageOne, duration: Duration(seconds: 1));
messageText: messageOne, duration: const Duration(seconds: 1));
Get.rawSnackbar(
messageText: messageTwo, duration: Duration(seconds: 1));
messageText: messageTwo, duration: const Duration(seconds: 1));
},
),
),
... ... @@ -122,9 +121,9 @@ void main() {
GestureDetector(
key: snackBarTapTarget,
onTap: () {
getBar = GetSnackBar(
getBar = const GetSnackBar(
message: 'bar1',
duration: const Duration(seconds: 2),
duration: Duration(seconds: 2),
isDismissible: true,
dismissDirection: dismissDirection,
);
... ... @@ -155,7 +154,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 500));
expect(find.byWidget(getBar), findsOneWidget);
await tester.ensureVisible(find.byWidget(getBar));
await tester.drag(find.byWidget(getBar), Offset(0.0, 50.0));
await tester.drag(find.byWidget(getBar), const Offset(0.0, 50.0));
await tester.pump(const Duration(milliseconds: 500));
expect(Get.isSnackbarOpen, false);
... ... @@ -222,12 +221,12 @@ void main() {
});
testWidgets("Get test actions and icon", (tester) async {
final icon = Icon(Icons.alarm);
final action = TextButton(onPressed: () {}, child: Text('button'));
const icon = Icon(Icons.alarm);
final action = TextButton(onPressed: () {}, child: const Text('button'));
late final GetSnackBar getBar;
await tester.pumpWidget(GetMaterialApp(home: Scaffold()));
await tester.pumpWidget(const GetMaterialApp(home: Scaffold()));
await tester.pump();
... ...
... ... @@ -57,8 +57,8 @@ class WrapperNamed extends StatelessWidget {
}
class WrapperTranslations extends Translations {
static final fallbackLocale = Locale('en', 'US');
static Locale? get locale => Locale('en', 'US');
static const fallbackLocale = Locale('en', 'US');
static Locale? get locale => const Locale('en', 'US');
@override
Map<String, Map<String, String>> get keys => {
'en_US': {
... ...
... ... @@ -44,7 +44,7 @@ void main() {
debounce(count, (dynamic _) {
// print(_);
result = _ as int?;
}, time: Duration(milliseconds: 100));
}, time: const Duration(milliseconds: 100));
count.value++;
count.value++;
... ... @@ -52,7 +52,7 @@ void main() {
count.value++;
await Future.delayed(Duration.zero);
expect(-1, result);
await Future.delayed(Duration(milliseconds: 100));
await Future.delayed(const Duration(milliseconds: 100));
expect(4, result);
});
... ... @@ -60,23 +60,22 @@ void main() {
final count = 0.obs;
int? result = -1;
interval<int>(count, (v) {
print(v);
result = v;
}, time: Duration(milliseconds: 100));
}, time: const Duration(milliseconds: 100));
count.value++;
await Future.delayed(Duration.zero);
await Future.delayed(Duration(milliseconds: 100));
await Future.delayed(const Duration(milliseconds: 100));
expect(result, 1);
count.value++;
count.value++;
count.value++;
await Future.delayed(Duration.zero);
await Future.delayed(Duration(milliseconds: 100));
await Future.delayed(const Duration(milliseconds: 100));
expect(result, 2);
count.value++;
await Future.delayed(Duration.zero);
await Future.delayed(Duration(milliseconds: 100));
await Future.delayed(const Duration(milliseconds: 100));
expect(result, 5);
});
... ... @@ -110,7 +109,7 @@ void main() {
reactiveInteger.call(3);
reactiveInteger.call(3);
await Future.delayed(Duration(milliseconds: 100));
await Future.delayed(const Duration(milliseconds: 100));
expect(1, timesCalled);
});
... ... @@ -127,8 +126,8 @@ void main() {
reactiveInteger.trigger(2);
reactiveInteger.trigger(3);
await Future.delayed(Duration(milliseconds: 100));
print(timesCalled);
await Future.delayed(const Duration(milliseconds: 100));
expect(3, timesCalled);
});
... ... @@ -146,7 +145,7 @@ void main() {
reactiveInteger.trigger(3);
reactiveInteger.trigger(1);
await Future.delayed(Duration(milliseconds: 100));
await Future.delayed(const Duration(milliseconds: 100));
expect(4, timesCalled);
});
... ...
... ... @@ -34,11 +34,11 @@ void main() {
'Map: ${controller.map.length}',
),
TextButton(
child: Text("increment"),
child: const Text("increment"),
onPressed: () => controller.increment(),
),
TextButton(
child: Text("increment2"),
child: const Text("increment2"),
onPressed: () => controller.increment2(),
)
],
... ...
... ... @@ -18,8 +18,8 @@ void main() {
Text('Bool: ${controller.boolean.value}'),
Text('Map: ${controller.map.length}'),
TextButton(
child: Text("increment"),
onPressed: controller.increment,
child: const Text("increment"),
),
Obx(() => Text('Obx: ${controller.map.length}'))
]),
... ...
... ... @@ -31,7 +31,7 @@ void main() {
'Map: ${controller.map.length}',
),
TextButton(
child: Text("increment"),
child: const Text("increment"),
onPressed: () => controller.increment(),
),
GetX<Controller2>(builder: (controller) {
... ...
... ... @@ -15,11 +15,11 @@ void main() {
'${controller.counter}',
),
TextButton(
child: Text("increment"),
child: const Text("increment"),
onPressed: () => controller.increment(),
),
TextButton(
child: Text("incrementWithId"),
child: const Text("incrementWithId"),
onPressed: () => controller.incrementWithId(),
),
GetBuilder<Controller>(
... ...
... ... @@ -2,8 +2,44 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:get/utils.dart';
void main() {
test('Test for toPrecision on Double', () {
var testVar = 5.4545454;
expect(testVar.toPrecision(2), equals(5.45));
group('DoubleExt', () {
test('toPrecision', () {
expect(3.14159.toPrecision(2), equals(3.14));
expect(3.14159.toPrecision(4), equals(3.1416));
expect(1.0.toPrecision(0), equals(1.0));
expect(123456789.123456789.toPrecision(4), equals(123456789.1235));
expect((-3.14159).toPrecision(2), equals(-3.14));
});
test('milliseconds', () {
expect(1000.0.ms, equals(const Duration(milliseconds: 1000)));
expect(
1.5.ms, equals(const Duration(milliseconds: 1, microseconds: 500)));
expect((-2000.0).ms, equals(const Duration(milliseconds: -2000)));
});
test('seconds', () {
expect(60.0.seconds, equals(const Duration(seconds: 60)));
expect(1.5.seconds, equals(const Duration(milliseconds: 1500)));
expect((-120.0).seconds, equals(const Duration(seconds: -120)));
});
test('minutes', () {
expect(2.5.minutes, equals(const Duration(minutes: 2, seconds: 30)));
expect(1.2.minutes, equals(const Duration(seconds: 72)));
expect((-3.0).minutes, equals(const Duration(minutes: -3)));
});
test('hours', () {
expect(1.5.hours, equals(const Duration(hours: 1, minutes: 30)));
expect(0.25.hours, equals(const Duration(minutes: 15)));
expect((-2.0).hours, equals(const Duration(hours: -2)));
});
test('days', () {
expect(1.5.days, equals(const Duration(days: 1, hours: 12)));
expect(0.25.days, equals(const Duration(hours: 6)));
expect((-3.0).days, equals(const Duration(days: -3)));
});
});
}
... ...
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
void main() {
group('DurationExt', () {
test('seconds', () {
expect(1.seconds, equals(const Duration(seconds: 1)));
expect(
2.5.seconds, equals(const Duration(seconds: 2, milliseconds: 500)));
expect((-1).seconds, equals(const Duration(seconds: -1)));
});
test('days', () {
expect(1.days, equals(const Duration(days: 1)));
expect((-1).days, equals(const Duration(days: -1)));
});
test('hours', () {
expect(1.hours, equals(const Duration(hours: 1)));
expect((-1).hours, equals(const Duration(hours: -1)));
});
test('minutes', () {
expect(1.minutes, equals(const Duration(minutes: 1)));
expect((-1).minutes, equals(const Duration(minutes: -1)));
});
test('milliseconds', () {
expect(1.milliseconds, equals(const Duration(milliseconds: 1)));
expect((-1).milliseconds, equals(const Duration(milliseconds: -1)));
});
test('microseconds', () {
expect(1.microseconds, equals(const Duration(microseconds: 1)));
expect((-1).microseconds, equals(const Duration(microseconds: -1)));
});
test('ms', () {
expect(1.ms, equals(const Duration(milliseconds: 1)));
expect((-1).ms, equals(const Duration(milliseconds: -1)));
});
});
}
... ...
... ... @@ -3,12 +3,12 @@ import 'package:get/utils.dart';
void main() {
group('String extensions', () {
final text = "oi";
final digit = "5";
final specialCaracters = "#\$!%@";
final alphaNumeric = "123asd";
final numbers = "123";
final letters = "foo";
const text = "oi";
const digit = "5";
const specialCaracters = "#\$!%@";
const alphaNumeric = "123asd";
const numbers = "123";
const letters = "foo";
// String notInitializedVar;
test('var.isNum', () {
... ... @@ -66,27 +66,27 @@ void main() {
});
test('var.isBool', () {
final trueString = 'true';
const trueString = 'true';
// expect(notInitializedVar.isBool, false);
expect(letters.isBool, false);
expect(trueString.isBool, true);
});
test('var.isVectorFileName', () {
final path = "logo.svg";
final fullPath = "C:/Users/Getx/Documents/logo.svg";
const path = "logo.svg";
const fullPath = "C:/Users/Getx/Documents/logo.svg";
expect(path.isVectorFileName, true);
expect(fullPath.isVectorFileName, true);
expect(alphaNumeric.isVectorFileName, false);
});
test('var.isImageFileName', () {
final jpgPath = "logo.jpg";
final jpegPath = "logo.jpeg";
final pngPath = "logo.png";
final gifPath = "logo.gif";
final bmpPath = "logo.bmp";
final svgPath = "logo.svg";
const jpgPath = "logo.jpg";
const jpegPath = "logo.jpeg";
const pngPath = "logo.png";
const gifPath = "logo.gif";
const bmpPath = "logo.bmp";
const svgPath = "logo.svg";
expect(jpgPath.isImageFileName, true);
expect(jpegPath.isImageFileName, true);
... ... @@ -97,12 +97,12 @@ void main() {
});
test('var.isAudioFileName', () {
final mp3Path = "logo.mp3";
final wavPath = "logo.wav";
final wmaPath = "logo.wma";
final amrPath = "logo.amr";
final oggPath = "logo.ogg";
final svgPath = "logo.svg";
const mp3Path = "logo.mp3";
const wavPath = "logo.wav";
const wmaPath = "logo.wma";
const amrPath = "logo.amr";
const oggPath = "logo.ogg";
const svgPath = "logo.svg";
expect(mp3Path.isAudioFileName, true);
expect(wavPath.isAudioFileName, true);
... ... @@ -113,14 +113,14 @@ void main() {
});
test('var.isVideoFileName', () {
final mp4Path = "logo.mp4";
final aviPath = "logo.avi";
final wmvPath = "logo.wmv";
final rmvbPath = "logo.rmvb";
final mpgPath = "logo.mpg";
final mpegPath = "logo.mpeg";
final threegpPath = "logo.3gp";
final svgPath = "logo.svg";
const mp4Path = "logo.mp4";
const aviPath = "logo.avi";
const wmvPath = "logo.wmv";
const rmvbPath = "logo.rmvb";
const mpgPath = "logo.mpg";
const mpegPath = "logo.mpeg";
const threegpPath = "logo.3gp";
const svgPath = "logo.svg";
expect(mp4Path.isVideoFileName, true);
expect(aviPath.isVideoFileName, true);
... ... @@ -139,8 +139,8 @@ void main() {
});
test('var.isDocumentFileName', () {
final docPath = "file.doc";
final docxPath = "file.docx";
const docPath = "file.doc";
const docxPath = "file.docx";
expect(docPath.isDocumentFileName, true);
expect(docxPath.isDocumentFileName, true);
... ... @@ -148,8 +148,8 @@ void main() {
});
test('var.isExcelFileName', () {
final xlsPath = "file.xls";
final xlsxPath = "file.xlsx";
const xlsPath = "file.xls";
const xlsxPath = "file.xlsx";
expect(xlsPath.isExcelFileName, true);
expect(xlsxPath.isExcelFileName, true);
... ... @@ -157,8 +157,8 @@ void main() {
});
test('var.isPPTFileName', () {
final pptPath = "file.ppt";
final pptxPath = "file.pptx";
const pptPath = "file.ppt";
const pptxPath = "file.pptx";
expect(pptPath.isPPTFileName, true);
expect(pptxPath.isPPTFileName, true);
... ... @@ -166,20 +166,20 @@ void main() {
});
test('var.isAPKFileName', () {
final apkPath = "file.apk";
const apkPath = "file.apk";
expect(apkPath.isAPKFileName, true);
expect(alphaNumeric.isAPKFileName, false);
});
test('var.isPDFFileName', () {
final pdfPath = "file.pdf";
const pdfPath = "file.pdf";
expect(pdfPath.isPDFFileName, true);
expect(alphaNumeric.isPDFFileName, false);
});
test('var.isHTMLFileName', () {
final htmlPath = "file.html";
const htmlPath = "file.html";
expect(htmlPath.isHTMLFileName, true);
expect(alphaNumeric.isHTMLFileName, false);
... ... @@ -296,7 +296,7 @@ void main() {
expect(phone.isPhoneNumber, true);
}
final bigRandomNumber = '168468468465241327987624987327987';
const bigRandomNumber = '168468468465241327987624987327987';
expect(bigRandomNumber.isPhoneNumber, false);
expect(alphaNumeric.isPhoneNumber, false);
... ... @@ -693,7 +693,7 @@ void main() {
});
test('var.isCaseInsensitiveContains(string)', () {
final phrase = 'Back to Square One';
const phrase = 'Back to Square One';
expect(phrase.isCaseInsensitiveContains('to'), true);
expect(phrase.isCaseInsensitiveContains('square'), true);
... ... @@ -702,7 +702,7 @@ void main() {
});
test('var.isCaseInsensitiveContainsAny(string)', () {
final phrase = 'Back to Square One';
const phrase = 'Back to Square One';
expect(phrase.isCaseInsensitiveContainsAny('to'), true);
expect(phrase.isCaseInsensitiveContainsAny('square'), true);
... ...
... ... @@ -3,16 +3,18 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:get/utils.dart';
class Foo extends StatelessWidget {
const Foo({super.key});
@override
Widget build(BuildContext context) {
return SizedBox.shrink();
return const SizedBox.shrink();
}
}
void main() {
group('Group test for PaddingX Extension', () {
testWidgets('Test of paddingAll', (tester) async {
Widget containerTest = Foo();
Widget containerTest = const Foo();
expect(find.byType(Padding), findsNothing);
... ... @@ -22,7 +24,7 @@ void main() {
});
testWidgets('Test of paddingOnly', (tester) async {
Widget containerTest = Foo();
Widget containerTest = const Foo();
expect(find.byType(Padding), findsNothing);
... ... @@ -32,7 +34,7 @@ void main() {
});
testWidgets('Test of paddingSymmetric', (tester) async {
Widget containerTest = Foo();
Widget containerTest = const Foo();
expect(find.byType(Padding), findsNothing);
... ... @@ -42,7 +44,7 @@ void main() {
});
testWidgets('Test of paddingZero', (tester) async {
Widget containerTest = Foo();
Widget containerTest = const Foo();
expect(find.byType(Padding), findsNothing);
... ... @@ -54,7 +56,7 @@ void main() {
group('Group test for MarginX Extension', () {
testWidgets('Test of marginAll', (tester) async {
Widget containerTest = Foo();
Widget containerTest = const Foo();
await tester.pumpWidget(containerTest.marginAll(16));
... ... @@ -62,7 +64,7 @@ void main() {
});
testWidgets('Test of marginOnly', (tester) async {
Widget containerTest = Foo();
Widget containerTest = const Foo();
await tester.pumpWidget(containerTest.marginOnly(top: 16));
... ... @@ -70,7 +72,7 @@ void main() {
});
testWidgets('Test of marginSymmetric', (tester) async {
Widget containerTest = Foo();
Widget containerTest = const Foo();
await tester.pumpWidget(containerTest.marginSymmetric(vertical: 16));
... ... @@ -78,7 +80,7 @@ void main() {
});
testWidgets('Test of marginZero', (tester) async {
Widget containerTest = Foo();
Widget containerTest = const Foo();
await tester.pumpWidget(containerTest.marginZero);
... ...
... ... @@ -8,7 +8,7 @@ class TestClass {
class EmptyClass {}
void main() {
dynamic _id(dynamic e) => e;
dynamic newId(dynamic e) => e;
test('null isNullOrBlank should be true for null', () {
expect(GetUtils.isNullOrBlank(null), true);
... ... @@ -38,8 +38,8 @@ void main() {
});
test('isNullOrBlank should validate iterables', () {
expect(GetUtils.isNullOrBlank([].map(_id)), true);
expect(GetUtils.isNullOrBlank([1].map(_id)), false);
expect(GetUtils.isNullOrBlank([].map(newId)), true);
expect(GetUtils.isNullOrBlank([1].map(newId)), false);
});
test('isNullOrBlank should validate lists', () {
... ... @@ -67,8 +67,8 @@ void main() {
group('GetUtils.isLength* functions', () {
test('isLengthEqualTo should validate iterable lengths', () {
// iterables should cover list and set
expect(GetUtils.isLengthEqualTo([].map(_id), 0), true);
expect(GetUtils.isLengthEqualTo([1, 2].map(_id), 2), true);
expect(GetUtils.isLengthEqualTo([].map(newId), 0), true);
expect(GetUtils.isLengthEqualTo([1, 2].map(newId), 2), true);
expect(GetUtils.isLengthEqualTo({}, 0), true);
expect(GetUtils.isLengthEqualTo({1: 1, 2: 1}, 2), true);
... ... @@ -81,9 +81,9 @@ void main() {
test('isLengthGreaterOrEqual should validate lengths', () {
// iterables should cover list and set
expect(GetUtils.isLengthGreaterOrEqual([].map(_id), 0), true);
expect(GetUtils.isLengthGreaterOrEqual([1, 2].map(_id), 2), true);
expect(GetUtils.isLengthGreaterOrEqual([1, 2].map(_id), 1), true);
expect(GetUtils.isLengthGreaterOrEqual([].map(newId), 0), true);
expect(GetUtils.isLengthGreaterOrEqual([1, 2].map(newId), 2), true);
expect(GetUtils.isLengthGreaterOrEqual([1, 2].map(newId), 1), true);
expect(GetUtils.isLengthGreaterOrEqual({}, 0), true);
expect(GetUtils.isLengthGreaterOrEqual({1: 1, 2: 1}, 1), true);
... ... @@ -97,9 +97,9 @@ void main() {
test('isLengthLessOrEqual should validate lengths', () {
// iterables should cover list and set
expect(GetUtils.isLengthLessOrEqual([].map(_id), 0), true);
expect(GetUtils.isLengthLessOrEqual([1, 2].map(_id), 2), true);
expect(GetUtils.isLengthLessOrEqual([1, 2].map(_id), 1), false);
expect(GetUtils.isLengthLessOrEqual([].map(newId), 0), true);
expect(GetUtils.isLengthLessOrEqual([1, 2].map(newId), 2), true);
expect(GetUtils.isLengthLessOrEqual([1, 2].map(newId), 1), false);
expect(GetUtils.isLengthLessOrEqual({}, 0), true);
expect(GetUtils.isLengthLessOrEqual({1: 1, 2: 1}, 1), false);
... ...
@TestOn('browser')
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
... ...