Skip to content

Commit 41ff93f

Browse files
authored
Merge pull request #13 from Onix-Systems/feat/version_rising
update 1.0.14
2 parents 8069183 + 7eff347 commit 41ff93f

File tree

50 files changed

+382
-343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+382
-343
lines changed

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/analysis_options.yaml

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
include: package:flutter_lints/flutter.yaml
22

33
analyzer:
4-
plugins:
5-
- dart_code_metrics
64
exclude:
75
- "build/**"
86
- "**/*.g.dart"
@@ -14,6 +12,8 @@ analyzer:
1412
- "**/*.tailor.dart"
1513
- "ios/**"
1614
- "test/**"
15+
- "lib/core/app/localization/**"
16+
1717
errors:
1818
prefer_mixin: ignore
1919
flutter_style_todos: ignore
@@ -49,6 +49,12 @@ analyzer:
4949
use_build_context_synchronously: info
5050
use_key_in_widget_constructors: info
5151
valid_regexps: error
52+
missing_required_param: error
53+
missing_return: error
54+
collection_methods_unrelated_type: warning
55+
avoid_final_parameters: error
56+
cast_nullable_to_non_nullable: warning
57+
implicit_call_tearoffs: info
5258

5359
linter:
5460
rules:
@@ -75,8 +81,7 @@ linter:
7581
control_flow_in_finally: true
7682
empty_statements: true
7783
hash_and_equals: true
78-
iterable_contains_unrelated_type: true
79-
list_remove_unrelated_type: true
84+
collection_methods_unrelated_type: true
8085
literal_only_boolean_expressions: true
8186
no_adjacent_strings_in_list: true
8287
no_duplicate_case_values: true
@@ -90,6 +95,8 @@ linter:
9095
use_build_context_synchronously: true
9196
use_key_in_widget_constructors: true
9297
valid_regexps: true
98+
avoid_dynamic_calls: true
99+
invalid_case_patterns: true
93100

94101
# Style rules.
95102
always_declare_return_types: true
@@ -155,7 +162,6 @@ linter:
155162
prefer_conditional_assignment: true
156163
prefer_constructors_over_static_methods: true
157164
prefer_contains: true
158-
prefer_equal_for_default_values: true
159165
prefer_final_fields: true
160166
prefer_final_in_for_each: true
161167
prefer_final_locals: true
@@ -181,7 +187,7 @@ linter:
181187
recursive_getters: true
182188
sized_box_for_whitespace: true
183189
slash_for_doc_comments: true
184-
sort_child_properties_last: false
190+
sort_child_properties_last: true
185191
sort_constructors_first: false
186192
sort_unnamed_constructors_first: false
187193
type_annotate_public_apis: true
@@ -214,7 +220,7 @@ linter:
214220
use_string_buffers: true
215221
use_to_and_as_if_applicable: true
216222
void_checks: true
217-
lines_longer_than_80_chars: false
223+
lines_longer_than_80_chars: true
218224
flutter_style_todos: true
219225
conditional_uri_does_not_exist: true
220226
no_leading_underscores_for_library_prefixes: true
@@ -223,9 +229,37 @@ linter:
223229
sized_box_shrink_expand: true
224230
use_decorated_box: true
225231
use_colored_box: true
232+
avoid_double_and_int_checks: true
233+
avoid_final_parameters: true
234+
avoid_redundant_argument_values: true
235+
cast_nullable_to_non_nullable: true
236+
combinators_ordering: true
237+
dangling_library_doc_comments: true
238+
eol_at_end_of_file: true
239+
implicit_call_tearoffs: true
240+
join_return_with_assignment: true
241+
library_private_types_in_public_api: true
242+
no_default_cases: true
243+
noop_primitive_operations: true
244+
null_check_on_nullable_type_parameter: true
245+
package_prefixed_library_names: true
246+
prefer_asserts_with_message: true
247+
prefer_int_literals: true
248+
prefer_null_aware_method_calls: true
249+
require_trailing_commas: true
250+
tighten_type_of_initializing_formals: true
251+
unnecessary_constructor_name: true
252+
unnecessary_library_directive: true
253+
unnecessary_to_list_in_spreads: true
254+
use_enums: true
255+
use_string_in_part_of_directives: true
256+
use_super_parameters: true
257+
use_test_throws_matchers: true
258+
unnecessary_breaks: true
226259

