From 0b82cfb673d09b24b33dde1123519986c1d1387b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Rodri=CC=81guez?= Date: Thu, 31 Jul 2025 15:40:07 -0300 Subject: [PATCH 1/2] Create notification module for notification management --- .idea/flutter-base.iml | 5 + .idea/libraries/Dart_SDK.xml | 42 ++--- app/lib/main/app.dart | 67 ++++++- app/lib/main/init.dart | 2 + .../ui/pages/login/login_page.dart | 44 ++++- app/pubspec.yaml | 2 + modules/common/.flutter-plugins | 11 +- modules/common/.flutter-plugins-dependencies | 2 +- modules/data/.flutter-plugins | 27 +-- modules/data/.flutter-plugins-dependencies | 2 +- modules/domain/.flutter-plugins | 11 +- modules/domain/.flutter-plugins-dependencies | 2 +- modules/notifications/.gitignore | 29 +++ modules/notifications/.metadata | 10 ++ modules/notifications/CHANGELOG.md | 3 + modules/notifications/LICENSE | 1 + modules/notifications/README.md | 39 ++++ modules/notifications/analysis_options.yaml | 4 + .../lib/bloc/notification_cubit.dart | 34 ++++ modules/notifications/lib/init.dart | 13 ++ modules/notifications/lib/notifications.dart | 7 + .../lib/presentation/notification_widget.dart | 170 ++++++++++++++++++ .../lib/presentation/resources/resources.dart | 10 ++ .../lib/presentation/resources/spacing.dart | 43 +++++ .../lib/service/notification_service.dart | 24 +++ .../lib/utils/notification_constants.dart | 8 + modules/notifications/pubspec.yaml | 58 ++++++ .../test/notifications_test.dart | 12 ++ 28 files changed, 632 insertions(+), 50 deletions(-) create mode 100644 modules/notifications/.gitignore create mode 100644 modules/notifications/.metadata create mode 100644 modules/notifications/CHANGELOG.md create mode 100644 modules/notifications/LICENSE create mode 100644 modules/notifications/README.md create mode 100644 modules/notifications/analysis_options.yaml create mode 100644 modules/notifications/lib/bloc/notification_cubit.dart create mode 100644 modules/notifications/lib/init.dart create mode 100644 modules/notifications/lib/notifications.dart create mode 100644 modules/notifications/lib/presentation/notification_widget.dart create mode 100644 modules/notifications/lib/presentation/resources/resources.dart create mode 100644 modules/notifications/lib/presentation/resources/spacing.dart create mode 100644 modules/notifications/lib/service/notification_service.dart create mode 100644 modules/notifications/lib/utils/notification_constants.dart create mode 100644 modules/notifications/pubspec.yaml create mode 100644 modules/notifications/test/notifications_test.dart diff --git a/.idea/flutter-base.iml b/.idea/flutter-base.iml index 63f30ae..dcd5024 100644 --- a/.idea/flutter-base.iml +++ b/.idea/flutter-base.iml @@ -63,9 +63,14 @@ + + + + + \ No newline at end of file diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index 8b6af92..797a79c 100644 --- a/.idea/libraries/Dart_SDK.xml +++ b/.idea/libraries/Dart_SDK.xml @@ -1,27 +1,27 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/app/lib/main/app.dart b/app/lib/main/app.dart index 3e3f732..499afd4 100644 --- a/app/lib/main/app.dart +++ b/app/lib/main/app.dart @@ -1,3 +1,4 @@ +import 'package:app/presentation/themes/local_theme.dart'; import 'package:common/core/resource.dart'; import 'package:flutter/material.dart'; import 'package:domain/bloc/app/app_cubit.dart'; @@ -11,6 +12,10 @@ import 'package:app/presentation/utils/lang_extensions.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:go_router/go_router.dart'; +import 'package:notifications/bloc/notification_cubit.dart'; +import 'package:notifications/presentation/notification_widget.dart'; +import 'package:notifications/service/notification_service.dart'; +import 'package:notifications/utils/notification_constants.dart'; import 'init.dart'; @@ -25,6 +30,9 @@ class App extends StatelessWidget { providers: [ BlocProvider(create: (_) => getIt()), BlocProvider(create: (_) => getIt()), + BlocProvider.value( + value: getIt().notificationCubit, + ), ], child: BlocBuilder( builder: (context, state) { @@ -51,7 +59,64 @@ class App extends StatelessWidget { } } }, - child: child, + child: Stack( + children: [ + child ?? const SizedBox.shrink(), + BlocBuilder( + buildWhen: (previous, current) => previous != current, + builder: (context, state) { + return state?.message?.isNotEmpty ?? false + ? Positioned( + top: NotificationConstants + .notificationButtonPadding, + child: SizedBox( + width: MediaQuery.of(context).size.width, + child: Row( + children: [ + const Spacer(), + // Change according on project needs + NotificationWidget( + onClose: () { + getIt() + .clearNotification(); + }, + message: state!.message!, + style: Theme.of(context) + .textTheme + .headlineMedium + ?.copyWith( + color: context + .colors.neutralVariant.v0, + ), + status: state.status, + maxWidth: + NotificationConstants.toastMaxWidth, + progressBarColor: switch ( + state.status) { + NotificationStatus.idle => + context.colors.primary.v10, + NotificationStatus.information => + context.colors.primary.v99, + NotificationStatus.success => + context.colors.primary.v0, + NotificationStatus.error => + context.colors.error.v40, + }, + progressBarBorderColor: + context.colors.neutral.v0, + progressBarBackgroundColor: + context.colors.neutral.v0, + ), + const Spacer(), + ], + ), + ), + ) + : const SizedBox.shrink(); + }, + ), + ], + ), ); }, routerConfig: _goRouter, diff --git a/app/lib/main/init.dart b/app/lib/main/init.dart index cd7eb36..cd0c48d 100644 --- a/app/lib/main/init.dart +++ b/app/lib/main/init.dart @@ -6,6 +6,7 @@ import 'package:example_domain/init.dart'; import 'package:example_data/init.dart'; import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; +import 'package:notifications/init.dart'; import 'package:url_strategy/url_strategy.dart'; void init() async { @@ -21,6 +22,7 @@ Future initialize() async { await CommonInit.initialize(getIt); await DataInit.initialize(getIt); await DomainInit.initialize(getIt); + await NotificationsInit.initialize(getIt); // Example Module init await ExampleDomainInit.initialize(getIt); diff --git a/app/lib/presentation/ui/pages/login/login_page.dart b/app/lib/presentation/ui/pages/login/login_page.dart index 8eb2545..9b9573a 100644 --- a/app/lib/presentation/ui/pages/login/login_page.dart +++ b/app/lib/presentation/ui/pages/login/login_page.dart @@ -1,7 +1,5 @@ import 'package:app/main/init.dart'; import 'package:app/presentation/themes/app_themes.dart'; -import 'package:app/presentation/themes/local_theme.dart'; -import 'package:app/presentation/themes/resources/app_theme_data.dart'; import 'package:common/core/resource.dart'; import 'package:domain/bloc/auth/auth_cubit.dart'; import 'package:domain/services/AuthService.dart'; @@ -9,10 +7,13 @@ import 'package:flutter/material.dart'; import 'package:app/presentation/ui/custom/app_theme_switch.dart'; import 'package:app/presentation/ui/custom/loading_screen.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:notifications/service/notification_service.dart'; class LoginPage extends StatelessWidget { AuthService get _authService => getIt(); + NotificationService get _notificationService => getIt(); + const LoginPage({Key? key}) : super(key: key); @override @@ -41,6 +42,45 @@ class LoginPage extends StatelessWidget { }, ), ), + const SizedBox(height: 16), + SizedBox( + width: double.maxFinite, + child: ElevatedButton( + child: const Text('Success notification'), + onPressed: () { + _notificationService.notify( + 'Success message', + NotificationStatus.success, + ); + }, + ), + ), + const SizedBox(height: 16), + SizedBox( + width: double.maxFinite, + child: ElevatedButton( + child: const Text('Error notification'), + onPressed: () { + _notificationService.notify( + 'Error message', + NotificationStatus.error, + ); + }, + ), + ), + const SizedBox(height: 16), + SizedBox( + width: double.maxFinite, + child: ElevatedButton( + child: const Text('Information notification'), + onPressed: () { + _notificationService.notify( + 'Information message', + NotificationStatus.information, + ); + }, + ), + ), ], ), ), diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 0f7943f..9b5bdde 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -47,6 +47,8 @@ dependencies: path: ../modules/common data: path: ../modules/data + notifications: + path: ../modules/notifications # Remove example dependencies example_data: diff --git a/modules/common/.flutter-plugins b/modules/common/.flutter-plugins index 40b8cd5..2dfc7fc 100644 --- a/modules/common/.flutter-plugins +++ b/modules/common/.flutter-plugins @@ -1,6 +1,7 @@ # This is a generated file; do not edit or check into version control. -package_info_plus=/Users/fabianvalencia/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/ -permission_handler=/Users/fabianvalencia/.pub-cache/hosted/pub.dev/permission_handler-10.4.5/ -permission_handler_android=/Users/fabianvalencia/.pub-cache/hosted/pub.dev/permission_handler_android-10.3.6/ -permission_handler_apple=/Users/fabianvalencia/.pub-cache/hosted/pub.dev/permission_handler_apple-9.1.4/ -permission_handler_windows=/Users/fabianvalencia/.pub-cache/hosted/pub.dev/permission_handler_windows-0.1.3/ +package_info_plus=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/ +permission_handler=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler-11.4.0/ +permission_handler_android=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_android-12.1.0/ +permission_handler_apple=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_apple-9.4.7/ +permission_handler_html=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_html-0.1.3+5/ +permission_handler_windows=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_windows-0.2.1/ diff --git a/modules/common/.flutter-plugins-dependencies b/modules/common/.flutter-plugins-dependencies index 65e0b09..acedba3 100644 --- a/modules/common/.flutter-plugins-dependencies +++ b/modules/common/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"package_info_plus","path":"/Users/fabianvalencia/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/Users/fabianvalencia/.pub-cache/hosted/pub.dev/permission_handler_apple-9.1.4/","native_build":true,"dependencies":[]}],"android":[{"name":"package_info_plus","path":"/Users/fabianvalencia/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/Users/fabianvalencia/.pub-cache/hosted/pub.dev/permission_handler_android-10.3.6/","native_build":true,"dependencies":[]}],"macos":[{"name":"package_info_plus","path":"/Users/fabianvalencia/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus","path":"/Users/fabianvalencia/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":false,"dependencies":[]}],"windows":[{"name":"package_info_plus","path":"/Users/fabianvalencia/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"/Users/fabianvalencia/.pub-cache/hosted/pub.dev/permission_handler_windows-0.1.3/","native_build":true,"dependencies":[]}],"web":[{"name":"package_info_plus","path":"/Users/fabianvalencia/.pub-cache/hosted/pub.dev/package_info_plus-4.2.0/","dependencies":[]}]},"dependencyGraph":[{"name":"package_info_plus","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]}],"date_created":"2024-05-02 16:35:44.210631","version":"3.19.3"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_apple-9.4.7/","native_build":true,"dependencies":[]}],"android":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_android-12.1.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":false,"dependencies":[]}],"windows":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_windows-0.2.1/","native_build":true,"dependencies":[]}],"web":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","dependencies":[]},{"name":"permission_handler_html","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_html-0.1.3+5/","dependencies":[]}]},"dependencyGraph":[{"name":"package_info_plus","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_html","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_html","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]}],"date_created":"2025-07-31 12:46:11.975084","version":"3.24.5","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/modules/data/.flutter-plugins b/modules/data/.flutter-plugins index ae81242..60a55da 100644 --- a/modules/data/.flutter-plugins +++ b/modules/data/.flutter-plugins @@ -1,14 +1,15 @@ # This is a generated file; do not edit or check into version control. -package_info_plus=/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/ -path_provider_linux=/Users/usuario/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.0/ -path_provider_windows=/Users/usuario/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.0/ -permission_handler=/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler-10.4.3/ -permission_handler_android=/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler_android-10.3.3/ -permission_handler_apple=/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler_apple-9.1.4/ -permission_handler_windows=/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler_windows-0.1.3/ -shared_preferences=/Users/usuario/.pub-cache/hosted/pub.dev/shared_preferences-2.2.0/ -shared_preferences_android=/Users/usuario/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.0/ -shared_preferences_foundation=/Users/usuario/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.3/ -shared_preferences_linux=/Users/usuario/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.0/ -shared_preferences_web=/Users/usuario/.pub-cache/hosted/pub.dev/shared_preferences_web-2.2.0/ -shared_preferences_windows=/Users/usuario/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.0/ +package_info_plus=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/ +path_provider_linux=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/ +path_provider_windows=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/ +permission_handler=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler-11.4.0/ +permission_handler_android=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_android-12.1.0/ +permission_handler_apple=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_apple-9.4.7/ +permission_handler_html=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_html-0.1.3+5/ +permission_handler_windows=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_windows-0.2.1/ +shared_preferences=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/shared_preferences-2.5.3/ +shared_preferences_android=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/shared_preferences_android-2.4.7/ +shared_preferences_foundation=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.4/ +shared_preferences_linux=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/ +shared_preferences_web=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.3/ +shared_preferences_windows=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/ diff --git a/modules/data/.flutter-plugins-dependencies b/modules/data/.flutter-plugins-dependencies index 96ccafd..b5c0b6e 100644 --- a/modules/data/.flutter-plugins-dependencies +++ b/modules/data/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"package_info_plus","path":"/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler_apple-9.1.4/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/usuario/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"package_info_plus","path":"/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler_android-10.3.3/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/usuario/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"package_info_plus","path":"/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/usuario/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus","path":"/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/usuario/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/usuario/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.0/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"package_info_plus","path":"/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/usuario/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.0/","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler_windows-0.1.3/","native_build":true,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/usuario/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.0/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"package_info_plus","path":"/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/usuario/.pub-cache/hosted/pub.dev/shared_preferences_web-2.2.0/","dependencies":[]}]},"dependencyGraph":[{"name":"package_info_plus","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-06-05 15:15:43.462832","version":"3.22.1"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_apple-9.4.7/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_android-12.1.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/shared_preferences_android-2.4.7/","native_build":true,"dependencies":[]}],"macos":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_windows-0.2.1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","dependencies":[]},{"name":"permission_handler_html","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_html-0.1.3+5/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.3/","dependencies":[]}]},"dependencyGraph":[{"name":"package_info_plus","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_html","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_html","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2025-07-31 12:46:13.239947","version":"3.24.5","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/modules/domain/.flutter-plugins b/modules/domain/.flutter-plugins index 50f5e12..2dfc7fc 100644 --- a/modules/domain/.flutter-plugins +++ b/modules/domain/.flutter-plugins @@ -1,6 +1,7 @@ # This is a generated file; do not edit or check into version control. -package_info_plus=/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/ -permission_handler=/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler-10.4.3/ -permission_handler_android=/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler_android-10.3.3/ -permission_handler_apple=/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler_apple-9.1.4/ -permission_handler_windows=/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler_windows-0.1.3/ +package_info_plus=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/ +permission_handler=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler-11.4.0/ +permission_handler_android=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_android-12.1.0/ +permission_handler_apple=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_apple-9.4.7/ +permission_handler_html=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_html-0.1.3+5/ +permission_handler_windows=/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_windows-0.2.1/ diff --git a/modules/domain/.flutter-plugins-dependencies b/modules/domain/.flutter-plugins-dependencies index 4f774ef..812e54a 100644 --- a/modules/domain/.flutter-plugins-dependencies +++ b/modules/domain/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"package_info_plus","path":"/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler_apple-9.1.4/","native_build":true,"dependencies":[]}],"android":[{"name":"package_info_plus","path":"/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler_android-10.3.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"package_info_plus","path":"/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus","path":"/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/","native_build":false,"dependencies":[]}],"windows":[{"name":"package_info_plus","path":"/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"/Users/usuario/.pub-cache/hosted/pub.dev/permission_handler_windows-0.1.3/","native_build":true,"dependencies":[]}],"web":[{"name":"package_info_plus","path":"/Users/usuario/.pub-cache/hosted/pub.dev/package_info_plus-4.1.0/","dependencies":[]}]},"dependencyGraph":[{"name":"package_info_plus","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]}],"date_created":"2024-06-05 15:26:45.216002","version":"3.22.1"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_apple-9.4.7/","native_build":true,"dependencies":[]}],"android":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_android-12.1.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":false,"dependencies":[]}],"windows":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_windows-0.2.1/","native_build":true,"dependencies":[]}],"web":[{"name":"package_info_plus","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/package_info_plus-8.3.0/","dependencies":[]},{"name":"permission_handler_html","path":"/Users/juanrodriguez/.pub-cache/hosted/pub.dev/permission_handler_html-0.1.3+5/","dependencies":[]}]},"dependencyGraph":[{"name":"package_info_plus","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_html","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_html","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]}],"date_created":"2025-07-31 12:46:13.109027","version":"3.24.5","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/modules/notifications/.gitignore b/modules/notifications/.gitignore new file mode 100644 index 0000000..ac5aa98 --- /dev/null +++ b/modules/notifications/.gitignore @@ -0,0 +1,29 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +build/ diff --git a/modules/notifications/.metadata b/modules/notifications/.metadata new file mode 100644 index 0000000..2d28132 --- /dev/null +++ b/modules/notifications/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "dec2ee5c1f98f8e84a7d5380c05eb8a3d0a81668" + channel: "[user-branch]" + +project_type: package diff --git a/modules/notifications/CHANGELOG.md b/modules/notifications/CHANGELOG.md new file mode 100644 index 0000000..41cc7d8 --- /dev/null +++ b/modules/notifications/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/modules/notifications/LICENSE b/modules/notifications/LICENSE new file mode 100644 index 0000000..ba75c69 --- /dev/null +++ b/modules/notifications/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/modules/notifications/README.md b/modules/notifications/README.md new file mode 100644 index 0000000..4a260d8 --- /dev/null +++ b/modules/notifications/README.md @@ -0,0 +1,39 @@ + + +TODO: Put a short description of the package here that helps potential users +know whether this package might be useful for them. + +## Features + +TODO: List what your package can do. Maybe include images, gifs, or videos. + +## Getting started + +TODO: List prerequisites and provide or point to information on how to +start using the package. + +## Usage + +TODO: Include short and useful examples for package users. Add longer examples +to `/example` folder. + +```dart +const like = 'sample'; +``` + +## Additional information + +TODO: Tell users more about the package: where to find more information, how to +contribute to the package, how to file issues, what response they can expect +from the package authors, and more. diff --git a/modules/notifications/analysis_options.yaml b/modules/notifications/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/modules/notifications/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/modules/notifications/lib/bloc/notification_cubit.dart b/modules/notifications/lib/bloc/notification_cubit.dart new file mode 100644 index 0000000..04145d7 --- /dev/null +++ b/modules/notifications/lib/bloc/notification_cubit.dart @@ -0,0 +1,34 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:notifications/service/notification_service.dart'; + +class NotificationCubit extends Cubit { + NotificationCubit() : super(null); + + void showNotification({ + String? message, + required NotificationStatus status, + }) { + emit( + message?.isEmpty ?? true + ? null + : NotificationState( + message: message, + status: status, + ), + ); + } + + void clearNotification() { + emit(null); + } +} + +class NotificationState { + final String? message; + final NotificationStatus status; + + NotificationState({ + required this.message, + required this.status, + }); +} diff --git a/modules/notifications/lib/init.dart b/modules/notifications/lib/init.dart new file mode 100644 index 0000000..c1d4a0d --- /dev/null +++ b/modules/notifications/lib/init.dart @@ -0,0 +1,13 @@ +import 'package:notifications/bloc/notification_cubit.dart'; +import 'package:get_it/get_it.dart'; +import 'package:notifications/service/notification_service.dart'; + +class NotificationsInit { + static Future initialize(GetIt getIt) async { + //Cubits + getIt.registerSingleton(NotificationCubit()); + + //Services + getIt.registerLazySingleton(() => NotificationService(getIt())); + } +} diff --git a/modules/notifications/lib/notifications.dart b/modules/notifications/lib/notifications.dart new file mode 100644 index 0000000..2d1d579 --- /dev/null +++ b/modules/notifications/lib/notifications.dart @@ -0,0 +1,7 @@ +library notifications; + +/// A Calculator. +class Calculator { + /// Returns [value] plus 1. + int addOne(int value) => value + 1; +} diff --git a/modules/notifications/lib/presentation/notification_widget.dart b/modules/notifications/lib/presentation/notification_widget.dart new file mode 100644 index 0000000..b3b181a --- /dev/null +++ b/modules/notifications/lib/presentation/notification_widget.dart @@ -0,0 +1,170 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_animate/flutter_animate.dart'; +import 'package:flutter_rounded_progress_bar/flutter_rounded_progress_bar.dart'; +import 'package:flutter_rounded_progress_bar/rounded_progress_bar_style.dart'; +import 'package:notifications/presentation/resources/resources.dart'; +import 'package:notifications/service/notification_service.dart'; +import 'package:notifications/utils/notification_constants.dart'; + +class NotificationWidget extends StatefulWidget { + final VoidCallback? onClose; + final String message; + final TextStyle? style; + final NotificationStatus status; + final double? maxWidth; + final Color progressBarColor; + final Color? progressBarBorderColor; + final Color? progressBarBackgroundColor; + + const NotificationWidget({ + super.key, + required this.onClose, + required this.message, + required this.style, + this.status = NotificationStatus.idle, + this.maxWidth, + required this.progressBarColor, + this.progressBarBorderColor, + this.progressBarBackgroundColor, + }); + + @override + State createState() => _NotificationWidgetState(); +} + +class _NotificationWidgetState extends State + with SingleTickerProviderStateMixin { + late AnimationController progressController; + late Animation animation; + late Animation colorAnimation; + late CurvedAnimation curve; + final Future countDown = Future.delayed( + NotificationConstants.toastDurationInMilliseconds.milliseconds, + ); + + @override + void initState() { + super.initState(); + + progressController = AnimationController( + vsync: this, + duration: const Duration( + milliseconds: 1, + ), + ); + + curve = CurvedAnimation( + parent: progressController, + curve: Curves.linear, + ); + + animation = Tween(begin: 100, end: 0).animate(curve) + ..addListener(() { + setState(() {}); + }); + + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + progressController.forward(); + _closeToast(); + }); + } + + void _closeToast() async { + await countDown; + if (mounted) { + widget.onClose?.call(); + } + } + + @override + void dispose() { + progressController.dispose(); + countDown.ignore(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Container( + constraints: BoxConstraints( + maxWidth: widget.maxWidth ?? double.infinity, + ), + child: Card( + elevation: 5.0, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Stack( + children: [ + Align( + alignment: Alignment.topRight, + child: Padding( + padding: const EdgeInsets.only( + top: NotificationConstants.closeToastButtonPadding, + right: NotificationConstants.closeToastButtonPadding, + ), + child: InkWell( + onTap: widget.onClose, + child: const Icon(Icons.close), + ), + ), + ), + Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: EdgeInsets.symmetric( + vertical: spacing.m, + horizontal: spacing.s, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + // Change according of project needs + switch (widget.status) { + NotificationStatus.idle => const SizedBox.shrink(), + NotificationStatus.information => + const Icon(Icons.info_outline), + NotificationStatus.success => + const Icon(Icons.check_circle_outline), + NotificationStatus.error => + const Icon(Icons.error_outline), + }, + SizedBox(width: spacing.xs), + Expanded( + child: Text( + widget.message, + style: widget.style, + ), + ), + ], + ), + ), + ), + ], + ), + RoundedProgressBar( + milliseconds: NotificationConstants.toastDurationInMilliseconds, + height: NotificationConstants.roundedProgressBarHeight, + borderRadius: const BorderRadius.all( + Radius.circular( + NotificationConstants.progressBarRadius, + ), + ), + style: RoundedProgressBarStyle( + borderWidth: spacing.xxs, + widthShadow: 0, + colorBorder: + widget.progressBarBorderColor ?? Colors.transparent, + colorProgress: widget.progressBarColor, + backgroundProgress: + widget.progressBarBackgroundColor ?? Colors.transparent, + ), + percent: animation.value, + ), + ], + ), + ), + ); + } +} diff --git a/modules/notifications/lib/presentation/resources/resources.dart b/modules/notifications/lib/presentation/resources/resources.dart new file mode 100644 index 0000000..c0387a4 --- /dev/null +++ b/modules/notifications/lib/presentation/resources/resources.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; +import 'package:notifications/presentation/resources/spacing.dart'; + +extension SpacingOnWidget on Widget { + Spacing get spacing => Spacing(); +} + +extension SpacingOnStateWidget on State { + Spacing get spacing => Spacing(); +} diff --git a/modules/notifications/lib/presentation/resources/spacing.dart b/modules/notifications/lib/presentation/resources/spacing.dart new file mode 100644 index 0000000..ccc52b0 --- /dev/null +++ b/modules/notifications/lib/presentation/resources/spacing.dart @@ -0,0 +1,43 @@ +class Spacing { + final double spacerSize; + final double xxs; + final double xs; + final double s; + final double m; + final double l; + final double xl; + final double xxl; + final double xxxl; + final double xxxxl; + final double xxxxxl; + + Spacing._({ + required this.spacerSize, + required this.xxs, + required this.xs, + required this.s, + required this.m, + required this.l, + required this.xl, + required this.xxl, + required this.xxxl, + required this.xxxxl, + required this.xxxxxl, + }); + + factory Spacing({double spacerSize = 4.0}) { + return Spacing._( + spacerSize: spacerSize, + xxs: 1 * spacerSize, + xs: 2 * spacerSize, + s: 3 * spacerSize, + m: 4 * spacerSize, + l: 5 * spacerSize, + xl: 6 * spacerSize, + xxl: 7 * spacerSize, + xxxl: 8 * spacerSize, + xxxxl: 9 * spacerSize, + xxxxxl: 10 * spacerSize, + ); + } +} diff --git a/modules/notifications/lib/service/notification_service.dart b/modules/notifications/lib/service/notification_service.dart new file mode 100644 index 0000000..988861d --- /dev/null +++ b/modules/notifications/lib/service/notification_service.dart @@ -0,0 +1,24 @@ +import 'package:notifications/bloc/notification_cubit.dart'; + +class NotificationService { + final NotificationCubit _notificationCubit; + + NotificationService(this._notificationCubit); + + NotificationCubit get notificationCubit => _notificationCubit; + + void notify(String message, NotificationStatus status) { + _notificationCubit.showNotification(message: message, status: status); + } + + void clearNotification() { + _notificationCubit.clearNotification(); + } +} + +enum NotificationStatus { + idle, + information, + success, + error, +} diff --git a/modules/notifications/lib/utils/notification_constants.dart b/modules/notifications/lib/utils/notification_constants.dart new file mode 100644 index 0000000..994bb64 --- /dev/null +++ b/modules/notifications/lib/utils/notification_constants.dart @@ -0,0 +1,8 @@ +class NotificationConstants { + static const toastDurationInMilliseconds = 5000; + static const closeToastButtonPadding = 9.0; + static const roundedProgressBarHeight = 5.0; + static const progressBarRadius = 8.0; + static const notificationButtonPadding = 60.0; + static const toastMaxWidth = 313.0; +} diff --git a/modules/notifications/pubspec.yaml b/modules/notifications/pubspec.yaml new file mode 100644 index 0000000..9b42c7b --- /dev/null +++ b/modules/notifications/pubspec.yaml @@ -0,0 +1,58 @@ +name: notifications +description: "A new Flutter package project." +version: 0.0.1 +homepage: + +environment: + sdk: ^3.5.4 + flutter: ">=1.17.0" + +dependencies: + flutter: + sdk: flutter + flutter_bloc: ^8.1.2 + get_it: ^7.6.0 + flutter_animate: ^4.2.0+1 + flutter_rounded_progress_bar: ^0.3.2 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^4.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + +# To add assets to your package, add an assets section, like this: +# assets: +# - images/a_dot_burr.jpeg +# - images/a_dot_ham.jpeg +# +# For details regarding assets in packages, see +# https://flutter.dev/to/asset-from-package +# +# An image asset can refer to one or more resolution-specific "variants", see +# https://flutter.dev/to/resolution-aware-images + +# To add custom fonts to your package, add a fonts section here, +# in this "flutter" section. Each entry in this list should have a +# "family" key with the font family name, and a "fonts" key with a +# list giving the asset and other descriptors for the font. For +# example: +# fonts: +# - family: Schyler +# fonts: +# - asset: fonts/Schyler-Regular.ttf +# - asset: fonts/Schyler-Italic.ttf +# style: italic +# - family: Trajan Pro +# fonts: +# - asset: fonts/TrajanPro.ttf +# - asset: fonts/TrajanPro_Bold.ttf +# weight: 700 +# +# For details regarding fonts in packages, see +# https://flutter.dev/to/font-from-package diff --git a/modules/notifications/test/notifications_test.dart b/modules/notifications/test/notifications_test.dart new file mode 100644 index 0000000..6a28abb --- /dev/null +++ b/modules/notifications/test/notifications_test.dart @@ -0,0 +1,12 @@ +import 'package:flutter_test/flutter_test.dart'; + +import 'package:notifications/notifications.dart'; + +void main() { + test('adds one to input values', () { + final calculator = Calculator(); + expect(calculator.addOne(2), 3); + expect(calculator.addOne(-7), -6); + expect(calculator.addOne(0), 1); + }); +} From d7b8ef02124dfd37bd08924b6b28609a8642f700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Rodri=CC=81guez?= Date: Thu, 31 Jul 2025 16:09:57 -0300 Subject: [PATCH 2/2] Refactor --- modules/notifications/lib/notifications.dart | 7 ------- modules/notifications/test/notifications_test.dart | 12 ------------ 2 files changed, 19 deletions(-) delete mode 100644 modules/notifications/lib/notifications.dart delete mode 100644 modules/notifications/test/notifications_test.dart diff --git a/modules/notifications/lib/notifications.dart b/modules/notifications/lib/notifications.dart deleted file mode 100644 index 2d1d579..0000000 --- a/modules/notifications/lib/notifications.dart +++ /dev/null @@ -1,7 +0,0 @@ -library notifications; - -/// A Calculator. -class Calculator { - /// Returns [value] plus 1. - int addOne(int value) => value + 1; -} diff --git a/modules/notifications/test/notifications_test.dart b/modules/notifications/test/notifications_test.dart deleted file mode 100644 index 6a28abb..0000000 --- a/modules/notifications/test/notifications_test.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; - -import 'package:notifications/notifications.dart'; - -void main() { - test('adds one to input values', () { - final calculator = Calculator(); - expect(calculator.addOne(2), 3); - expect(calculator.addOne(-7), -6); - expect(calculator.addOne(0), 1); - }); -}