diff --git a/Makefile b/Makefile
index f554460b..ba80b922 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,13 @@
-build:
- @flutter clean
- @flutter build macos --release
+build_macos:
+ @rm -rf release
+ fvm flutter clean
+ fvm flutter build macos --release
@mkdir release
@appdmg installers/dmg_creator/config.json release/Onix_Flutter_Project_Generator.dmg
+
+build_runner:
+ fvm dart run build_runner build --delete-conflicting-outputs
+
+codegen:
+ dart run build_runner build --delete-conflicting-outputs
\ No newline at end of file
diff --git a/README.md b/README.md
index 908e0ed0..df2c6a56 100644
--- a/README.md
+++ b/README.md
@@ -18,11 +18,16 @@
How does it work? Watch the video!
+
+
+https://github.com/user-attachments/assets/5fd10595-2964-4006-8926-4715e1032cba
+
+
@@ -77,7 +82,7 @@ Also there an option to select **optional packages to include** to the project:
* **Localization** - [Intl](https://pub.dev/packages/intl_utils)
* **Theming** - [ThemeTailor](https://pub.dev/packages/theme_tailor)
* **UI** - [ScreenUtil](https://pub.dev/packages/flutter_screenutil)
-
+* **Monitor and capture errors** - [Sentry](https://pub.dev/packages/sentry_flutter)
## Key Features
@@ -108,4 +113,4 @@ If you have any doubts related to the project or want to discuss something, then
## License
-Licensed under the MIT License, Copyright (c) 2023-present Onix-Systems
\ No newline at end of file
+Licensed under the MIT License, Copyright (c) 2024-present Onix-Systems
diff --git a/analysis_options.yaml b/analysis_options.yaml
index c2fdba0c..65f9f11a 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -14,22 +14,253 @@ analyzer:
- "bricks/**"
- '**/*.g.dart'
- '**/*.freezed.dart'
+ - "lib/app/localization/**"
+
+ errors:
+ prefer_mixin: ignore
+ flutter_style_todos: ignore
+ invalid_annotation_target: ignore
+ always_use_package_imports: warning
+ avoid_dynamic_calls: info
+ avoid_empty_else: error
+ avoid_print: warning
+ avoid_relative_lib_imports: warning
+ avoid_returning_null_for_future: error
+ avoid_slow_async_io: warning
+ avoid_type_to_string: error
+ avoid_types_as_parameter_names: info
+ avoid_web_libraries_in_flutter: error
+ cancel_subscriptions: error
+ close_sinks: error
+ comment_references: info
+ control_flow_in_finally: error
+ empty_statements: error
+ hash_and_equals: error
+ iterable_contains_unrelated_type: error
+ list_remove_unrelated_type: error
+ literal_only_boolean_expressions: warning
+ no_adjacent_strings_in_list: error
+ no_duplicate_case_values: error
+ no_logic_in_create_state: error
+ prefer_void_to_null: error
+ test_types_in_equals: error
+ throw_in_finally: error
+ unnecessary_statements: error
+ unrelated_type_equality_checks: error
+ unsafe_html: error
+ use_build_context_synchronously: info
+ use_key_in_widget_constructors: info
+ valid_regexps: error
+ missing_required_param: error
+ missing_return: error
+ collection_methods_unrelated_type: warning
+ avoid_final_parameters: error
+ cast_nullable_to_non_nullable: warning
+ implicit_call_tearoffs: info
linter:
- # The lint rules applied to this project can be customized in the
- # section below to disable rules from the `package:flutter_lints/flutter.yaml`
- # included above or to enable additional rules. A list of all available lints
- # and their documentation is published at
- # https://dart-lang.github.io/linter/lints/index.html.
- #
- # Instead of disabling a lint rule for the entire project in the
- # section below, it can also be suppressed for a single line of code
- # or a specific dart file by using the `// ignore: name_of_lint` and
- # `// ignore_for_file: name_of_lint` syntax on the line or in the file
- # producing the lint.
rules:
- # avoid_print: false # Uncomment to disable the `avoid_print` rule
- # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
+ # Const rules.
+ prefer_const_constructors: true
+ prefer_const_constructors_in_immutables: true
+ prefer_const_declarations: true
+ prefer_const_literals_to_create_immutables: true
+ unnecessary_const: true
+ unnecessary_late: true
+
+ # Error rules.
+ always_use_package_imports: true
+ avoid_empty_else: true
+ avoid_print: true
+ avoid_relative_lib_imports: true
+ avoid_slow_async_io: true
+ avoid_type_to_string: true
+ avoid_types_as_parameter_names: true
+ avoid_web_libraries_in_flutter: true
+ cancel_subscriptions: true
+ close_sinks: true
+ control_flow_in_finally: true
+ empty_statements: true
+ hash_and_equals: true
+ collection_methods_unrelated_type: true
+ literal_only_boolean_expressions: true
+ no_adjacent_strings_in_list: true
+ no_duplicate_case_values: true
+ no_logic_in_create_state: true
+ prefer_void_to_null: true
+ test_types_in_equals: true
+ throw_in_finally: true
+ unnecessary_statements: true
+ unrelated_type_equality_checks: true
+ unsafe_html: true
+ use_build_context_synchronously: true
+ use_key_in_widget_constructors: true
+ valid_regexps: true
+ avoid_dynamic_calls: true
+ invalid_case_patterns: true
+
+ # Style rules.
+ always_declare_return_types: true
+ always_put_required_named_parameters_first: true
+ annotate_overrides: true
+ avoid_annotating_with_dynamic: true
+ avoid_bool_literals_in_conditional_expressions: true
+ avoid_catching_errors: true
+ avoid_equals_and_hash_code_on_mutable_classes: true
+ avoid_escaping_inner_quotes: true
+ avoid_field_initializers_in_const_classes: true
+ avoid_function_literals_in_foreach_calls: true
+ avoid_implementing_value_types: true
+ avoid_init_to_null: true
+ avoid_js_rounded_ints: true
+ avoid_multiple_declarations_per_line: true
+ avoid_null_checks_in_equality_operators: true
+ avoid_positional_boolean_parameters: true
+ avoid_private_typedef_functions: true
+ avoid_renaming_method_parameters: true
+ avoid_return_types_on_setters: true
+ avoid_returning_null_for_void: true
+ avoid_returning_this: true
+ avoid_setters_without_getters: true
+ avoid_shadowing_type_parameters: true
+ avoid_single_cascade_in_expression_statements: true
+ avoid_types_on_closure_parameters: true
+ avoid_unnecessary_containers: true
+ avoid_unused_constructor_parameters: true
+ avoid_void_async: true
+ await_only_futures: true
+ camel_case_extensions: true
+ camel_case_types: true
+ cascade_invocations: true
+ constant_identifier_names: true
+ curly_braces_in_flow_control_structures: true
+ deprecated_consistency: true
+ directives_ordering: true
+ do_not_use_environment: true
+ empty_catches: true
+ empty_constructor_bodies: true
+ exhaustive_cases: true
+ file_names: true
+ implementation_imports: true
+ leading_newlines_in_multiline_strings: true
+ library_names: true
+ library_prefixes: true
+ missing_whitespace_between_adjacent_strings: true
+ no_runtimeType_toString: true
+ non_constant_identifier_names: true
+ null_closures: true
+ omit_local_variable_types: true
+ one_member_abstracts: true
+ only_throw_errors: true
+ overridden_fields: true
+ package_api_docs: true
+ parameter_assignments: true
+ prefer_adjacent_string_concatenation: true
+ prefer_asserts_in_initializer_lists: true
+ prefer_collection_literals: true
+ prefer_conditional_assignment: true
+ prefer_constructors_over_static_methods: true
+ prefer_contains: true
+ prefer_final_fields: true
+ prefer_final_in_for_each: true
+ prefer_final_locals: true
+ prefer_for_elements_to_map_fromIterable: true
+ prefer_function_declarations_over_variables: true
+ prefer_generic_function_type_aliases: true
+ prefer_if_elements_to_conditional_expressions: true
+ prefer_if_null_operators: true
+ prefer_initializing_formals: true
+ prefer_inlined_adds: true
+ prefer_interpolation_to_compose_strings: true
+ prefer_is_empty: true
+ prefer_is_not_empty: true
+ prefer_is_not_operator: true
+ prefer_iterable_whereType: true
+ prefer_mixin: true
+ prefer_null_aware_operators: true
+ prefer_single_quotes: true
+ prefer_spread_collections: true
+ prefer_typing_uninitialized_variables: true
+ provide_deprecation_message: true
+ public_member_api_docs: false
+ recursive_getters: true
+ sized_box_for_whitespace: true
+ slash_for_doc_comments: true
+ sort_child_properties_last: true
+ sort_constructors_first: false
+ sort_unnamed_constructors_first: false
+ type_annotate_public_apis: true
+ type_init_formals: true
+ unawaited_futures: true
+ unnecessary_await_in_return: true
+ unnecessary_brace_in_string_interps: true
+ unnecessary_getters_setters: true
+ unnecessary_lambdas: true
+ unnecessary_new: true
+ unnecessary_null_aware_assignments: true
+ unnecessary_null_checks: true
+ unnecessary_null_in_if_null_operators: true
+ unnecessary_nullable_for_final_variable_declarations: true
+ unnecessary_overrides: true
+ unnecessary_parenthesis: true
+ unnecessary_raw_strings: true
+ unnecessary_string_escapes: true
+ unnecessary_string_interpolations: true
+ unnecessary_this: true
+ use_full_hex_values_for_flutter_colors: true
+ use_function_type_syntax_for_parameters: true
+ use_if_null_to_convert_nulls_to_bools: true
+ use_is_even_rather_than_modulo: true
+ use_late_for_private_fields_and_variables: true
+ use_named_constants: true
+ use_raw_strings: true
+ use_rethrow_when_possible: true
+ use_setters_to_change_properties: true
+ use_string_buffers: true
+ use_to_and_as_if_applicable: true
+ void_checks: true
+ lines_longer_than_80_chars: true
+ flutter_style_todos: true
+ conditional_uri_does_not_exist: true
+ no_leading_underscores_for_library_prefixes: true
+ no_leading_underscores_for_local_identifiers: true
+ secure_pubspec_urls: true
+ sized_box_shrink_expand: true
+ use_decorated_box: true
+ use_colored_box: true
+ avoid_double_and_int_checks: true
+ avoid_final_parameters: true
+ avoid_redundant_argument_values: true
+ cast_nullable_to_non_nullable: true
+ combinators_ordering: true
+ dangling_library_doc_comments: true
+ eol_at_end_of_file: true
+ implicit_call_tearoffs: true
+ join_return_with_assignment: true
+ library_private_types_in_public_api: true
+ no_default_cases: true
+ noop_primitive_operations: true
+ null_check_on_nullable_type_parameter: true
+ package_prefixed_library_names: true
+ prefer_asserts_with_message: true
+ prefer_int_literals: true
+ prefer_null_aware_method_calls: true
+ require_trailing_commas: true
+ tighten_type_of_initializing_formals: true
+ unnecessary_constructor_name: true
+ unnecessary_library_directive: true
+ unnecessary_to_list_in_spreads: true
+ use_enums: true
+ use_string_in_part_of_directives: true
+ use_super_parameters: true
+ use_test_throws_matchers: true
+ unnecessary_breaks: true
+
+ # Pub rules.
+ package_names: true
+ depend_on_referenced_packages: true
-# Additional information about this file can be found at
-# https://dart.dev/guides/language/analysis-options
+#https://github.com/dart-lang/lints/blob/main/lib/core.yaml
+#https://github.com/dart-lang/lints/blob/main/lib/recommended.yaml
+#https://github.com/flutter/packages/blob/master/packages/flutter_lints/lib/flutter.yaml
+#https://pub.dev/packages/dart_code_metrics
\ No newline at end of file
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/.env b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/.env
index 27cf2606..613ed02b 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/.env
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/.env
@@ -1,2 +1,2 @@
-APIKEY1 = 'APIKEY1'
-APIKEY2 = 'APIKEY2'
\ No newline at end of file
+APIKEY1=APIKEY1
+APIKEY2=APIKEY2
\ No newline at end of file
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app.gen.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app.gen.dart
index c6f7ccde..5df303e4 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app.gen.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app.gen.dart
@@ -3,9 +3,8 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
{{^web_only}}import 'package:loader_overlay/loader_overlay.dart';{{/web_only}}
{{#screen_util}}import 'package:flutter_screenutil/flutter_screenutil.dart';{{/screen_util}}
-import 'package:{{project_name}}/core/arch/bloc/base_bloc_state.dart';
-import 'package:{{project_name}}/app/bloc/app_bloc_imports.dart';
import 'package:{{project_name}}/presentation/style/theme/theme_imports.dart';
+import 'package:{{project_name}}/core/arch/widget/common/theme_switcher.dart';
{{#isGoRouter}}import 'package:{{project_name}}/app/router/app_router.dart';{{/isGoRouter}}
{{^isGoRouter}}import 'package:{{project_name}}/core/di/app.dart';{{/isGoRouter}}
{{^handLocalization}}import 'package:flutter_localizations/flutter_localizations.dart';{{/handLocalization}}
@@ -13,6 +12,7 @@ import 'package:{{project_name}}/presentation/style/theme/theme_imports.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';{{/handLocalization}}
{{#flavorizr}}import 'package:{{project_name}}/core/arch/widget/common/flavor_banner.dart';{{/flavorizr}}
{{^handLocalization}}import 'package:{{project_name}}/app/localization/generated/l10n.dart';{{/handLocalization}}
+{{^isGoRouter}}{{#sentry}}import 'package:sentry_flutter/sentry_flutter.dart';{{/sentry}}{{/isGoRouter}}
class App extends StatefulWidget {
const App({super.key});
@@ -21,12 +21,11 @@ class App extends StatefulWidget {
State createState() => _AppState();
}
-class _AppState extends BaseState {
+class _AppState extends State {
Locale? locale;
-
@override
- Widget buildWidget(BuildContext context) {
+ Widget build(BuildContext context) {
{{#isGoRouter}}AppRouter.init();{{/isGoRouter}}
return {{^web_only}}GlobalLoaderOverlay(
overlayColor: Colors.black.withOpacity(0.5),
@@ -35,8 +34,9 @@ class _AppState extends BaseState {
designSize: const Size(375, 812),
minTextAdapt: true,
builder: (context, child) {
- return{{/screen_util}} blocBuilder(
- builder: (context, state) {
+ return{{/screen_util}}
+ ThemeModeSwitcher(
+ builder: (context, themeMode, _) {
return MaterialApp.router(
debugShowCheckedModeBanner: false,
builder: (context, widget) {
@@ -55,12 +55,17 @@ class _AppState extends BaseState {
scrollBehavior: const CupertinoScrollBehavior(),
theme: createLightTheme(),
darkTheme: createDarkTheme(),
- themeMode: state.themeMode,
- {{#isGoRouter}}routeInformationProvider: AppRouter.router.routeInformationProvider,{{/isGoRouter}}
- routeInformationParser: {{#isGoRouter}}AppRouter.router.routeInformationParser,{{/isGoRouter}}
- {{^isGoRouter}}appRouter().defaultRouteParser(),{{/isGoRouter}}
- routerDelegate: {{#isGoRouter}}AppRouter.router.routerDelegate,{{/isGoRouter}}
- {{^isGoRouter}}appRouter().delegate(),{{/isGoRouter}}
+ themeMode: themeMode,
+ {{^isGoRouter}}
+ {{^sentry}}routerConfig: appRouter().config(),{{/sentry}}
+ {{#sentry}}routerConfig: appRouter().config(
+ navigatorObservers: () => [
+ SentryNavigatorObserver(),
+ ],
+ ),
+ {{/sentry}}
+ {{/isGoRouter}}
+ {{#isGoRouter}}routerConfig: AppRouter.router,{{/isGoRouter}}
locale: locale,
{{^handLocalization}}
localizationsDelegates: const [
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/bloc/app_bloc.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/bloc/app_bloc.dart
deleted file mode 100644
index fcad8f0d..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/bloc/app_bloc.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-import 'package:{{project_name}}/app/bloc/app_bloc_imports.dart';
-import 'package:{{project_name}}/core/arch/bloc/base_bloc.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-
-class AppBloc extends BaseBloc {
- AppBloc() : super(const AppScreenState(themeMode: ThemeMode.system)) {
- on(_onChangeTheme);
- }
-
- void _onChangeTheme(
- ChangeThemeEvent event,
- Emitter emit,
- ) {
- emit(state.copyWith(themeMode: event.mode));
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/bloc/app_bloc_imports.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/bloc/app_bloc_imports.dart
deleted file mode 100644
index dce02ecb..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/bloc/app_bloc_imports.dart
+++ /dev/null
@@ -1,2 +0,0 @@
-export 'app_bloc.dart';
-export 'app_models.dart';
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/bloc/app_models.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/bloc/app_models.dart
deleted file mode 100644
index 300704fd..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/bloc/app_models.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:freezed_annotation/freezed_annotation.dart';
-
-part 'app_models.freezed.dart';
-
-@freezed
-class AppEvent with _$AppEvent {
- const factory AppEvent.changeTheme(ThemeMode mode) = ChangeThemeEvent;
-}
-
-@freezed
-class AppScreenState with _$AppScreenState {
- const factory AppScreenState({required ThemeMode themeMode}) =
- _AppScreenState;
-}
-
-class AppSR {}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/router/app_router.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/router/app_router.dart
index 5588f91c..a1ca2bf0 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/router/app_router.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/router/app_router.dart
@@ -3,6 +3,7 @@
{{#isGoRouter}}import 'package:{{project_name}}/app/router/app_route.dart';{{/isGoRouter}}
{{#isGoRouter}}import 'package:go_router/go_router.dart';{{/isGoRouter}}
{{#isGoRouter}}import 'package:{{project_name}}/core/di/services.dart';{{/isGoRouter}}
+{{#isGoRouter}}{{#sentry}}import 'package:sentry_flutter/sentry_flutter.dart';{{/sentry}}{{/isGoRouter}}
//{imports end}
{{^isGoRouter}}
@@ -33,6 +34,11 @@ class AppRouter {{^isGoRouter}}extends RootStackRouter{{/isGoRouter}}{
routes: [
//{routes end}
],
+ {{#sentry}}
+ observers: [
+ SentryNavigatorObserver(),
+ ],
+ {{/sentry}}
);
}{{/isGoRouter}}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/service/app_service.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/service/app_service.dart
index 561e6224..d5a9bfaa 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/service/app_service.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/service/app_service.dart
@@ -2,7 +2,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
-import 'package:flutter_jailbreak_detection/flutter_jailbreak_detection.dart';
+import 'package:jailbreak_root_detection/jailbreak_root_detection.dart';
/*
* Example of .env file
*
@@ -12,15 +12,15 @@ import 'package:flutter_jailbreak_detection/flutter_jailbreak_detection.dart';
*/
class AppService {
- static const apiKey1 = 'APIKEY1';
- static const apiKey2 = 'APIKEY2';
+ static const String apiKey1 = 'APIKEY1';
+ static const String apiKey2 = 'APIKEY2';
//Change if not need to check for root or jail brake
final _secureFromJailbreak = true;
Future initialize() async {
if (_secureFromJailbreak && !kIsWeb && !kDebugMode) {
- final isJailBroken = await FlutterJailbreakDetection.jailbroken;
+ final isJailBroken = await JailbreakRootDetection.instance.isJailBroken;
if (isJailBroken) {
return false;
}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/dimensions.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/dimensions.dart
index 2f8abfcf..6f958a54 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/dimensions.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/dimensions.dart
@@ -1,6 +1,6 @@
{{#screen_util}}import 'package:flutter_screenutil/flutter_screenutil.dart';{{/screen_util}}
-final class Dimensions {
+class Dimensions {
{{#screen_util}} static final delimiterH10 = 10.h;{{/screen_util}}
{{^screen_util}} static const delimiterH10 = 10.0;{{/screen_util}}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/extension/failure_message_extension.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/extension/failure_message_extension.dart
index c9bf82e0..a573c562 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/extension/failure_message_extension.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/extension/failure_message_extension.dart
@@ -1,8 +1,8 @@
//@formatter:off
{{#handLocalization}}import 'package:{{project_name}}/app/localization/common_app_localization_ext.dart';{{/handLocalization}}
{{^handLocalization}}import 'package:{{project_name}}/app/localization/generated/l10n.dart';{{/handLocalization}}
-import 'package:{{project_name}}/core/arch/domain/entity/failure/api_failure.dart';
-{{#firebase_auth}}import 'package:{{project_name}}/core/arch/domain/entity/failure/firebase_failure.dart';{{/firebase_auth}}
+{{#firebase_auth}}import 'package:{{project_name}}/domain/entity/failure/firebase_failure.dart';{{/firebase_auth}}
+import 'package:onix_flutter_core_models/onix_flutter_core_models.dart';
import 'package:flutter/material.dart';
extension FailureMessageExtension on BuildContext {
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/extension/theme_brightness_extension.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/extension/theme_brightness_extension.dart
index 9ea00454..7ba7cd5b 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/extension/theme_brightness_extension.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/extension/theme_brightness_extension.dart
@@ -1,6 +1,5 @@
-import 'package:{{project_name}}/app/bloc/app_bloc_imports.dart';
import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:{{project_name}}/core/arch/widget/common/theme_switcher.dart';
extension ThemeBrightnessExtension on BuildContext {
bool get isDarkMode => Theme.of(this).brightness == Brightness.dark;
@@ -30,10 +29,7 @@ extension ThemeBrightnessExtension on BuildContext {
break;
}
}
- BlocProvider.of(this).add(
- AppEvent.changeTheme(
- newThemeMode,
- ),
- );
+
+ ThemeModeNotifier.of(this).changeTheme(newThemeMode);
}
}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/qa_utils.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/qa_utils.dart
index 53720b9f..5fdef649 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/qa_utils.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/qa_utils.dart
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
import 'package:{{project_name}}/core/arch/widget/common/toast.dart';
-final class QaUtils {
+class QaUtils {
static Widget buildCharlesProxyBtn(_) {
return const SizedBox();
//TODO SHOW set proxy ONLY FOR QA BUILDS
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/app_bloc_observer.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/app_bloc_observer.dart
deleted file mode 100644
index 5ed972c7..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/app_bloc_observer.dart
+++ /dev/null
@@ -1,16 +0,0 @@
-import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-
-class AppBlocObserver extends BlocObserver {
- @override
- void onEvent(Bloc bloc, Object? event) {
- logger.d('$event');
- super.onEvent(bloc, event);
- }
-
- @override
- void onError(BlocBase bloc, Object error, StackTrace stackTrace) {
- logger.d('$stackTrace');
- super.onError(bloc, error, stackTrace);
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_bloc.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_bloc.dart
deleted file mode 100644
index 1b18532e..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_bloc.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:{{project_name}}/core/arch/bloc/failure_stream_mixin.dart';
-import 'package:{{project_name}}/core/arch/bloc/progress_stream_mixin.dart';
-import 'package:{{project_name}}/core/arch/bloc/sr_mixin.dart';
-
-abstract class BaseBloc extends Bloc
- with
- SingleResultMixin,
- ProgressStreamMixin,
- FailureStreamMixin {
- BaseBloc(super.initialState);
-
- void dispose() {
- closeProgressStream();
- closeFailureStream();
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_bloc_state.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_bloc_state.dart
deleted file mode 100644
index db92f6c4..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_bloc_state.dart
+++ /dev/null
@@ -1,87 +0,0 @@
-//@formatter:off
-import 'package:{{project_name}}/core/arch/bloc/base_bloc.dart';
-import 'package:{{project_name}}/core/arch/bloc/bloc_builders_mixin.dart';
-import 'package:{{project_name}}/core/arch/bloc/bloc_typedefs.dart';
-import 'package:{{project_name}}/core/arch/bloc/stream_listener.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/progress_state/progress_state.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:get_it/get_it.dart';
-{{^web_only}}import 'package:loader_overlay/loader_overlay.dart';{{/web_only}}
-{{#web_only}}import 'package:flutter_overlay_loader/flutter_overlay_loader.dart';
-import 'package:{{project_name}}/app/util/extension/loader.dart';{{/web_only}}
-
-abstract class BaseState, SR,
-W extends StatefulWidget> extends State
- with BlocBuildersMixin {
- bool lazyBloc = false;
- B? _bloc;
-
- @override
- Widget build(BuildContext context) {
- return BlocProvider(
- create: (context) {
- final bloc = createBloc();
- onBlocCreated(context, bloc);
- _bloc = bloc;
- return bloc;
- },
- lazy: lazyBloc,
- child: Builder(
- builder: (context) {
- initParams(context);
- return buildWidget(context);
- },
- ),
- );
- }
-
- @override
- void dispose() {
- {{#web_only}}Loader.hide();{{/web_only}}
- {{^web_only}}if (context.mounted) {
- context.loaderOverlay.hide();
- }{{/web_only}}
- if (_bloc != null) {
- _bloc?.dispose();
- }
- super.dispose();
- }
-
- B blocOf(BuildContext context) => context.read();
-
- B createBloc() => GetIt.I.get();
-
- Widget srObserver({
- required BuildContext context,
- required Widget child,
- required SingleResultListener onSR,
- }) {
- return StreamListener(
- stream: (_bloc ?? blocOf(context)).singleResults,
- onData: (data) {
- onSR(context, data);
- },
- child: child,
- );
- }
-
- void onBlocCreated(BuildContext context, B bloc) {
- bloc.progressStream.listen((event) async {
- if (event is DefaultProgressState) {
- if (event.showProgress) {
- {{#web_only}}context.progressShow();{{/web_only}}
- {{^web_only}}context.loaderOverlay.show();{{/web_only}}
- } else {
- {{#web_only}}context.progressHide();{{/web_only}}
- {{^web_only}}context.loaderOverlay.hide();{{/web_only}}
- }
- }
- });
- }
-
- // ignore: no-empty-block
- void initParams(BuildContext context) {}
-
- Widget buildWidget(BuildContext context);
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_cubit.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_cubit.dart
deleted file mode 100644
index 4b875023..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_cubit.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:{{project_name}}/core/arch/bloc/failure_stream_mixin.dart';
-import 'package:{{project_name}}/core/arch/bloc/progress_stream_mixin.dart';
-import 'package:{{project_name}}/core/arch/bloc/sr_cubit_mixin.dart';
-
-abstract class BaseCubit extends Cubit
- with
- SingleResultCubitMixin,
- ProgressStreamMixin,
- FailureStreamMixin {
- BaseCubit(super.initialState);
-
- void dispose() {
- closeProgressStream();
- closeFailureStream();
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_cubit_state.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_cubit_state.dart
deleted file mode 100644
index 499df4a5..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_cubit_state.dart
+++ /dev/null
@@ -1,87 +0,0 @@
-//@formatter:off
-import 'package:{{project_name}}/core/arch/bloc/base_cubit.dart';
-import 'package:{{project_name}}/core/arch/bloc/bloc_builders_mixin.dart';
-import 'package:{{project_name}}/core/arch/bloc/bloc_typedefs.dart';
-import 'package:{{project_name}}/core/arch/bloc/stream_listener.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/progress_state/progress_state.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:get_it/get_it.dart';
-{{^web_only}}import 'package:loader_overlay/loader_overlay.dart';{{/web_only}}
-{{#web_only}}import 'package:flutter_overlay_loader/flutter_overlay_loader.dart';
-import 'package:{{project_name}}/app/util/extension/loader.dart';{{/web_only}}
-
-abstract class BaseCubitState, SR,
-W extends StatefulWidget> extends State
- with BlocBuildersMixin {
- bool lazyCubit = false;
- C? _cubit;
-
- @override
- Widget build(BuildContext context) {
- return BlocProvider(
- create: (context) {
- final cubit = createCubit();
- onCubitCreated(context, cubit);
- _cubit = cubit;
- return cubit;
- },
- lazy: lazyCubit,
- child: Builder(
- builder: (context) {
- initParams(context);
- return buildWidget(context);
- },
- ),
- );
- }
-
- @override
- void dispose() {
- {{#web_only}}Loader.hide();{{/web_only}}
- {{^web_only}}if (context.mounted) {
- context.loaderOverlay.hide();
- }{{/web_only}}
- if (_cubit != null) {
- _cubit?.dispose();
- }
- super.dispose();
- }
-
- C cubitOf(BuildContext context) => context.read();
-
- C createCubit() => GetIt.I.get();
-
- Widget srObserver({
- required BuildContext context,
- required Widget child,
- required SingleResultListener onSR,
- }) {
- return StreamListener(
- stream: (_cubit ?? cubitOf(context)).singleResults,
- onData: (data) {
- onSR(context, data);
- },
- child: child,
- );
- }
-
- void onCubitCreated(BuildContext context, C cubit) {
- cubit.progressStream.listen((event) async {
- if (event is DefaultProgressState) {
- if (event.showProgress) {
- {{#web_only}}context.progressShow();{{/web_only}}
- {{^web_only}}context.loaderOverlay.show();{{/web_only}}
- } else {
- {{#web_only}}context.progressHide();{{/web_only}}
- {{^web_only}}context.loaderOverlay.hide();{{/web_only}}
- }
- }
- });
- }
-
- // ignore: no-empty-block
- void initParams(BuildContext context) {}
-
- Widget buildWidget(BuildContext context);
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/bloc_builders_mixin.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/bloc_builders_mixin.dart
deleted file mode 100644
index bfca8999..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/bloc_builders_mixin.dart
+++ /dev/null
@@ -1,38 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:{{project_name}}/core/arch/bloc/bloc_typedefs.dart';
-
-mixin BlocBuildersMixin, S, SR> {
- Widget blocConsumer({
- required StateListener builder,
- required ListenDelegate listener,
- BlocBuilderCondition? buildWhen,
- BlocListenerCondition? listenWhen,
- }) {
- return BlocConsumer(
- builder: (_, state) => builder(state),
- listener: listener,
- buildWhen: buildWhen,
- listenWhen: listenWhen,
- );
- }
-
- Widget blocBuilder({
- required BlocWidgetBuilder builder,
- BlocBuilderCondition? buildWhen,
- }) {
- return BlocBuilder(builder: builder, buildWhen: buildWhen);
- }
-
- Widget blocListener({
- required ListenDelegate listener,
- Widget? child,
- BlocListenerCondition? listenWhen,
- }) {
- return BlocListener(
- listener: listener,
- listenWhen: listenWhen,
- child: child,
- );
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/bloc_typedefs.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/bloc_typedefs.dart
deleted file mode 100644
index b9021aab..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/bloc_typedefs.dart
+++ /dev/null
@@ -1,8 +0,0 @@
-import 'package:flutter/material.dart';
-
-typedef ListenDelegate = void Function(BuildContext context, S state);
-typedef StateListener = Widget Function(S state);
-typedef SingleResultListener = void Function(
- BuildContext context,
- SR singleResult,
-);
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/failure_stream_mixin.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/failure_stream_mixin.dart
deleted file mode 100644
index 27144ef6..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/failure_stream_mixin.dart
+++ /dev/null
@@ -1,22 +0,0 @@
-import 'dart:async';
-
-import 'package:{{project_name}}/core/arch/domain/entity/failure/failure.dart';
-
-mixin class FailureStreamMixin {
- final StreamController _errorStreamController =
- StreamController.broadcast();
-
- Stream get failureStream => _errorStreamController.stream;
-
- void onFailure(Failure failure) {
- if (!_errorStreamController.isClosed) {
- _errorStreamController.add(failure);
- }
- }
-
- void closeFailureStream() {
- if (!_errorStreamController.isClosed) {
- _errorStreamController.close();
- }
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/progress_stream_mixin.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/progress_stream_mixin.dart
deleted file mode 100644
index 3bf2fe3b..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/progress_stream_mixin.dart
+++ /dev/null
@@ -1,34 +0,0 @@
-import 'dart:async';
-
-import 'package:{{project_name}}/core/arch/domain/entity/progress_state/progress_state.dart';
-
-mixin class ProgressStreamMixin {
- final StreamController _progressStreamController =
- StreamController.broadcast();
-
- Stream get progressStream =>
- _progressStreamController.stream;
-
- void showProgress({BaseProgressState? state}) {
- if (!_progressStreamController.isClosed) {
- _progressStreamController.add(
- state ?? const DefaultProgressState(showProgress: true),
- );
- }
- }
-
- Future hideProgress({BaseProgressState? state}) async {
- await Future.delayed(const Duration(milliseconds: 50));
- if (!_progressStreamController.isClosed) {
- _progressStreamController.add(
- state ?? const DefaultProgressState(showProgress: false),
- );
- }
- }
-
- void closeProgressStream() {
- if (!_progressStreamController.isClosed) {
- _progressStreamController.close();
- }
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/sr_cubit_mixin.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/sr_cubit_mixin.dart
deleted file mode 100644
index 1d77f806..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/sr_cubit_mixin.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-import 'dart:async';
-
-import 'package:flutter/foundation.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-
-/// Mixin for extending the block's capabilities to support SingleResult -
-/// events that need to be rendered 1 time
-/// - Navigation
-/// - Toast
-/// - Snack
-/// - Some interaction with the animation
-mixin SingleResultCubitMixin on Cubit
- implements SingleResultProvider, SingleResultEmitter {
- @protected
- final StreamController _srController = StreamController.broadcast();
-
- @override
- Stream get singleResults => _srController.stream;
-
- @override
- void addSr(SR sr) {
- if (!_srController.isClosed) _srController.add(sr);
- }
-
- @override
- Future close() {
- _srController.close();
- return super.close();
- }
-}
-
-/// Protocol for providing a stream of events [SingleResult]
-abstract class SingleResultProvider {
- Stream get singleResults;
-}
-
-/// Protocol for receiving events [SingleResult]
-//ignore: one_member_abstracts
-abstract class SingleResultEmitter {
- void addSr(SingleResult sr);
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/sr_mixin.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/sr_mixin.dart
deleted file mode 100644
index c3db4c5a..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/sr_mixin.dart
+++ /dev/null
@@ -1,50 +0,0 @@
-import 'dart:async';
-
-import 'package:flutter/foundation.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-
-/// Mixin for extending the block's capabilities to support SingleResult -
-/// events that need to be rendered 1 time
-/// - Navigation
-/// - Toast
-/// - Snack
-/// - Some interaction with the animation
-mixin SingleResultMixin on Bloc
- implements SingleResultProvider, SingleResultEmitter {
- @protected
- final StreamController _srController = StreamController.broadcast();
-
- @override
- Stream get singleResults => _srController.stream;
-
- @override
- void addSr(SR sr) {
- final observer = Bloc.observer;
- if (observer is SrBlocObserver) observer.onSr(this, sr);
- if (!_srController.isClosed) _srController.add(sr);
- }
-
- @override
- Future close() {
- _srController.close();
-
- return super.close();
- }
-}
-
-/// Protocol for providing a stream of events [SingleResult]
-abstract class SingleResultProvider {
- Stream get singleResults;
-}
-
-/// Protocol for receiving events [SingleResult]
-abstract class SingleResultEmitter {
- void addSr(SingleResult sr);
-}
-
-/// Extending Observer to support logging SingleResult events
-class SrBlocObserver extends BlocObserver {
- @protected
- @mustCallSuper
- void onSr(Bloc bloc, SR sr) {}
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/stream_listener.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/stream_listener.dart
deleted file mode 100644
index 390aee25..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/stream_listener.dart
+++ /dev/null
@@ -1,65 +0,0 @@
-import 'dart:async';
-
-import 'package:flutter/widgets.dart';
-
-/// Widget for managing the Stream [stream] life cycle supplied
-/// to the widget tree.
-class StreamListener extends StatefulWidget {
- final Stream stream;
-
- final Widget child;
- final void Function(T event) onData;
- final Function? onError;
- final Function()? onDone;
- final bool? cancelOnError;
-
- const StreamListener({
- required this.stream,
- required this.child,
- required this.onData,
- this.onError,
- this.onDone,
- this.cancelOnError,
- super.key,
- });
-
- @override
- State> createState() => _StreamListenerState();
-}
-
-class _StreamListenerState extends State> {
- @override
- void initState() {
- super.initState();
- listen();
- }
-
- @override
- void didUpdateWidget(covariant StreamListener oldWidget) {
- super.didUpdateWidget(oldWidget);
- _streamSubs?.cancel();
- listen();
- }
-
- @override
- Widget build(BuildContext context) {
- return widget.child;
- }
-
- StreamSubscription? _streamSubs;
-
- @override
- void dispose() {
- _streamSubs?.cancel();
- super.dispose();
- }
-
- void listen() {
- _streamSubs = widget.stream.listen(
- widget.onData,
- onDone: widget.onDone,
- onError: widget.onError,
- cancelOnError: widget.cancelOnError,
- );
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/local/prefs/base_preferences.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/local/prefs/base_preferences.dart
deleted file mode 100644
index f9e980b2..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/local/prefs/base_preferences.dart
+++ /dev/null
@@ -1,55 +0,0 @@
-import 'package:shared_preferences/shared_preferences.dart';
-
-class BasePreferences {
- Future get(String key, T defaultValue) async {
- final prefs = await SharedPreferences.getInstance();
- T result;
-
- switch (defaultValue.runtimeType) {
- case const (String):
- final value = prefs.getString(key) as T?;
- result = value ?? defaultValue;
- case const (bool):
- final value = prefs.getBool(key) as T?;
- result = value ?? defaultValue;
- case const (double):
- final value = prefs.getDouble(key) as T?;
- result = value ?? defaultValue;
- case const (int):
- final value = prefs.getInt(key) as T?;
- result = value ?? defaultValue;
- default:
- return defaultValue;
- }
- return result;
- }
-
- Future put(String key, T value) async {
- final prefs = await SharedPreferences.getInstance();
- switch (value.runtimeType) {
- case const (String):
- await prefs.setString(key, value as String);
- case const (bool):
- await prefs.setBool(key, value as bool);
- case const (double):
- await prefs.setDouble(key, value as double);
- case const (int):
- await prefs.setInt(key, value as int);
- }
- }
-
- Future clearPrefs() async {
- final prefs = await SharedPreferences.getInstance();
- await prefs.clear();
- }
-
- Future removePrefByKey(String key) async {
- final prefs = await SharedPreferences.getInstance();
- return prefs.remove(key);
- }
-
- Future reload() async {
- final prefs = await SharedPreferences.getInstance();
- await prefs.reload();
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/base/base_api_client.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/base/base_api_client.dart
deleted file mode 100644
index c28c822e..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/base/base_api_client.dart
+++ /dev/null
@@ -1,18 +0,0 @@
-abstract class BaseApiClient {
- static const String kAuthHeader = 'Authorization';
- static const String kAuthPrefix = 'Bearer ';
- static const String kAcceptHeader = 'Accept';
- static const String kContentTypeHeader = 'Content-Type';
- static const String kJsonPrefix = 'application/json';
- static const String kMultipartPrefix = 'multipart/form-data';
- static const String kMediaJPEG = 'image/jpeg';
- static const String kMediaPNG = 'image/png';
-
- late T client;
-
- void attachInterceptors();
-
- void deAttachInterceptors();
-
- void attachLoggerInterceptor();
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/base/http_status.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/base/http_status.dart
deleted file mode 100644
index 058212ef..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/base/http_status.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-class HttpStatus {
- static const int kCodeSuccess200 = 200;
- static const int kCodeSuccess201 = 201;
- static const int badRequest = 400;
- static const int unauthorized = 401;
- static const int forbidden = 403;
- static const int notFound = 404;
- static const int unprocessedEntity = 422;
- static const int unsupportedMediaType = 415;
- static const int internalServerError = 500;
- static const int notImplemented = 501;
- static const int badGateway = 502;
- static const int serviceUnavailable = 503;
-
- static const int networkConnectTimeoutError = 599;
- static const int tooManyRequests = 429;
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/base/map_common_server_error.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/base/map_common_server_error.dart
deleted file mode 100644
index c8296fb4..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/base/map_common_server_error.dart
+++ /dev/null
@@ -1,45 +0,0 @@
-//@formatter:off
-import 'package:{{project_name}}/core/arch/data/remote/error/default_api_error.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/data_response.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/failure/api_failure.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/failure/canceled_request_failure.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/failure/failure.dart';
-import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
-
-class MapCommonServerError {
- static Failure getServerFailureDetails(
- DataResponse failure,
- ) {
- try {
- return failure.maybeWhen(
- undefinedError: (error, statusCode) => ApiFailure(
- ServerFailure.unknown,
- statusCode: statusCode,
- message: error.toString(),
- ),
- apiError: _getResponseError,
- notConnected: () => ApiFailure(ServerFailure.noNetwork),
- unauthorized: () => ApiFailure(ServerFailure.unAuthorized),
- tooManyRequests: () => ApiFailure(ServerFailure.tooManyRequests),
- canceledRequest: () => const CanceledRequestFailure(),
- orElse: () => ApiFailure(ServerFailure.unknown),
- );
- } catch (e, trace) {
- logger.crash(reason: 'Mapping Error Failed', error: e, stackTrace: trace);
- return ApiFailure(ServerFailure.exception, message: e.toString());
- }
- }
-
- static ApiFailure _getResponseError(customError, int? statusCode) {
- if (customError is DefaultApiError) {
- return ApiFailure(
- ServerFailure.response,
- message: customError.name,
- statusCode: statusCode,
- );
- }
- //TODO process other error types and provide results
- //TODO also add new error types to DataResponse if needed
- return ApiFailure(ServerFailure.response);
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/api_client.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/api_client.dart
deleted file mode 100644
index 346edcde..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/api_client.dart
+++ /dev/null
@@ -1,91 +0,0 @@
-import 'dart:io';
-
-import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
-import 'package:dio/dio.dart';
-import 'package:dio/io.dart';
-import 'package:dio_cache_interceptor/dio_cache_interceptor.dart';
-import 'package:flutter/foundation.dart';
-import 'package:pretty_dio_logger/pretty_dio_logger.dart';
-
-import 'package:{{project_name}}/core/arch/data/remote/base/base_api_client.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/interceptor/basic_app_auth_interceptor.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/interceptor/cache_interceptor.dart';
-
-class ApiClient implements BaseApiClient {
- static const defaultConnectTimeout = 30000;
- static const defaultReceiveTimeout = 30000;
-
- ApiClient({required BaseOptions options}) {
- client = Dio(options);
- customInterceptor = BasicAppAuthInterceptor();
- cacheInterceptor = CacheInterceptor(client);
- client.transformer = BackgroundTransformer();
- attachLoggerInterceptor();
- }
-
- late BasicAppAuthInterceptor customInterceptor;
- late CacheInterceptor cacheInterceptor;
-
- CacheOptions? get cacheOptions => cacheInterceptor.cacheOptions;
-
- @override
- late Dio client;
-
- @override
- void attachLoggerInterceptor() {
- if (kDebugMode) {
- client.interceptors.add(
- PrettyDioLogger(
- requestHeader: true,
- requestBody: true,
- responseHeader: true,
- compact: false,
- ),
- );
- }
- }
-
- @override
- void attachInterceptors() {
- client.interceptors.remove(customInterceptor);
- client.interceptors.add(customInterceptor);
- _attachCacheInterceptor();
- }
-
- @override
- void deAttachInterceptors() {
- client.interceptors.remove(customInterceptor);
- clearCache();
- }
-
- void attachCharlesProxy(String? charlesIp, String? port) {
- if (charlesIp == null || port == null) return;
-
- client.httpClientAdapter = IOHttpClientAdapter(
- createHttpClient: () {
- final client = HttpClient()
- ..findProxy = (uri) => 'PROXY $charlesIp:$port';
-
- //ignore: cascade_invocations
- client.badCertificateCallback = (cert, host, port) => true;
- return client;
- },
- );
-
- logger.d('CharlesProxyEnabled');
- }
-
- CachePolicy getCachePolicy({required bool forceRefresh}) =>
- cacheInterceptor.getCachePolicy(forceRefresh: forceRefresh);
-
- Future clearCache() async {
- logger.d('clearCache');
- await cacheInterceptor.clearCache();
- await _attachCacheInterceptor();
- }
-
- Future _attachCacheInterceptor() async {
- logger.d('attachCacheInterceptor');
- await cacheInterceptor.attachCacheInterceptor();
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_client_module.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_client_module.dart
deleted file mode 100644
index 53c52c20..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_client_module.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-import 'package:connectivity_plus/connectivity_plus.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor_impl.dart';
-import 'package:{{project_name}}/core/arch/data/remote/base/base_api_client.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/api_client.dart';
-import 'package:dio/dio.dart';
-import 'package:internet_connection_checker/internet_connection_checker.dart';
-import 'package:flutter/foundation.dart' show kIsWeb;
-
-abstract class DioClientModule {
- ApiClient makeApiClient(String baseUrl) => ApiClient(
- options: BaseOptions(
- baseUrl: baseUrl,
- connectTimeout:
- const Duration(milliseconds: ApiClient.defaultConnectTimeout),
- receiveTimeout:
- const Duration(milliseconds: ApiClient.defaultReceiveTimeout),
- headers: {
- BaseApiClient.kAcceptHeader: BaseApiClient.kJsonPrefix,
- BaseApiClient.kContentTypeHeader: BaseApiClient.kJsonPrefix,
- },
- ),
- );
-
- DioRequestProcessor makeDioErrorHandler() => kIsWeb
- ? DioRequestProcessorImpl()
- : DioRequestProcessorImpl(
- connectivity: Connectivity(),
- internetConnectionChecker: InternetConnectionChecker(),
- );
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor.dart
deleted file mode 100644
index 60e4eab6..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor.dart
+++ /dev/null
@@ -1,24 +0,0 @@
-import 'dart:async';
-import 'package:{{project_name}}/core/arch/data/remote/error/dio_error_processor.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/data_response.dart';
-import 'package:dio/dio.dart';
-
-///Custom function to provide request Future
-typedef OnRequest = Future Function();
-
-///Custom Function to provide response converter (Map to Object)
-typedef OnResponse = T Function(Response response);
-
-abstract class DioRequestProcessor {
- ///Pass 2 required functions:
- ///onRequest - your request Future
- ///onResponse - your response converter, basically call fromJson inside
- ///checkNetworkConnection - set to false if you need get data from
- ///cache interceptor
- Future> processRequest({
- required OnRequest onRequest,
- required OnResponse onResponse,
- bool checkNetworkConnection = true,
- OnCustomError? onCustomError,
- });
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor_impl.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor_impl.dart
deleted file mode 100644
index f3c8a666..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor_impl.dart
+++ /dev/null
@@ -1,112 +0,0 @@
-import 'dart:async';
-import 'dart:io';
-
-import 'package:{{project_name}}/core/arch/data/remote/base/http_status.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/data_response.dart';
-import 'package:{{project_name}}/core/arch/data/remote/error/dio_error_processor.dart';
-import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
-import 'package:connectivity_plus/connectivity_plus.dart';
-import 'package:dio/dio.dart';
-import 'package:flutter/material.dart';
-import 'package:internet_connection_checker/internet_connection_checker.dart';
-import 'package:retry/retry.dart';
-
-class DioRequestProcessorImpl implements DioRequestProcessor {
- /// Number of attempts to re-execute the request
- static const defaultMaxAttemptsCount = 2;
-
- /// Error codes that require re-execution of the request (without bad request)
- /// Basic list of error codes that require re-execution of the request
- static const defaultRetryStatusCodes = [
- HttpStatus.badGateway,
- HttpStatus.serviceUnavailable,
- ];
-
- @protected
- final Connectivity? connectivity;
- @protected
- final InternetConnectionChecker? internetConnectionChecker;
- final int maxAttemptsCount;
- @protected
- final bool useRetry;
- @protected
- final List retryStatusCodes;
- final _errorProcessor = const DioErrorProcessor();
-
- DioRequestProcessorImpl({
- this.connectivity,
- this.internetConnectionChecker,
- this.useRetry = false,
- this.maxAttemptsCount = defaultMaxAttemptsCount,
- this.retryStatusCodes = defaultRetryStatusCodes,
- });
-
- @override
- Future> processRequest({
- required OnRequest onRequest,
- required OnResponse onResponse,
- bool checkNetworkConnection = true,
- OnCustomError? onCustomError,
- }) async {
- if (connectivity != null && internetConnectionChecker != null) {
- final resultConnectivity =
- await connectivity?.checkConnectivity() ?? false;
- final hasConnection =
- await internetConnectionChecker?.hasConnection ?? false;
-
- if (checkNetworkConnection &&
- (resultConnectivity == ConnectivityResult.none || !hasConnection)) {
- return DataResponse.notConnected();
- }
- }
-
- try {
- final response = await _call(onRequest);
- return DataResponse.success(onResponse(response as Response));
- } on DioException catch (e, trace) {
- if(e.type == DioExceptionType.cancel) {
- return const DataResponse.canceledRequest();
- }
- logger.crash(reason: 'onDioError', error: e, stackTrace: trace);
- return _errorProcessor.processError(
- e,
- onCustomError: onCustomError,
- );
- } catch (e, trace) {
- logger.crash(reason: 'onDioCommonError', error: e, stackTrace: trace);
- return DataResponse.undefinedError(e);
- }
- }
-
- Future _call(OnRequest request) async {
- if (useRetry) {
- return retry(
- request,
- maxAttempts: maxAttemptsCount,
- retryIf: (exception) => _retryPolicy(
- exception: exception,
- retryStatusCodes: retryStatusCodes,
- ),
- );
- } else {
- return request();
- }
- }
-
- FutureOr _retryPolicy({
- required Exception exception,
- required List retryStatusCodes,
- }) {
- if (exception is! DioException) return false;
- if (exception.type == DioExceptionType.cancel) return false;
- final response = exception.response;
- if (response == null) {
- return true;
- }
- if (exception is SocketException || exception is TimeoutException) {
- return true;
- }
- return retryStatusCodes.contains(response.statusCode);
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/interceptor/authorization_interceptor.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/interceptor/authorization_interceptor.dart
deleted file mode 100644
index dea93d75..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/interceptor/authorization_interceptor.dart
+++ /dev/null
@@ -1,130 +0,0 @@
-import 'package:{{project_name}}/core/arch/data/remote/base/base_api_client.dart';
-import 'package:{{project_name}}/core/arch/data/remote/base/http_status.dart';
-import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
-import 'package:{{project_name}}/core/di/repository.dart';
-import 'package:{{project_name}}/core/di/services.dart';
-import 'package:{{project_name}}/data/mapper/authentication/authentication_mapper.dart';
-import 'package:{{project_name}}/data/model/remote/authentication/authentication_response.dart';
-import 'package:{{project_name}}/data/model/remote/token/token_request.dart';
-import 'package:{{project_name}}/domain/entity/authentication/authentication.dart';
-import 'package:dio/dio.dart';
-
-class AuthorizationInterceptor extends QueuedInterceptorsWrapper {
- late Dio _refreshDio;
-
- //TODO change refresh path
- final _refreshPath = 'auth/refresh';
-
- AuthorizationInterceptor() {
- _refreshDio = Dio();
- }
-
- @override
- Future onRequest(
- RequestOptions options,
- RequestInterceptorHandler handler,
- ) async {
- final token = tokenRepository.accessToken;
- if (token != null && token.isNotEmpty) {
- options.headers.addAll(
- {
- BaseApiClient.kAuthHeader: '${BaseApiClient.kAuthPrefix}$token',
- },
- );
- }
- logger.d('token: $token');
- handler.next(options);
- }
-
- @override
- Future onError(
- DioException err,
- ErrorInterceptorHandler handler,
- ) async {
- if (err.response?.statusCode == HttpStatus.unauthorized) {
- final refreshToken = tokenRepository.refreshToken;
- final accessToken = tokenRepository.accessToken;
- try {
- if (refreshToken == null ||
- refreshToken.isEmpty ||
- accessToken == null ||
- accessToken.isEmpty) {
- await sessionService().closeSession();
- return handler.next(err);
- }
- final request = TokenRequest(
- accessToken: accessToken,
- refreshToken: refreshToken,
- );
- final authEntity = await _refresh(err, request);
- return await _resolveRequest(err, handler, authEntity);
- } on DioException {
- if (err.response?.statusCode == HttpStatus.unauthorized) {
- await sessionService().closeSession();
- }
- } catch (e, stackTrace) {
- logger.crash(error: e, stackTrace: stackTrace);
- await sessionService().closeSession();
- }
- }
- handler.next(err);
- }
-
- Future _refresh(
- DioException err,
- TokenRequest request,
- ) async {
- logger.d('_refresh start');
- final result = await _refreshDio.post(
- '${err.requestOptions.baseUrl}$_refreshPath',
- options: Options(
- headers: {
- BaseApiClient.kAcceptHeader: BaseApiClient.kJsonPrefix,
- BaseApiClient.kContentTypeHeader: BaseApiClient.kJsonPrefix,
- BaseApiClient.kAuthHeader:
- '${BaseApiClient.kAuthPrefix}${request.accessToken}',
- },
- ),
- data: request.toJson(),
- );
- final data = AuthenticationResponse.fromJson(
- result.data['data'],
- );
- logger.d('_refresh end');
- return AuthenticationMappers().mapRefreshEntity(data);
- }
-
- Future _resolveRequest(
- DioException err,
- ErrorInterceptorHandler handler,
- Authentication authEntity,
- ) async {
- await tokenRepository.update(
- Authentication(
- accessToken: authEntity.accessToken,
- refreshToken: authEntity.refreshToken,
- ),
- );
- final requestOptions = err.response?.requestOptions;
- if (requestOptions != null) {
- requestOptions.headers[BaseApiClient.kAuthHeader] =
- '${BaseApiClient.kAuthPrefix}${authEntity.accessToken}';
- final options = Options(
- method: requestOptions.method,
- headers: requestOptions.headers,
- );
- final dioRefresh = Dio(
- BaseOptions(baseUrl: requestOptions.baseUrl),
- );
- final response = await dioRefresh.request(
- requestOptions.path,
- data: requestOptions.data,
- queryParameters: requestOptions.queryParameters,
- options: options,
- );
- return handler.resolve(response);
- }
- logger.e('err: $err');
- return handler.next(err);
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/interceptor/basic_app_auth_interceptor.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/interceptor/basic_app_auth_interceptor.dart
deleted file mode 100644
index d5394fe5..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/interceptor/basic_app_auth_interceptor.dart
+++ /dev/null
@@ -1,27 +0,0 @@
-import 'dart:io';
-
-import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
-import 'package:dio/dio.dart';
-
-class BasicAppAuthInterceptor extends InterceptorsWrapper {
- @override
- void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
- logger.d('AppInterceptor onRequest');
- //TODO add accessToken
- // var accessToken = 'some token';
- // options.headers[kAuthHeader] = '$kAuthPrefix$accessToken';
- // options.headers[kAcceptHeader] = kJsonPrefix;
- // options.headers[kContentTypeHeader] = kJsonPrefix;
- super.onRequest(options, handler);
- }
-
- @override
- void onError(DioException err, ErrorInterceptorHandler handler) {
- logger.d('AppInterceptor start: $err');
- if (err.response?.statusCode == HttpStatus.unauthorized) {
- //TODO disposeSessionLocal
- return;
- }
- super.onError(err, handler);
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/interceptor/cache_interceptor.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/interceptor/cache_interceptor.dart
deleted file mode 100644
index ef463177..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/interceptor/cache_interceptor.dart
+++ /dev/null
@@ -1,81 +0,0 @@
-import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
-import 'package:{{project_name}}/core/di/local.dart';
-import 'package:{{project_name}}/data/source/local/secure_storage/secure_storage_keys.dart';
-import 'package:dio/io.dart';
-import 'dart:io';
-import 'package:dio/dio.dart';
-import 'package:dio_cache_interceptor/dio_cache_interceptor.dart';
-import 'package:dio_cache_interceptor_hive_store/dio_cache_interceptor_hive_store.dart';
-import 'package:{{project_name}}/app/service/hive_cipher_key_service.dart';
-import 'package:path_provider/path_provider.dart' as pp;
-import 'package:hive_flutter/hive_flutter.dart';
-
-class CacheInterceptor {
- final Dio client;
-
- CacheOptions? cacheOptions;
- HiveCacheStore? _cacheStore;
- DioCacheInterceptor? _interceptor;
-
- CacheInterceptor(this.client);
-
- Future attachCacheInterceptor() async {
- try {
- final options = await createOptions();
- final interceptor = DioCacheInterceptor(options: options);
- _interceptor = interceptor;
-
- client.interceptors.add(interceptor);
- cacheOptions = options;
-
- client.httpClientAdapter = IOHttpClientAdapter(
- createHttpClient: () {
- final client = HttpClient();
- //ignore: cascade_invocations
- client.badCertificateCallback = (cert, host, port) => true;
- return client;
- },
- );
-
- logger.d('DioCacheInterceptor ADDED');
- } catch (e, trace) {
- logger.crash(
- reason: 'DioCacheInterceptor Error',
- error: e,
- stackTrace: trace,
- );
- }
- }
-
- Future createOptions() async {
- final dir = await pp.getApplicationDocumentsDirectory();
- final keyService = HiveCipherKeyService(secureStorageSource());
- final key = await keyService.init();
-
- _cacheStore =
- HiveCacheStore(dir.path, encryptionCipher: HiveAesCipher(key));
-
- return CacheOptions(
- store: _cacheStore,
- policy: CachePolicy.noCache,
- hitCacheOnErrorExcept: [],
- maxStale: const Duration(days: 1),
- allowPostMethod: true,
- );
- }
-
- CachePolicy getCachePolicy({required bool forceRefresh}) {
- return forceRefresh
- ? CachePolicy.refreshForceCache
- : CachePolicy.forceCache;
- }
-
- Future clearCache() async {
- await secureStorageSource().delete(SecureStorageKeys.kSecretKeyCipher);
- await _cacheStore?.clean();
- }
-
- void deAttachInterceptor() {
- client.interceptors.remove(_interceptor);
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/graph_ql/graph_ql_const.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/graph_ql/graph_ql_const.dart
deleted file mode 100644
index 381eee54..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/graph_ql/graph_ql_const.dart
+++ /dev/null
@@ -1,3 +0,0 @@
-class GraphQlConst {
- static const String graphQLBaseUrl = 'https://jsonplaceholder.typicode.com';
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_const.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/dio/dio_const.dart
similarity index 90%
rename from bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_const.dart
rename to bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/dio/dio_const.dart
index 6b7475d1..b5bda011 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_const.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/dio/dio_const.dart
@@ -4,5 +4,6 @@ class DioConst {
static const String defaultApiClientName = 'DefaultApiClient';
+ const DioConst._();
//{dio const end}
}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/default_api_error.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/default_api_error.dart
index 331b983b..794df1e0 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/default_api_error.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/default_api_error.dart
@@ -1,7 +1,6 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'default_api_error.freezed.dart';
-
part 'default_api_error.g.dart';
//TODO Modify this class to make it like Your Api error
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/default_api_error.freezed.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/default_api_error.freezed.dart
new file mode 100644
index 00000000..6792e96a
--- /dev/null
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/default_api_error.freezed.dart
@@ -0,0 +1,183 @@
+// coverage:ignore-file
+// GENERATED CODE - DO NOT MODIFY BY HAND
+// ignore_for_file: type=lint
+// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
+
+part of 'default_api_error.dart';
+
+// **************************************************************************
+// FreezedGenerator
+// **************************************************************************
+
+T _$identity(T value) => value;
+
+final _privateConstructorUsedError = UnsupportedError(
+ 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
+
+DefaultApiError _$DefaultApiErrorFromJson(Map json) {
+ return _DefaultApiError.fromJson(json);
+}
+
+/// @nodoc
+mixin _$DefaultApiError {
+ String get name => throw _privateConstructorUsedError;
+ String get code => throw _privateConstructorUsedError;
+
+ /// Serializes this DefaultApiError to a JSON map.
+ Map toJson() => throw _privateConstructorUsedError;
+
+ /// Create a copy of DefaultApiError
+ /// with the given fields replaced by the non-null parameter values.
+ @JsonKey(includeFromJson: false, includeToJson: false)
+ $DefaultApiErrorCopyWith get copyWith =>
+ throw _privateConstructorUsedError;
+}
+
+/// @nodoc
+abstract class $DefaultApiErrorCopyWith<$Res> {
+ factory $DefaultApiErrorCopyWith(
+ DefaultApiError value, $Res Function(DefaultApiError) then) =
+ _$DefaultApiErrorCopyWithImpl<$Res, DefaultApiError>;
+ @useResult
+ $Res call({String name, String code});
+}
+
+/// @nodoc
+class _$DefaultApiErrorCopyWithImpl<$Res, $Val extends DefaultApiError>
+ implements $DefaultApiErrorCopyWith<$Res> {
+ _$DefaultApiErrorCopyWithImpl(this._value, this._then);
+
+ // ignore: unused_field
+ final $Val _value;
+ // ignore: unused_field
+ final $Res Function($Val) _then;
+
+ /// Create a copy of DefaultApiError
+ /// with the given fields replaced by the non-null parameter values.
+ @pragma('vm:prefer-inline')
+ @override
+ $Res call({
+ Object? name = null,
+ Object? code = null,
+ }) {
+ return _then(_value.copyWith(
+ name: null == name
+ ? _value.name
+ : name // ignore: cast_nullable_to_non_nullable
+ as String,
+ code: null == code
+ ? _value.code
+ : code // ignore: cast_nullable_to_non_nullable
+ as String,
+ ) as $Val);
+ }
+}
+
+/// @nodoc
+abstract class _$$DefaultApiErrorImplCopyWith<$Res>
+ implements $DefaultApiErrorCopyWith<$Res> {
+ factory _$$DefaultApiErrorImplCopyWith(_$DefaultApiErrorImpl value,
+ $Res Function(_$DefaultApiErrorImpl) then) =
+ __$$DefaultApiErrorImplCopyWithImpl<$Res>;
+ @override
+ @useResult
+ $Res call({String name, String code});
+}
+
+/// @nodoc
+class __$$DefaultApiErrorImplCopyWithImpl<$Res>
+ extends _$DefaultApiErrorCopyWithImpl<$Res, _$DefaultApiErrorImpl>
+ implements _$$DefaultApiErrorImplCopyWith<$Res> {
+ __$$DefaultApiErrorImplCopyWithImpl(
+ _$DefaultApiErrorImpl _value, $Res Function(_$DefaultApiErrorImpl) _then)
+ : super(_value, _then);
+
+ /// Create a copy of DefaultApiError
+ /// with the given fields replaced by the non-null parameter values.
+ @pragma('vm:prefer-inline')
+ @override
+ $Res call({
+ Object? name = null,
+ Object? code = null,
+ }) {
+ return _then(_$DefaultApiErrorImpl(
+ name: null == name
+ ? _value.name
+ : name // ignore: cast_nullable_to_non_nullable
+ as String,
+ code: null == code
+ ? _value.code
+ : code // ignore: cast_nullable_to_non_nullable
+ as String,
+ ));
+ }
+}
+
+/// @nodoc
+@JsonSerializable()
+class _$DefaultApiErrorImpl implements _DefaultApiError {
+ const _$DefaultApiErrorImpl({required this.name, required this.code});
+
+ factory _$DefaultApiErrorImpl.fromJson(Map json) =>
+ _$$DefaultApiErrorImplFromJson(json);
+
+ @override
+ final String name;
+ @override
+ final String code;
+
+ @override
+ String toString() {
+ return 'DefaultApiError(name: $name, code: $code)';
+ }
+
+ @override
+ bool operator ==(Object other) {
+ return identical(this, other) ||
+ (other.runtimeType == runtimeType &&
+ other is _$DefaultApiErrorImpl &&
+ (identical(other.name, name) || other.name == name) &&
+ (identical(other.code, code) || other.code == code));
+ }
+
+ @JsonKey(includeFromJson: false, includeToJson: false)
+ @override
+ int get hashCode => Object.hash(runtimeType, name, code);
+
+ /// Create a copy of DefaultApiError
+ /// with the given fields replaced by the non-null parameter values.
+ @JsonKey(includeFromJson: false, includeToJson: false)
+ @override
+ @pragma('vm:prefer-inline')
+ _$$DefaultApiErrorImplCopyWith<_$DefaultApiErrorImpl> get copyWith =>
+ __$$DefaultApiErrorImplCopyWithImpl<_$DefaultApiErrorImpl>(
+ this, _$identity);
+
+ @override
+ Map toJson() {
+ return _$$DefaultApiErrorImplToJson(
+ this,
+ );
+ }
+}
+
+abstract class _DefaultApiError implements DefaultApiError {
+ const factory _DefaultApiError(
+ {required final String name,
+ required final String code}) = _$DefaultApiErrorImpl;
+
+ factory _DefaultApiError.fromJson(Map json) =
+ _$DefaultApiErrorImpl.fromJson;
+
+ @override
+ String get name;
+ @override
+ String get code;
+
+ /// Create a copy of DefaultApiError
+ /// with the given fields replaced by the non-null parameter values.
+ @override
+ @JsonKey(includeFromJson: false, includeToJson: false)
+ _$$DefaultApiErrorImplCopyWith<_$DefaultApiErrorImpl> get copyWith =>
+ throw _privateConstructorUsedError;
+}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/default_api_error.g.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/default_api_error.g.dart
new file mode 100644
index 00000000..509c781e
--- /dev/null
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/default_api_error.g.dart
@@ -0,0 +1,21 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'default_api_error.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+_$DefaultApiErrorImpl _$$DefaultApiErrorImplFromJson(
+ Map json) =>
+ _$DefaultApiErrorImpl(
+ name: json['name'] as String,
+ code: json['code'] as String,
+ );
+
+Map _$$DefaultApiErrorImplToJson(
+ _$DefaultApiErrorImpl instance) =>
+ {
+ 'name': instance.name,
+ 'code': instance.code,
+ };
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/dio_error_processor.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/dio_error_processor.dart
deleted file mode 100644
index 618e7156..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/dio_error_processor.dart
+++ /dev/null
@@ -1,62 +0,0 @@
-import 'package:{{project_name}}/core/arch/data/remote/base/http_status.dart';
-import 'package:{{project_name}}/core/arch/data/remote/error/default_api_error.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/data_response.dart';
-import 'package:dio/dio.dart';
-
-typedef OnCustomError = dynamic Function(
- int code,
- Map response,
- );
-
-class DioErrorProcessor {
- const DioErrorProcessor();
-
- DataResponse processError(
- DioException e, {
- OnCustomError? onCustomError,
- }) {
- final responseData = e.response?.data;
- final statusCode = e.response?.statusCode ?? -1;
- if (e.type == DioExceptionType.connectionTimeout ||
- e.type == DioExceptionType.sendTimeout ||
- statusCode == HttpStatus.networkConnectTimeoutError) {
- return DataResponse.notConnected();
- }
- if (statusCode == HttpStatus.unauthorized) {
- return DataResponse.unauthorized();
- }
- if (statusCode == HttpStatus.tooManyRequests) {
- return DataResponse.tooManyRequests();
- }
-
- final errorHandler = onCustomError;
-
- if (errorHandler != null) {
- final apiError = errorHandler(statusCode, responseData);
- if (apiError != null) {
- return DataResponse.apiError(apiError, statusCode);
- }
- }
- return _default(e);
- }
-
- DataResponse _default(DioException e) {
- try {
- final response = e.response?.data;
- final statusCode = e.response?.statusCode ?? -1;
- if (response != null) {
- // TODO: process default error there
- // TODO: customize DefaultApiError to your purposes
- // TODO: also add new error types to DataResponse if needed
-
- final error = DefaultApiError.fromJson(response);
- return DataResponse.apiError(error, statusCode);
- }
- return DataResponse.undefinedError(e, statusCode);
- } catch (_) {
- // This is in case the response is not received
- // in the form of ResponseType.json
- return DataResponse.undefinedError(e);
- }
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/graph_ql/graph_ql_client.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/graph_ql/graph_ql_client.dart
similarity index 73%
rename from bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/graph_ql/graph_ql_client.dart
rename to bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/graph_ql/graph_ql_client.dart
index 19e98202..8ccf0b05 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/graph_ql/graph_ql_client.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/graph_ql/graph_ql_client.dart
@@ -1,6 +1,6 @@
-import 'package:{{project_name}}/core/arch/data/remote/base/base_api_client.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/graph_ql/graph_ql_const.dart';
import 'package:graphql/client.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
+import 'package:{{project_name}}/core/arch/data/remote/graph_ql/graph_ql_const.dart';
class GraphQlClient implements BaseApiClient {
@override
@@ -32,4 +32,7 @@ class GraphQlClient implements BaseApiClient {
@override
void deAttachInterceptors() {}
+
+ @override
+ void attachCacheInterceptor(CacheInterceptor cacheInterceptor) {}
}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/graph_ql/graph_ql_const.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/graph_ql/graph_ql_const.dart
new file mode 100644
index 00000000..a2df4519
--- /dev/null
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/graph_ql/graph_ql_const.dart
@@ -0,0 +1,6 @@
+class GraphQlConst {
+ //TODO: Specify Api client Base URL
+ static const String graphQLBaseUrl = 'https://host.todo';
+
+ const GraphQlConst._();
+}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/graph_ql/request_processor/graph_ql_request_processor.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/graph_ql/request_processor/graph_ql_request_processor.dart
similarity index 83%
rename from bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/graph_ql/request_processor/graph_ql_request_processor.dart
rename to bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/graph_ql/request_processor/graph_ql_request_processor.dart
index 394043c3..6fed3035 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/graph_ql/request_processor/graph_ql_request_processor.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/graph_ql/request_processor/graph_ql_request_processor.dart
@@ -1,7 +1,7 @@
import 'dart:async';
-import 'package:{{project_name}}/core/arch/data/remote/clients/graph_ql/graph_ql_client.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/data_response.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
+import 'package:{{project_name}}/core/arch/data/remote/graph_ql/graph_ql_client.dart';
///Custom function to provide request Future
typedef OnRequest = Future Function();
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/graph_ql/request_processor/graph_ql_request_processor_impl.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/graph_ql/request_processor/graph_ql_request_processor_impl.dart
similarity index 87%
rename from bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/graph_ql/request_processor/graph_ql_request_processor_impl.dart
rename to bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/graph_ql/request_processor/graph_ql_request_processor_impl.dart
index 30647012..e7e77780 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/graph_ql/request_processor/graph_ql_request_processor_impl.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/graph_ql/request_processor/graph_ql_request_processor_impl.dart
@@ -1,8 +1,9 @@
-import 'package:{{project_name}}/core/arch/data/remote/clients/graph_ql/graph_ql_client.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/graph_ql/request_processor/graph_ql_request_processor.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/data_response.dart';
-import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
import 'package:graphql/client.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart'
+ hide OnRequest, OnResponse;
+import 'package:{{project_name}}/core/arch/data/remote/graph_ql/graph_ql_client.dart';
+import 'package:{{project_name}}/core/arch/data/remote/graph_ql/request_processor/graph_ql_request_processor.dart';
+import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
class GraphQlRequestProcessorImpl implements GraphQlRequestProcessor {
@override
@@ -32,7 +33,7 @@ class GraphQlRequestProcessorImpl implements GraphQlRequestProcessor {
final customerErrors = onSuccess(response);
if (customerErrors?.isNotEmpty ?? false) {
final error = customerErrors?.join('\n');
- return DataResponse.apiError(error);
+ return DataResponse.apiError(error ?? '');
}
}
@@ -67,7 +68,7 @@ class GraphQlRequestProcessorImpl implements GraphQlRequestProcessor {
final customerErrors = onSuccess(response);
if (customerErrors?.isNotEmpty ?? false) {
final error = customerErrors?.join('\n');
- return DataResponse.apiError(error);
+ return DataResponse.apiError(error ?? '');
}
}
return DataResponse.success(response);
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/common/converter/mapper.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/common/converter/mapper.dart
deleted file mode 100644
index a8a0cf41..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/common/converter/mapper.dart
+++ /dev/null
@@ -1,10 +0,0 @@
-abstract class Mapper {
- E map(T from);
-}
-
-//ignore: one_member_abstracts
-abstract class MapperList extends Mapper {
- List mapList(List from) {
- return from.map(map).toList();
- }
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/base_empty_response.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/base_empty_response.dart
deleted file mode 100644
index c46d7c38..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/base_empty_response.dart
+++ /dev/null
@@ -1,5 +0,0 @@
-class BaseEmptyResponse {
- BaseEmptyResponse();
- factory BaseEmptyResponse.fromJson(Map _) =>
- BaseEmptyResponse();
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/data_response.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/data_response.dart
deleted file mode 100644
index 9cb18d28..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/data_response.dart
+++ /dev/null
@@ -1,33 +0,0 @@
-import 'package:freezed_annotation/freezed_annotation.dart';
-
-part 'data_response.freezed.dart';
-
-@freezed
-sealed class DataResponse with _$DataResponse {
- T get data => (this as _DataResponseSuccess).data;
-
- const DataResponse._();
-
- const factory DataResponse.success(T data) = _DataResponseSuccess;
-
- const factory DataResponse.undefinedError(Object? errorObject, [
- int? statusCode,
- ]) = _UndefinedError;
-
- const factory DataResponse.apiError(error, [int? statusCode]) = _ApiError;
-
- const factory DataResponse.notConnected() = _NoInternetConnection;
-
- const factory DataResponse.unauthorized() = _Unauthorized;
-
- const factory DataResponse.tooManyRequests() = _TooManyRequests;
-
- const factory DataResponse.canceledRequest() = _CanceledRequest;
-
- {{#firebase_auth}}const factory DataResponse.firebaseError(
- String code) = _FirebaseError;{{/firebase_auth}}
-
- bool isSuccess() => this is _DataResponseSuccess;
-
- bool isError() => this is! _DataResponseSuccess;
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/operation_status.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/operation_status.dart
deleted file mode 100644
index 028b7994..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/operation_status.dart
+++ /dev/null
@@ -1,4 +0,0 @@
-enum OperationStatus {
- success,
- failed,
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/result.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/result.dart
deleted file mode 100644
index bfff7df2..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/result.dart
+++ /dev/null
@@ -1,25 +0,0 @@
-import 'package:{{project_name}}/core/arch/domain/entity/failure/failure.dart';
-import 'package:freezed_annotation/freezed_annotation.dart';
-
-part 'result.freezed.dart';
-
-@freezed
-class Result with _$Result {
- bool get success => this is _ResultSuccess;
-
- bool get isError => this is ResultError;
-
- ///WARNING. ALWAYS CHECK success == true before call
- T get data => (this as _ResultSuccess).data;
-
- ///WARNING. ALWAYS CHECK isError == true before call
- ResultError get error => this as ResultError;
-
- const Result._();
-
- const factory Result.success(T data) = _ResultSuccess;
-
- const factory Result.error({
- required Failure failure,
- }) = ResultError;
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/failure/api_failure.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/failure/api_failure.dart
deleted file mode 100644
index 39c84cef..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/failure/api_failure.dart
+++ /dev/null
@@ -1,28 +0,0 @@
-import 'package:{{project_name}}/core/arch/domain/entity/failure/failure.dart';
-
-class ApiFailure implements FeatureFailure {
- final ServerFailure failure;
- final int? statusCode;
-
- final String message;
-
- ApiFailure(
- this.failure, {
- this.message = '',
- this.statusCode,
- });
-
- @override
- String toString() {
- return 'ApiFailure{$failure, message: $message, statusCode: $statusCode}';
- }
-}
-
-enum ServerFailure {
- noNetwork,
- exception,
- unAuthorized,
- tooManyRequests,
- response,
- unknown,
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/failure/canceled_request_failure.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/failure/canceled_request_failure.dart
deleted file mode 100644
index 172471ba..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/failure/canceled_request_failure.dart
+++ /dev/null
@@ -1,5 +0,0 @@
-import 'package:{{project_name}}/core/arch/domain/entity/failure/failure.dart';
-
-class CanceledRequestFailure implements FeatureFailure {
- const CanceledRequestFailure();
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/failure/failure.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/failure/failure.dart
deleted file mode 100644
index 254d9519..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/failure/failure.dart
+++ /dev/null
@@ -1,15 +0,0 @@
-abstract class Failure {}
-
-class CommonFailure implements Failure {
- CommonFailure(this.e);
-
- Exception e;
-}
-
-class DataSourceFailure implements Failure {
- DataSourceFailure(this.e);
-
- Exception e;
-}
-
-abstract class FeatureFailure implements Failure {}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/progress_state/progress_state.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/progress_state/progress_state.dart
deleted file mode 100644
index e1d8cb23..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/progress_state/progress_state.dart
+++ /dev/null
@@ -1,10 +0,0 @@
-///To add custom progress data in BLoC extends from this class
-abstract class BaseProgressState {
- const BaseProgressState();
-}
-
-class DefaultProgressState extends BaseProgressState {
- final bool showProgress;
-
- const DefaultProgressState({required this.showProgress});
-}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/widget/common/theme_switcher.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/widget/common/theme_switcher.dart
new file mode 100644
index 00000000..ca1cf37d
--- /dev/null
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/widget/common/theme_switcher.dart
@@ -0,0 +1,56 @@
+import 'package:flutter/material.dart';
+
+class ThemeModeSwitcher extends StatefulWidget {
+ final Widget Function(BuildContext, ThemeMode, Widget?) builder;
+ final ThemeMode initialThemeMode;
+
+ const ThemeModeSwitcher({
+ required this.builder,
+ this.initialThemeMode = ThemeMode.system,
+ super.key,
+ });
+
+ @override
+ State createState() => _ThemeModeSwitcherState();
+}
+
+class _ThemeModeSwitcherState extends State {
+ late final _themeNotifier = ValueNotifier(widget.initialThemeMode);
+
+ @override
+ Widget build(BuildContext context) {
+ return ThemeModeNotifier(
+ notifier: _themeNotifier,
+ child: ValueListenableBuilder(
+ valueListenable: _themeNotifier,
+ builder: widget.builder,
+ ),
+ );
+ }
+}
+
+class ThemeModeNotifier extends InheritedWidget {
+ final ValueNotifier notifier;
+
+ const ThemeModeNotifier({
+ required this.notifier,
+ required super.child,
+ super.key,
+ });
+
+ void changeTheme(ThemeMode themeMode) {
+ notifier.value = themeMode;
+ }
+
+ static ThemeModeNotifier of(BuildContext context) {
+ return context.dependOnInheritedWidgetOfExactType()!;
+ }
+
+ @override
+ bool updateShouldNotify(covariant ThemeModeNotifier oldWidget) {
+ if (notifier.value != oldWidget.notifier.value) {
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/bloc.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/bloc.dart
index 2b08d7ee..8510f397 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/bloc.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/bloc.dart
@@ -1,9 +1,7 @@
//@formatter:off
import 'package:get_it/get_it.dart';
-import 'package:{{project_name}}/app/bloc/app_bloc_imports.dart';
//{imports end}
void registerBloc(GetIt getIt) {
- getIt.registerFactory(AppBloc.new);
//{bloc end}
}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/injection.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/injection.dart
index 7ab4feec..c102b446 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/injection.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/injection.dart
@@ -1,7 +1,8 @@
import 'package:get_it/get_it.dart';
import 'package:{{project_name}}/core/di/app.dart';
-import 'package:{{project_name}}/core/di/bloc.dart';
+{{#isBloc}}import 'package:{{project_name}}/core/di/bloc.dart';{{/isBloc}}
import 'package:{{project_name}}/core/di/local.dart';
+{{#isProvider}}import 'package:{{project_name}}/core/di/provider.dart';{{/isProvider}}
import 'package:{{project_name}}/core/di/remote.dart';
import 'package:{{project_name}}/core/di/repository.dart';
import 'package:{{project_name}}/core/di/services.dart';
@@ -17,5 +18,6 @@ void initializeDi(GetIt getIt) {
registerApp(getIt);
registerAppServices(getIt);
registerUseCases(getIt);
- registerBloc(getIt);
+ {{#isBloc}}registerBloc(getIt);{{/isBloc}}
+ {{#isProvider}}registerProvider(getIt);{{/isProvider}}
}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/local.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/local.dart
index bb004b30..15c4da32 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/local.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/local.dart
@@ -1,9 +1,9 @@
import 'package:get_it/get_it.dart';
-import 'package:{{project_name}}/core/arch/data/local/prefs/base_preferences.dart';
import 'package:{{project_name}}/data/source/local/preferences_source/preferences_source.dart';
import 'package:{{project_name}}/data/source/local/preferences_source/preferences_source_impl.dart';
import 'package:{{project_name}}/data/source/local/secure_storage/secure_storage_source.dart';
import 'package:{{project_name}}/data/source/local/secure_storage/secure_storage_source_impl.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
void registerLocal(GetIt getIt) {
getIt
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/provider.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/provider.dart
new file mode 100644
index 00000000..8bcd9a2e
--- /dev/null
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/provider.dart
@@ -0,0 +1,7 @@
+//@formatter:off
+import 'package:get_it/get_it.dart';
+//{imports end}
+
+void registerProvider(GetIt getIt) {
+ //{provider end}
+}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/remote.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/remote.dart
index 83615beb..56499e9f 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/remote.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/remote.dart
@@ -1,26 +1,23 @@
//@formatter:off
import 'package:get_it/get_it.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/api_client.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_client_module.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_const.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor.dart';
-{{#graphql}}import 'package:{{project_name}}/core/arch/data/remote/clients/graph_ql/graph_ql_client.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/graph_ql/request_processor/graph_ql_request_processor.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/graph_ql/request_processor/graph_ql_request_processor_impl.dart';{{/graphql}}
+import 'package:{{project_name}}/core/arch/data/remote/dio/dio_const.dart';
+{{#graphql}}import 'package:{{project_name}}/core/arch/data/remote/graph_ql/graph_ql_client.dart';
+import 'package:{{project_name}}/core/arch/data/remote/graph_ql/request_processor/graph_ql_request_processor.dart';
+import 'package:{{project_name}}/core/arch/data/remote/graph_ql/request_processor/graph_ql_request_processor_impl.dart';{{/graphql}}
{{#firebase_auth}}import 'package:firebase_auth/firebase_auth.dart';{{/firebase_auth}}
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/api_client.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_client_module.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_const.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
void registerRemote(GetIt getIt) {
final dioClientModule = _DioClientModule();
getIt
..registerLazySingleton(
- dioClientModule.makeDioErrorHandler,
- )
- ..registerLazySingleton(
- () => dioClientModule.makeApiClient(DioConst.defaultBaseUrl),
+ dioClientModule.makeDioRequestProcessor,
+ )..registerLazySingleton(
+ () => dioClientModule.makeApiClient(
+ ApiClientParams(
+ baseUrl: DioConst.defaultBaseUrl,
+ ),
+ ),
instanceName: DioConst.defaultApiClientName,
);
{{#firebase_auth}}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/riverpod.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/riverpod.dart
new file mode 100644
index 00000000..e9f0c2d5
--- /dev/null
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/riverpod.dart
@@ -0,0 +1,8 @@
+//@formatter:off
+import 'package:flutter_riverpod/flutter_riverpod.dart';
+import 'package:get_it/get_it.dart';
+//{imports end}
+
+void registerRiverpod(GetIt getIt) {
+ //{riverpod end}
+}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/source.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/source.dart
index 30854c3f..74bcdf2a 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/source.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/di/source.dart
@@ -1,16 +1,14 @@
//@formatter:off
import 'package:get_it/get_it.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/api_client.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_const.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor.dart';
-{{#graphql}}import 'package:{{project_name}}/core/arch/data/remote/clients/graph_ql/graph_ql_client.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/graph_ql/request_processor/graph_ql_request_processor.dart';
+import 'package:{{project_name}}/core/arch/data/remote/dio/dio_const.dart';
+{{#graphql}}import 'package:{{project_name}}/core/arch/data/remote/graph_ql/graph_ql_client.dart';
+import 'package:{{project_name}}/core/arch/data/remote/graph_ql/request_processor/graph_ql_request_processor.dart';
import 'package:{{project_name}}/data/source/remote/auth/auth_source.dart';
import 'package:{{project_name}}/data/source/remote/auth/auth_source_impl.dart';{{/graphql}}
{{#firebase_auth}}import 'package:firebase_auth/firebase_auth.dart';
import 'package:{{project_name}}/data/source/remote/firebase/auth/firebase_auth_source.dart';
import 'package:{{project_name}}/data/source/remote/firebase/auth/firebase_auth_source_impl.dart';{{/firebase_auth}}
-
+import 'package:onix_flutter_core/onix_flutter_core.dart';
//{imports end}
void registerSources(GetIt getIt) {
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/mapper/authentication/authentication_mapper.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/mapper/authentication/authentication_mapper.dart
index 94c04056..0839d9a9 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/mapper/authentication/authentication_mapper.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/mapper/authentication/authentication_mapper.dart
@@ -1,6 +1,6 @@
-import 'package:{{project_name}}/core/arch/domain/common/converter/mapper.dart';
import 'package:{{project_name}}/data/model/remote/authentication/authentication_response.dart';
import 'package:{{project_name}}/domain/entity/authentication/authentication.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
class _ResponseToEntity
implements Mapper {
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/repository/firebase_auth_repository_impl.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/repository/firebase_auth_repository_impl.dart
index 36d21f7d..4ccce165 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/repository/firebase_auth_repository_impl.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/repository/firebase_auth_repository_impl.dart
@@ -1,12 +1,10 @@
-import 'package:{{project_name}}/core/arch/domain/entity/common/operation_status.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/result.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/failure/api_failure.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/failure/firebase_failure.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
+import 'package:onix_flutter_core_models/onix_flutter_core_models.dart';
import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
import 'package:{{project_name}}/data/source/remote/firebase/auth/firebase_auth_source.dart';
+import 'package:{{project_name}}/domain/entity/failure/firebase_failure.dart';
import 'package:{{project_name}}/domain/params/create_user/create_account_params.dart';
import 'package:{{project_name}}/domain/repository/firebase_auth_repository.dart';
-
//{entities_imports}
class FirebaseAuthRepositoryImpl extends FirebaseAuthRepository {
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/repository/refresh_token_repository_impl.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/repository/refresh_token_repository_impl.dart
index 89d24f58..cfd4155d 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/repository/refresh_token_repository_impl.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/repository/refresh_token_repository_impl.dart
@@ -1,4 +1,4 @@
-import 'package:{{project_name}}/core/arch/domain/entity/common/result.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
import 'package:{{project_name}}/domain/entity/authentication/authentication.dart';
import 'package:{{project_name}}/domain/repository/refresh_token_repository.dart';
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/local/preferences_source/preferences_source_impl.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/local/preferences_source/preferences_source_impl.dart
index 5a47745c..fd1b6b99 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/local/preferences_source/preferences_source_impl.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/local/preferences_source/preferences_source_impl.dart
@@ -1,5 +1,4 @@
-import 'package:{{project_name}}/core/arch/data/local/prefs/base_preferences.dart';
-
+import 'package:onix_flutter_core/onix_flutter_core.dart';
import 'package:{{project_name}}/data/source/local/preferences_source/preferences_keys.dart';
import 'package:{{project_name}}/data/source/local/preferences_source/preferences_source.dart';
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/auth/auth_source.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/auth/auth_source.dart
index bc1f942a..9886a594 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/auth/auth_source.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/auth/auth_source.dart
@@ -1,4 +1,4 @@
-import 'package:{{project_name}}/core/arch/domain/entity/common/data_response.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
import 'package:{{project_name}}/data/model/remote/authentication/authentication_request.dart';
import 'package:{{project_name}}/data/model/remote/customer_access_token/customer_token_response_data.dart';
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/auth/auth_source_impl.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/auth/auth_source_impl.dart
index 01d98078..2b6b06cd 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/auth/auth_source_impl.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/auth/auth_source_impl.dart
@@ -1,10 +1,10 @@
-import 'package:{{project_name}}/core/arch/data/remote/clients/graph_ql/graph_ql_client.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/graph_ql/request_processor/graph_ql_request_processor.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/data_response.dart';
+import 'package:{{project_name}}/core/arch/data/remote/graph_ql/graph_ql_client.dart';
+import 'package:{{project_name}}/core/arch/data/remote/graph_ql/request_processor/graph_ql_request_processor.dart';
import 'package:{{project_name}}/data/model/remote/authentication/authentication_request.dart';
import 'package:{{project_name}}/data/model/remote/customer_access_token/customer_token_response_data.dart';
import 'package:{{project_name}}/data/source/remote/auth/auth_source.dart';
import 'package:{{project_name}}/data/source/remote/auth/mutations/access_token_mutation.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
class AuthSourceImpl extends AuthSource {
final GraphQlClient _apiClient;
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/firebase/auth/firebase_auth_source.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/firebase/auth/firebase_auth_source.dart
index 440c2037..287d7298 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/firebase/auth/firebase_auth_source.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/firebase/auth/firebase_auth_source.dart
@@ -1,5 +1,4 @@
-import 'package:{{project_name}}/core/arch/domain/entity/common/data_response.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/operation_status.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
//{response_imports}
//{request_imports}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/firebase/auth/firebase_auth_source_impl.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/firebase/auth/firebase_auth_source_impl.dart
index 73151354..3e9d7e79 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/firebase/auth/firebase_auth_source_impl.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/firebase/auth/firebase_auth_source_impl.dart
@@ -1,7 +1,5 @@
import 'package:firebase_auth/firebase_auth.dart';
-
-import 'package:{{project_name}}/core/arch/domain/entity/common/data_response.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/operation_status.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
import 'package:{{project_name}}/data/source/remote/firebase/auth/firebase_auth_source.dart';
//{response_imports}
@@ -70,7 +68,7 @@ class FirebaseAuthSourceImpl extends FirebaseAuthSource {
return const DataResponse.unauthorized();
}
} on FirebaseAuthException catch (e) {
- return DataResponse.firebaseError(e.code);
+ return DataResponse.undefinedError(e);
} catch (e) {
return DataResponse.undefinedError(e);
}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/firebase/firebase_const.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/firebase/firebase_const.dart
index 1518b5f3..19d53802 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/firebase/firebase_const.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/data/source/remote/firebase/firebase_const.dart
@@ -3,4 +3,6 @@ class FirebaseConst {
static const errWrongPassword = 'wrong-password';
static const errWeakPassword = 'weak-password';
static const errEmailAlreadyRegistered = 'email-already-in-use';
+
+ const FirebaseConst._();
}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/failure/firebase_failure.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/entity/failure/firebase_failure.dart
similarity index 50%
rename from bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/failure/firebase_failure.dart
rename to bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/entity/failure/firebase_failure.dart
index a1399c26..8a1d8124 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/failure/firebase_failure.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/entity/failure/firebase_failure.dart
@@ -1,6 +1,6 @@
-import 'package:{{project_name}}/core/arch/domain/entity/failure/failure.dart';
+import 'package:onix_flutter_core_models/onix_flutter_core_models.dart';
-class FirebaseFailure implements FeatureFailure {
+class FirebaseFailure implements Failure {
FirebaseFailure(this.code);
final String code;
@@ -9,4 +9,4 @@ class FirebaseFailure implements FeatureFailure {
String toString() {
return 'FirebaseFailure{code: $code}';
}
-}
+}
\ No newline at end of file
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/repository/firebase_auth_repository.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/repository/firebase_auth_repository.dart
index a2252462..a5520b0a 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/repository/firebase_auth_repository.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/repository/firebase_auth_repository.dart
@@ -1,4 +1,4 @@
-import 'package:{{project_name}}/core/arch/domain/entity/common/result.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
import 'package:{{project_name}}/domain/params/create_user/create_account_params.dart';
//{entities_imports}
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/repository/refresh_token_repository.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/repository/refresh_token_repository.dart
index de2e708f..08f26042 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/repository/refresh_token_repository.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/repository/refresh_token_repository.dart
@@ -1,4 +1,4 @@
-import 'package:{{project_name}}/core/arch/domain/entity/common/result.dart';
+import 'package:onix_flutter_core/onix_flutter_core.dart';
import 'package:{{project_name}}/domain/entity/authentication/authentication.dart';
abstract class RefreshTokenRepository {
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/usecase/create_account_use_case.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/usecase/create_account_use_case.dart
index 4b9bd743..375825ff 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/usecase/create_account_use_case.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/usecase/create_account_use_case.dart
@@ -1,5 +1,5 @@
+import 'package:onix_flutter_core/onix_flutter_core.dart';
import 'package:{{project_name}}/app/service/firebase_session_service/firebase_session_service.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/result.dart';
import 'package:{{project_name}}/domain/params/create_user/create_account_params.dart';
import 'package:{{project_name}}/domain/repository/firebase_auth_repository.dart';
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/usecase/log_out_use_case.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/usecase/log_out_use_case.dart
index 472a16df..0c5ab0a5 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/usecase/log_out_use_case.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/usecase/log_out_use_case.dart
@@ -1,5 +1,5 @@
+import 'package:onix_flutter_core/onix_flutter_core.dart';
import 'package:{{project_name}}/app/service/firebase_session_service/firebase_session_service.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/result.dart';
import 'package:{{project_name}}/domain/repository/firebase_auth_repository.dart';
class LogOutUseCase {
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/usecase/login_use_case.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/usecase/login_use_case.dart
index 5e9184a6..4a0225cb 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/usecase/login_use_case.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/domain/usecase/login_use_case.dart
@@ -1,6 +1,5 @@
+import 'package:onix_flutter_core/onix_flutter_core.dart';
import 'package:{{project_name}}/app/service/firebase_session_service/firebase_session_service.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/result.dart';
-
import 'package:{{project_name}}/domain/repository/firebase_auth_repository.dart';
class LoginUseCase {
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/main.gen.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/main.gen.dart
index 6300e3af..c22ff4f9 100644
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/main.gen.dart
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/main.gen.dart
@@ -2,14 +2,16 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
+{{#isBloc}}import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:onix_flutter_bloc/onix_flutter_bloc.dart';{{/isBloc}}
+{{#isRiverpod}}import 'package:flutter_riverpod/flutter_riverpod.dart';{{/isRiverpod}}
import 'package:{{project_name}}/app/banned_app.dart';
-import 'package:{{project_name}}/core/arch/bloc/app_bloc_observer.dart';
import 'package:{{project_name}}/app/app.dart';
import 'package:{{project_name}}/app/app_initialization.dart';
import 'package:{{project_name}}/core/di/services.dart';
import 'package:{{project_name}}/app/util/extension/orientation_extension.dart';
import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
+{{#sentry}}import 'package:sentry_flutter/sentry_flutter.dart';{{/sentry}}
Future main{{#flavorizr}}App{{/flavorizr}}() async {
unawaited(
@@ -17,23 +19,37 @@ Future main{{#flavorizr}}App{{/flavorizr}}() async {
() async {
WidgetsFlutterBinding.ensureInitialized();
await Initialization.I.initApp();
-
+ {{#sentry}}await SentryFlutter.init(
+ (options) {
+ options.dsn = 'SENTRY_DSN';
+ },
+ );{{/sentry}}
await OrientationExtension.lockVertical();
- Bloc.observer = AppBlocObserver();
+ {{#isBloc}}Bloc.observer = AppBlocObserver();{{/isBloc}}
final isAllowedToUseApp = await environmentService().initialize();
if (isAllowedToUseApp) {
+ {{#isRiverpod}}
+ runApp(const ProviderScope(child: App()));
+ {{/isRiverpod}}
+ {{^isRiverpod}}
runApp(const App());
+ {{/isRiverpod}}
} else {
runApp(const BannedApp());
}
},
- (error, stackTrace) {
- logger.crash(error: error, stackTrace: stackTrace, reason: 'main');
- },
- )?.catchError((e, trace) {
- logger.crash(error: e, stackTrace: trace, reason: 'main');
+ _onError,
+ )?.catchError((error, stackTrace) {
+ _onError(error, stackTrace);
exit(-1);
- }),
+ },
+ ),
);
+}
+
+
+Future _onError(dynamic error, dynamic stackTrace) async {
+ logger.crash(error: error, stackTrace: stackTrace, reason: 'main');
+ {{#sentry}}await Sentry.captureException(error, stackTrace: stackTrace);{{/sentry}}
}
\ No newline at end of file
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/test/app_test.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/test/app_test.dart
new file mode 100644
index 00000000..05a37e98
--- /dev/null
+++ b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/test/app_test.dart
@@ -0,0 +1 @@
+void main() {}
\ No newline at end of file
diff --git a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/test/core/data/remote/dio/dio_request_processor/dio_request_processor_impl_test.dart b/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/test/core/data/remote/dio/dio_request_processor/dio_request_processor_impl_test.dart
deleted file mode 100644
index 06128ec1..00000000
--- a/bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/test/core/data/remote/dio/dio_request_processor/dio_request_processor_impl_test.dart
+++ /dev/null
@@ -1,503 +0,0 @@
-import 'package:{{project_name}}/core/arch/data/remote/base/http_status.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor.dart';
-import 'package:{{project_name}}/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor_impl.dart';
-import 'package:{{project_name}}/core/arch/data/remote/error/default_api_error.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/data_response.dart';
-import 'package:{{project_name}}/core/arch/domain/entity/common/operation_status.dart';
-import 'package:connectivity_plus/connectivity_plus.dart';
-import 'package:dio/dio.dart';
-import 'package:flutter_test/flutter_test.dart';
-import 'package:internet_connection_checker/internet_connection_checker.dart';
-import 'package:mockito/annotations.dart';
-import 'package:mockito/mockito.dart';
-
-import 'dio_request_processor_impl_test.mocks.dart';
-
-class _MockedException implements Exception {
- const _MockedException();
-}
-
-const mockedException = _MockedException();
-
-@GenerateNiceMocks([
- MockSpec(),
- MockSpec(),
-])
-void main() {
- group('DataResponse error tests', () {
- late DioRequestProcessor requestProcessor;
-
- setUp(() {
- requestProcessor = DioRequestProcessorImpl();
- });
-
- test('DataResponse.undefinedError with non DioExceptionType case',
- () async {
- Future mockedRequest() {
- throw mockedException;
- }
-
- final result =
- await requestProcessor.processRequest(
- onRequest: mockedRequest,
- onResponse: (_) => OperationStatus.success,
- );
-
- expect(
- result,
- const DataResponse.undefinedError(mockedException),
- );
- });
-
- test('DioExceptionType.connectionTimeout case', () async {
- Future mockedRequest() {
- throw DioException(
- type: DioExceptionType.connectionTimeout,
- message: '',
- requestOptions: RequestOptions(),
- error: '',
- );
- }
-
- final result =
- await requestProcessor.processRequest(
- onRequest: mockedRequest,
- onResponse: (_) => OperationStatus.success,
- );
-
- expect(
- result,
- const DataResponse.notConnected(),
- );
- });
-
- test('DioExceptionType.sendTimeout case', () async {
- Future mockedRequest() {
- throw DioException(
- type: DioExceptionType.sendTimeout,
- message: '',
- requestOptions: RequestOptions(),
- error: '',
- );
- }
-
- final result =
- await requestProcessor.processRequest(
- onRequest: mockedRequest,
- onResponse: (_) => OperationStatus.success,
- );
-
- expect(
- result,
- const DataResponse.notConnected(),
- );
- });
-
- test('HttpStatus.networkConnectTimeoutError case', () async {
- Future mockedRequest() {
- throw DioException(
- message: '',
- requestOptions: RequestOptions(),
- response: Response(
- requestOptions: RequestOptions(),
- statusCode: HttpStatus.networkConnectTimeoutError,
- ),
- error: '',
- );
- }
-
- final result =
- await requestProcessor.processRequest(
- onRequest: mockedRequest,
- onResponse: (_) => OperationStatus.success,
- );
-
- expect(
- result,
- const DataResponse.notConnected(),
- );
- });
-
- test('HttpStatus.unauthorized case', () async {
- Future mockedRequest() {
- throw DioException(
- message: '',
- requestOptions: RequestOptions(),
- response: Response(
- requestOptions: RequestOptions(),
- statusCode: HttpStatus.unauthorized,
- ),
- error: '',
- );
- }
-
- final result =
- await requestProcessor.processRequest(
- onRequest: mockedRequest,
- onResponse: (_) => OperationStatus.success,
- );
-
- expect(
- result,
- const DataResponse.unauthorized(),
- );
- });
-
- test('HttpStatus.tooManyRequests case', () async {
- Future mockedRequest() {
- throw DioException(
- message: '',
- requestOptions: RequestOptions(),
- response: Response(
- requestOptions: RequestOptions(),
- statusCode: HttpStatus.tooManyRequests,
- ),
- error: '',
- );
- }
-
- final result =
- await requestProcessor.processRequest(
- onRequest: mockedRequest,
- onResponse: (_) => OperationStatus.success,
- );
-
- expect(
- result,
- const DataResponse.tooManyRequests(),
- );
- });
-
- test('HttpStatus.badRequest case', () async {
- final exception = DioException(
- message: '',
- requestOptions: RequestOptions(),
- response: Response(
- requestOptions: RequestOptions(),
- statusCode: HttpStatus.badRequest,
- data: {
- 'name': 'name',
- 'code': 'code',
- },
- ),
- error: '',
- );
-
- Future mockedRequest() {
- throw exception;
- }
-
- final result =
- await requestProcessor.processRequest(
- onRequest: mockedRequest,
- onResponse: (_) => OperationStatus.success,
- );
-
- expect(
- result,
- const DataResponse.apiError(
- DefaultApiError(
- name: 'name',
- code: 'code',
- ),
- HttpStatus.badRequest,
- ),
- );
- });
-
- test('Empty response body case', () async {
- final mockedException = DioException(
- message: '',
- requestOptions: RequestOptions(),
- response: Response(
- requestOptions: RequestOptions(),
- statusCode: HttpStatus.badRequest,
- ),
- error: '',
- );
-
- Future mockedRequest() {
- throw mockedException;
- }
-
- final result =
- await requestProcessor.processRequest(
- onRequest: mockedRequest,
- onResponse: (_) => OperationStatus.success,
- );
-
- expect(
- result,
- DataResponse.undefinedError(
- mockedException,
- HttpStatus.badRequest,
- ),
- );
- });
-
- test('Unexpected ResponseType case', () async {
- final mockedException = DioException(
- message: '',
- requestOptions: RequestOptions(),
- response: Response(
- requestOptions: RequestOptions(
- responseType: ResponseType.plain,
- ),
- statusCode: HttpStatus.badRequest,
- data: '',
- ),
- error: '',
- );
-
- Future mockedRequest() {
- throw mockedException;
- }
-
- final result =
- await requestProcessor.processRequest(
- onRequest: mockedRequest,
- onResponse: (_) => OperationStatus.success,
- );
-
- expect(
- result,
- DataResponse.undefinedError(mockedException),
- );
- });
-
- test('HttpStatus.internalServerError case', () async {
- final mockedException = DioException(
- message: '',
- requestOptions: RequestOptions(),
- response: Response(
- requestOptions: RequestOptions(),
- statusCode: HttpStatus.internalServerError,
- ),
- error: '',
- );
-
- Future mockedRequest() {
- throw mockedException;
- }
-
- final result1 =
- await requestProcessor.processRequest(
- onRequest: mockedRequest,
- onResponse: (_) => OperationStatus.success,
- );
-
- expect(
- result1,
- DataResponse.undefinedError(
- mockedException,
- HttpStatus.internalServerError,
- ),
- );
- });
-
- test('HttpStatus.serviceUnavailable case', () async {
- final mockedException = DioException(
- message: '',
- requestOptions: RequestOptions(),
- response: Response(
- requestOptions: RequestOptions(),
- statusCode: HttpStatus.serviceUnavailable,
- ),
- error: '',
- );
-
- Future mockedRequest() {
- throw mockedException;
- }
-
- final result1 =
- await requestProcessor.processRequest(
- onRequest: mockedRequest,
- onResponse: (_) => OperationStatus.success,
- );
-
- expect(
- result1,
- DataResponse.undefinedError(
- mockedException,
- HttpStatus.serviceUnavailable,
- ),
- );
- });
-
- test('HttpStatus.forbidden case', () async {
- final mockedException = DioException(
- message: '',
- requestOptions: RequestOptions(),
- response: Response(
- requestOptions: RequestOptions(),
- statusCode: HttpStatus.forbidden,
- ),
- error: '',
- );
-
- Future mockedRequest() {
- throw mockedException;
- }
-
- final result1 =
- await requestProcessor.processRequest(
- onRequest: mockedRequest,
- onResponse: (_) => OperationStatus.success,
- );
-
- expect(
- result1,
- DataResponse.undefinedError(
- mockedException,
- HttpStatus.forbidden,
- ),
- );
- });
-
- test('Request is cancelled', () async {
- final cancelToken = CancelToken();
- final fetchDataFuture = Dio().get(
- 'https://jsonplaceholder.typicode.com/posts',
- cancelToken: cancelToken,
- );
- cancelToken.cancel('Cancelled by user');
- try {
- await fetchDataFuture;
- fail('Expected DioError to be thrown');
- } catch (e) {
- expect(e, isA());
- expect((e as DioException).type, DioExceptionType.cancel);
- expect(e.error, 'Cancelled by user');
- }
- });
-
- test('Request is cancelled and DataResponse.requestCanceled returned',
- () async {
- final cancelToken = CancelToken();
- final fetchDataFuture = Dio().get(
- 'https://jsonplaceholder.typicode.com/posts',
- cancelToken: cancelToken,
- );
- cancelToken.cancel('Cancelled by user');
-
- final result = await requestProcessor.processRequest(
- onRequest: () => fetchDataFuture,
- onResponse: (e) {},
- );
-
- final failure = result.maybeWhen(
- canceledRequest: () => true,
- orElse: () => false,
- );
-
- expect(result.isError(), true);
- expect(failure, true);
- });
- });
-
- group('HttpStatus.kCodeSuccess tests', () {
- late DioRequestProcessor requestProcessor;
-
- setUp(() {
- requestProcessor = DioRequestProcessorImpl();
- });
-
- test('Success case', () async {
- const mockedData = 'test';
-
- Future> mockedRequest() {
- return Future>.value(
- Response(
- requestOptions: RequestOptions(),
- statusCode: HttpStatus.kCodeSuccess200,
- data: mockedData,
- ),
- );
- }
-
- final result =
- await requestProcessor.processRequest, String>(
- onRequest: mockedRequest,
- onResponse: (response) => response.data as String,
- );
-
- expect(result, const DataResponse.success(mockedData));
- });
- });
-
- group('Connectivity && InternetConnectionChecker tests', () {
- late DioRequestProcessor requestProcessor;
- late Connectivity connectivity;
- late InternetConnectionChecker internetConnectionChecker;
-
- setUp(() {
- connectivity = MockConnectivity();
- internetConnectionChecker = MockInternetConnectionChecker();
- requestProcessor = DioRequestProcessorImpl(
- connectivity: connectivity,
- internetConnectionChecker: internetConnectionChecker,
- );
- });
-
- test('ConnectivityResult.none test', () async {
- const mockedData = 'test';
-
- when(connectivity.checkConnectivity()).thenAnswer(
- (_) async => [ConnectivityResult.none],
- );
-
- when(internetConnectionChecker.hasConnection).thenAnswer(
- (_) async => false,
- );
-
- Future> mockedRequest() {
- return Future>.value(
- Response(
- requestOptions: RequestOptions(),
- statusCode: HttpStatus.kCodeSuccess200,
- data: mockedData,
- ),
- );
- }
-
- final result =
- await requestProcessor.processRequest, String>(
- onRequest: mockedRequest,
- onResponse: (response) => response.data as String,
- );
-
- expect(result, const DataResponse.notConnected());
- });
-
- test('ConnectivityResult.mobile && hasConnection test', () async {
- const mockedData = 'test';
-
- when(connectivity.checkConnectivity()).thenAnswer(
- (_) async => [ConnectivityResult.mobile],
- );
-
- when(internetConnectionChecker.hasConnection).thenAnswer(
- (_) async => true,
- );
-
- Future> mockedRequest() {
- return Future>.value(
- Response(
- requestOptions: RequestOptions(),
- statusCode: HttpStatus.kCodeSuccess200,
- data: mockedData,
- ),
- );
- }
-
- final result =
- await requestProcessor.processRequest, String>(
- onRequest: mockedRequest,
- onResponse: (response) => response.data as String,
- );
-
- expect(result, const DataResponse.success(mockedData));
- });
- });
-}
diff --git a/bricks/flutter_clean_base/hooks/post_gen.dart b/bricks/flutter_clean_base/hooks/post_gen.dart
index 229a1b53..29988189 100644
--- a/bricks/flutter_clean_base/hooks/post_gen.dart
+++ b/bricks/flutter_clean_base/hooks/post_gen.dart
@@ -133,40 +133,22 @@ Future getDependencies(HookContext context) async {
List dependencies = [
'cupertino_icons',
'dio',
- 'pretty_dio_logger',
- 'dio_cache_interceptor',
- 'dio_cache_interceptor_hive_store',
'hive_flutter',
'freezed_annotation',
'json_annotation',
'get_it',
- 'flutter_bloc',
'flutter_secure_storage:^9.0.0',
'shared_preferences',
- 'internet_connection_checker',
- 'retry',
- 'encrypt',
'path_provider',
'logger',
'fluttertoast',
'collection',
'flutter_dotenv',
- 'flutter_jailbreak_detection',
+ 'jailbreak_root_detection',
'gap',
- // (Ivan Modlo): Connectivity Service has been blocked due to
- // unit tests that differ from the major version are lower than 6
- 'connectivity_plus: ^6.0.3',
+ 'onix_flutter_core',
];
- if (!context.vars['web_only']) {
- if (context.vars['screen_util']) {
- dependencies.add('flutter_screenutil');
- }
- dependencies.add('loader_overlay');
- } else {
- dependencies.add('flutter_overlay_loader');
- }
-
List devDependencies = [
'flutter_lints',
'build_runner',
@@ -174,10 +156,44 @@ Future getDependencies(HookContext context) async {
'json_serializable',
'import_sorter',
'mockito',
- 'bloc_test',
'test',
];
+ if (context.vars['isBloc']) {
+ dependencies.addAll(['flutter_bloc', 'onix_flutter_bloc']);
+ devDependencies.add('bloc_test');
+ await removeStateManagers(managers: ['provider', 'riverpod']);
+ }
+
+ if (context.vars['isProvider']) {
+ dependencies.addAll(['provider', 'onix_flutter_provider']);
+ await removeStateManagers(managers: ['bloc', 'riverpod']);
+ }
+
+ if (context.vars['isRiverpod']) {
+ dependencies.add('flutter_riverpod');
+ await removeStateManagers(managers: ['bloc', 'provider']);
+ }
+
+ if (context.vars['isBase']) {
+ await removeStateManagers(managers: ['provider', 'bloc', 'riverpod']);
+ } else {
+ dependencies.add('onix_flutter_core_models');
+ }
+
+ if (!context.vars['web_only']) {
+ if (context.vars['screen_util']) {
+ dependencies.add('flutter_screenutil');
+ }
+ dependencies.add('loader_overlay');
+ } else {
+ dependencies.add('flutter_overlay_loader');
+ }
+
+ if (context.vars['sentry']) {
+ dependencies.add('sentry_flutter');
+ }
+
if (context.vars['theme_generate']) {
dependencies.add('theme_tailor_annotation:3.0.1');
devDependencies.add('theme_tailor:3.0.1');
@@ -267,6 +283,13 @@ Future getDependencies(HookContext context) async {
}
}
+Future removeStateManagers({required List managers}) async {
+ for (var manager in managers) {
+ await Process.run('rm', ['$manager.dart'],
+ workingDirectory: '$name/lib/core/di');
+ }
+}
+
Future flavorize(HookContext context) async {
'Flavorizing...'.log();
@@ -483,6 +506,24 @@ flutter_additional_ios_build_settings(target)
11.0''', ''' MinimumOSVersion
12.0'''));
+ File mainInfoPlistFile = File('$name/ios/Runner/Info.plist');
+ String mainInfoPlistFileContent = mainInfoPlistFile.readAsStringSync();
+
+ mainInfoPlistFileContent = mainInfoPlistFileContent.replaceAll('''
+''', '''LSApplicationQueriesSchemes
+
+ undecimus
+ sileo
+ zbra
+ filza
+ activator
+ cydia
+
+
+''');
+
+ mainInfoPlistFile.writeAsStringSync(mainInfoPlistFileContent);
+
File xcodeWorkspaceFile =
File('$name/ios/Runner.xcodeproj/project.pbxproj');
List xcodeWorkspaceFileContent =
diff --git a/bricks/flutter_clean_base/hooks/pre_gen.dart b/bricks/flutter_clean_base/hooks/pre_gen.dart
index 9ba61a7c..68f28386 100644
--- a/bricks/flutter_clean_base/hooks/pre_gen.dart
+++ b/bricks/flutter_clean_base/hooks/pre_gen.dart
@@ -56,6 +56,13 @@ Future