227260
# Pub rules.
228261
package_names: true
262+
depend_on_referenced_packages: true
229263

230264
#https://github.com/dart-lang/lints/blob/main/lib/core.yaml
231265
#https://github.com/dart-lang/lints/blob/main/lib/recommended.yaml

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app.gen.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';{{/web_only}}
66
import 'package:{{project_name}}/core/arch/bloc/base_block_state.dart';
77
import 'package:{{project_name}}/app/bloc/app_bloc_imports.dart';
88
import 'package:{{project_name}}/presentation/style/theme/theme_imports.dart';
9-
{{#isGoRouter}}import 'package:{{project_name}}/core/router/app_router.dart';{{/isGoRouter}}
9+
{{#isGoRouter}}import 'package:{{project_name}}/app/router/app_router.dart';{{/isGoRouter}}
1010
{{^isGoRouter}}import 'package:{{project_name}}/core/di/app.dart';{{/isGoRouter}}
1111
{{^handLocalization}}import 'package:flutter_localizations/flutter_localizations.dart';{{/handLocalization}}
12-
{{#handLocalization}}import 'package:{{project_name}}/core/app/localization/common_app_localization_ext.dart';
12+
{{#handLocalization}}import 'package:{{project_name}}/app/localization/common_app_localization_ext.dart';
1313
import 'package:flutter_gen/gen_l10n/app_localizations.dart';{{/handLocalization}}
1414
{{#flavorizr}}import 'package:{{project_name}}/core/arch/widget/common/flavor_banner.dart';{{/flavorizr}}
15-
{{^handLocalization}}import 'package:{{project_name}}/core/app/localization/generated/l10n.dart';{{/handLocalization}}
15+
{{^handLocalization}}import 'package:{{project_name}}/app/localization/generated/l10n.dart';{{/handLocalization}}
1616

1717
class App extends StatefulWidget {
1818
const App({super.key});
@@ -29,21 +29,19 @@ class _AppState extends BaseState<AppScreenState, AppBloc, AppSR, App> {
2929
Widget buildWidget(BuildContext context) {
3030
{{#isGoRouter}}AppRouter.init();{{/isGoRouter}}
3131
return {{^web_only}}GlobalLoaderOverlay(
32-
useDefaultLoading: true,
3332
overlayColor: Colors.black,
3433
overlayOpacity: 0.5,
3534
child: ScreenUtilInit(
3635
designSize: const Size(375, 812),
3736
minTextAdapt: true,
38-
splitScreenMode: false,
3937
builder: (context, child) {
4038
return{{/web_only}} blocConsumer(
4139
stateListener: (state) {
4240
return MaterialApp.router(
4341
debugShowCheckedModeBanner: false,
4442
builder: (context, widget) {
4543
return MediaQuery(
46-
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
44+
data: MediaQuery.of(context).copyWith(textScaleFactor: 1),
4745
{{#flavorizr}}
4846
child: FlavorBanner(
4947
child: widget ?? const SizedBox(),
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import 'package:get_it/get_it.dart';
22
import 'package:{{project_name}}/core/di/app.dart';
33
import 'package:{{project_name}}/core/di/injection.dart';
4-
import 'package:{{project_name}}/core/di/services.dart';
54

6-
class AppInitialization {
7-
static final AppInitialization _instance =
8-
AppInitialization._privateConstructor();
5+
class Initialization {
6+
static final Initialization _instance = Initialization._privateConstructor();
97

10-
static AppInitialization get I => _instance;
8+
static Initialization get I => _instance;
119

12-
AppInitialization._privateConstructor();
10+
Initialization._privateConstructor();
1311

1412
Future<void> initApp() async {
1513
//TODO init firebase / Crashlytics / Messaging

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/app/app_service.dart renamed to bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/app_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AppService {
2626
}
2727
}
2828

29-
await dotenv.load(fileName: '.env');
29+
await dotenv.load();
3030
return true;
3131
}
3232

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/banned_app.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ class BannedApp extends StatelessWidget {
99
home: Scaffold(
1010
body: Center(
1111
child: Padding(
12-
padding: EdgeInsets.all(8.0),
12+
padding: EdgeInsets.all(8),
1313
child: Text(
1414
'App is not working on jail broken or rooted device.',
1515
textAlign: TextAlign.center,
16-
style: TextStyle(fontSize: 32.0),
16+
style: TextStyle(fontSize: 32),
1717
),
1818
),
1919
),
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Constants {
2+
static const String filterParamAll = 'All';
3+
}

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/router/app_router.dart renamed to bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/router/app_router.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{{#isGoRouter}}import 'package:flutter_bloc/flutter_bloc.dart';{{/isGoRouter}}
44
import 'package:flutter/material.dart';
55
{{#isGoRouter}}import 'package:go_router/go_router.dart';{{/isGoRouter}}
6-
{{^isGoRouter}}import 'package:{{project_name}}/core/router/guard/init_guard.dart';{{/isGoRouter}}
6+
{{^isGoRouter}}import 'package:{{project_name}}/app/router/guard/init_guard.dart';{{/isGoRouter}}
77
import 'package:{{project_name}}/presentation/screen/home_screen.dart';
88
//{imports end}
99

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart';
22
import 'package:{{project_name}}/core/di/app.dart';
33
import 'package:flutter/material.dart';
44

5-
import 'package:{{project_name}}/core/router/app_router.dart';
5+
import 'package:{{project_name}}/app/router/app_router.dart';
66

77
class RouterLoggingObserver extends AutoRouterObserver {
88
final AppRouter appRouter;
@@ -30,7 +30,8 @@ class RouterLoggingObserver extends AutoRouterObserver {
3030
@override
3131
void didReplace({Route? newRoute, Route? oldRoute}) {
3232
logger.w(
33-
'ROUTING Route replaced to: ${newRoute?.settings.name} from: ${oldRoute?.settings.name}, stack${_stack()}',);
33+
'ROUTING Route replaced to: ${newRoute?.settings.name} '
34+
'from: ${oldRoute?.settings.name}, stack${_stack()}',);
3435
}
3536

3637
@override
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import 'package:{{project_name}}/core/router/app_router.dart';
2-
import 'package:{{project_name}}/core/router/guard/init_guard.dart';
3-
import 'package:{{project_name}}/core/router/router_logging_observer.dart';
1+
import 'package:{{project_name}}/app/router/app_router.dart';
2+
import 'package:{{project_name}}/app/router/guard/init_guard.dart';
3+
import 'package:{{project_name}}/app/router/router_logging_observer.dart';
44

55
abstract class RouterModule {
66
AppRouter appRouter() {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'dart:async';
33
import 'package:{{project_name}}/core/di/remote.dart';
44
import 'package:{{project_name}}/core/di/repository.dart';
55
import 'package:{{project_name}}/domain/entity/authentication/authentication.dart';
6-
import 'package:{{project_name}}/domain/service/session_service/session_status.dart';
6+
import 'package:{{project_name}}/app/service/session_service/session_status.dart';
77

88
class SessionService {
99
final StreamController<SessionStatus> _sessionObserver =
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{#handLocalization}}import 'package:{{project_name}}/app/localization/common_app_localization_ext.dart';{{/handLocalization}}
2+
{{^handLocalization}}import 'package:{{project_name}}/app/localization/generated/l10n.dart';{{/handLocalization}}
3+
import 'package:{{project_name}}/core/arch/domain/entity/failure/api_failure.dart';
4+
import 'package:flutter/material.dart';
5+
6+
extension FailureMessageExtension on BuildContext {
7+
String getApiFailureMessage(ApiFailure failure) {
8+
switch (failure.failure) {
9+
case ServerFailure.noNetwork:
10+
{{#handLocalization}}return str.apiFailureNoNetwork;{{/handLocalization}}
11+
{{^handLocalization}}return S.current.apiFailureNoNetwork;{{/handLocalization}}
12+
case ServerFailure.exception:
13+
{{#handLocalization}}return str.apiFailureUndefined;{{/handLocalization}}
14+
{{^handLocalization}}return S.current.apiFailureUndefined;{{/handLocalization}}
15+
case ServerFailure.unAuthorized:
16+
{{#handLocalization}}return str.apiFailureUnAuthorized;{{/handLocalization}}
17+
{{^handLocalization}}return S.current.apiFailureUnAuthorized;{{/handLocalization}}
18+
case ServerFailure.tooManyRequests:
19+
{{#handLocalization}}return str.apiFailureTooManyRequests;{{/handLocalization}}
20+
{{^handLocalization}}return S.current.apiFailureTooManyRequests;{{/handLocalization}}
21+
case ServerFailure.response:
22+
return failure.message;
23+
case ServerFailure.unknown:
24+
{{#handLocalization}}return str.apiFailureUndefined;{{/handLocalization}}
25+
{{^handLocalization}}return S.current.apiFailureUndefined;{{/handLocalization}}
26+
}
27+
}
28+
}

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/util/qa_utils.dart renamed to bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/util/qa_utils.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class QaUtils {
5555
mainAxisAlignment: MainAxisAlignment.end,
5656
children: <Widget>[
5757
MaterialButton(
58-
elevation: 10.0,
58+
elevation: 10,
5959
child: const Text(
6060
'Set proxy',
6161
textDirection: TextDirection.ltr,
@@ -70,7 +70,7 @@ class QaUtils {
7070
},
7171
),
7272
MaterialButton(
73-
elevation: 10.0,
73+
elevation: 10,
7474
child: const Text('Cancel'),
7575
onPressed: () {
7676
Navigator.of(context, rootNavigator: true).pop(context);

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_bloc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ abstract class BaseBloc<Event, State, SR> extends Bloc<Event, State>
1717

1818
Stream<bool> get progressStream => _progressStreamController.stream;
1919

20-
BaseBloc(State initialState) : super(initialState) {
20+
BaseBloc(super.initialState) {
2121
_errorStreamController = StreamController<Failure>.broadcast();
2222
_progressStreamController = StreamController<bool>.broadcast();
2323
}

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/base_cubit.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ abstract class BaseCubit<State, SR> extends Cubit<State>
1717

1818
Stream<bool> get progressStream => _progressStreamController.stream;
1919

20-
BaseCubit(State initialState) : super(initialState) {
20+
BaseCubit(super.initialState) {
2121
_errorStreamController = StreamController<Failure>.broadcast();
2222
_progressStreamController = StreamController<bool>.broadcast();
2323
}

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/bloc/stream_listener.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class StreamListener<T> extends StatefulWidget {
1919
this.onError,
2020
this.onDone,
2121
this.cancelOnError,
22-
Key? key,
23-
}) : super(key: key);
22+
super.key,
23+
});
2424

2525
@override
2626
State<StreamListener<T>> createState() => _StreamListenerState<T>();

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/local/prefs/base_preferences.dart

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ class BasePreferences {
66
T result;
77

88
switch (defaultValue.runtimeType) {
9-
case String:
9+
case const (String):
1010
final value = prefs.getString(key) as T?;
1111
result = value ?? defaultValue;
1212
break;
13-
case bool:
13+
case const (bool):
1414
final value = prefs.getBool(key) as T?;
1515
result = value ?? defaultValue;
1616
break;
17-
case double:
17+
case const (double):
1818
final value = prefs.getDouble(key) as T?;
1919
result = value ?? defaultValue;
2020
break;
21-
case int:
21+
case const (int):
2222
final value = prefs.getInt(key) as T?;
2323
result = value ?? defaultValue;
2424
break;
@@ -31,16 +31,16 @@ class BasePreferences {
3131
Future<void> put<T>(String key, T value) async {
3232
final prefs = await SharedPreferences.getInstance();
3333
switch (value.runtimeType) {
34-
case String:
34+
case const (String):
3535
await prefs.setString(key, value as String);
3636
break;
37-
case bool:
37+
case const (bool):
3838
await prefs.setBool(key, value as bool);
3939
break;
40-
case double:
40+
case const (double):
4141
await prefs.setDouble(key, value as double);
4242
break;
43-
case int:
43+
case const (int):
4444
await prefs.setInt(key, value as int);
4545
break;
4646
}
@@ -55,4 +55,9 @@ class BasePreferences {
5555
final prefs = await SharedPreferences.getInstance();
5656
return prefs.remove(key);
5757
}
58+
59+
Future<void> reload() async {
60+
final prefs = await SharedPreferences.getInstance();
61+
await prefs.reload();
62+
}
5863
}

0 commit comments

Comments
 (0)