Skip to content

Commit 6a8df96

Browse files
authored
Merge pull request #36 from Onix-Systems/feat/brick_sync
Feat/brick sync
2 parents e7d7f87 + d057e92 commit 6a8df96

File tree

19 files changed

+530
-102
lines changed

19 files changed

+530
-102
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ analyzer:
1111
- "**/*.mocks.dart"
1212
- "**/*.tailor.dart"
1313
- "ios/**"
14-
- "test/**"
1514
- "lib/core/app/localization/**"
1615

1716
errors:

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class _AppState extends BaseState<AppScreenState, AppBloc, AppSR, App> {
3434
designSize: const Size(375, 812),
3535
minTextAdapt: true,
3636
builder: (context, child) {
37-
return{{/web_only}} blocConsumer(
38-
stateListener: (state) {
37+
return{{/web_only}} blocBuilder(
38+
builder: (constext, state) {
3939
return MaterialApp.router(
4040
debugShowCheckedModeBanner: false,
4141
builder: (context, widget) {
4242
return MediaQuery(
43-
data: MediaQuery.of(context).copyWith(textScaleFactor: 1),
43+
data: MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling),
4444
{{#flavorizr}}
4545
child: FlavorBanner(
4646
child: widget ?? const SizedBox(),
@@ -75,9 +75,8 @@ class _AppState extends BaseState<AppScreenState, AppBloc, AppSR, App> {
7575

7676
{{#handLocalization}}
7777
localeResolutionCallback: (deviceLocale, supportedLocales) {
78-
locale ??=
78+
return locale ??=
7979
Locale(AppLocalizations.supportedLocales.last.languageCode);
80-
return locale;
8180
},
8281
onGenerateTitle: (context) => context.str.title,
8382
localizationsDelegates: AppLocalizations.localizationsDelegates,

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'dart:async';
2-
31
import 'package:{{project_name}}/app/bloc/app_bloc_imports.dart';
42
import 'package:{{project_name}}/core/arch/bloc/base_bloc.dart';
53
import 'package:flutter/material.dart';
@@ -10,7 +8,7 @@ class AppBloc extends BaseBloc<AppEvent, AppScreenState, AppSR> {
108
on<ChangeThemeEvent>(_onChangeTheme);
119
}
1210

13-
FutureOr<void> _onChangeTheme(
11+
void _onChangeTheme(
1412
ChangeThemeEvent event,
1513
Emitter<AppScreenState> emit,
1614
) {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
class Constants {
2+
const Constants._();
3+
24
static const String filterParamAll = 'All';
35
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ abstract class BaseState<S, B extends BaseBloc<dynamic, S, SR>, SR,
7272

7373
Widget blocConsumer({
7474
required StateListener<S> stateListener,
75-
ListenDelegate<S>? listenDelegate,
75+
required ListenDelegate<S>? listenDelegate,
7676
BlocBuilderCondition<S>? buildWhen,
7777
BlocListenerCondition<S>? listenWhen,
7878
}) {

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:async';
2+
import 'package:{{project_name}}/core/arch/data/remote/error/dio_error_processor.dart';
23
import 'package:{{project_name}}/core/arch/domain/entity/common/data_response.dart';
34
import 'package:dio/dio.dart';
45

@@ -17,5 +18,6 @@ abstract class DioRequestProcessor {
1718
required OnRequest<T> onRequest,
1819
required OnResponse<R> onResponse,
1920
bool checkNetworkConnection = true,
21+
OnCustomError? onCustomError,
2022
});
2123
}

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/clients/dio/dio_request_processor/dio_request_processor_impl.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DioRequestProcessorImpl implements DioRequestProcessor {
3333
final bool useRetry;
3434
@protected
3535
final List<int> retryStatusCodes;
36-
final _errorProcessor = DioErrorProcessor();
36+
final _errorProcessor = const DioErrorProcessor();
3737

3838
DioRequestProcessorImpl({
3939
this.connectivity,
@@ -58,7 +58,7 @@ class DioRequestProcessorImpl implements DioRequestProcessor {
5858

5959
if (checkNetworkConnection &&
6060
(resultConnectivity == ConnectivityResult.none || !hasConnection)) {
61-
return const DataResponse.notConnected();
61+
return DataResponse<R>.notConnected();
6262
}
6363
}
6464

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/data/remote/error/dio_error_processor.dart

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,7 @@ import 'package:dio/dio.dart';
66
typedef OnCustomError<T> = dynamic Function(int code, dynamic response);
77

88
class DioErrorProcessor {
9-
/// Error codes that require re-execution of the request (without bad request)
10-
static const retryStatusCodesWithoutBadReq = [
11-
HttpStatus.unprocessedEntity,
12-
HttpStatus.forbidden,
13-
HttpStatus.unauthorized,
14-
HttpStatus.unsupportedMediaType,
15-
HttpStatus.badRequest,
16-
];
17-
18-
/// List of error codes indicating unknown server behavior -
19-
/// [CommonResponseError.undefinedError]
20-
static const defaultUndefinedErrorCodes = [
21-
HttpStatus.internalServerError,
22-
HttpStatus.notImplemented,
23-
HttpStatus.badGateway,
24-
HttpStatus.serviceUnavailable,
25-
HttpStatus.notFound,
26-
];
27-
28-
final List<int> undefinedErrorCodes;
29-
30-
DioErrorProcessor({
31-
this.undefinedErrorCodes = defaultUndefinedErrorCodes,
32-
});
9+
const DioErrorProcessor();
3310

3411
DataResponse<T> processError<T>(
3512
DioException e, {
@@ -40,40 +17,40 @@ class DioErrorProcessor {
4017
if (e.type == DioExceptionType.connectionTimeout ||
4118
e.type == DioExceptionType.sendTimeout ||
4219
statusCode == HttpStatus.networkConnectTimeoutError) {
43-
return const DataResponse.notConnected();
20+
return DataResponse<T>.notConnected();
4421
}
4522
if (statusCode == HttpStatus.unauthorized) {
46-
return const DataResponse.unauthorized();
23+
return DataResponse<T>.unauthorized();
4724
}
4825
if (statusCode == HttpStatus.tooManyRequests) {
49-
return const DataResponse.tooManyRequests();
50-
}
51-
if (undefinedErrorCodes.contains(statusCode)) {
52-
return DataResponse.undefinedError(e);
53-
}
54-
if (retryStatusCodesWithoutBadReq.contains(statusCode)) {
55-
return DataResponse.undefinedError(e);
26+
return DataResponse<T>.tooManyRequests();
5627
}
5728
final errorHandler = onCustomError;
5829
if (errorHandler != null) {
5930
final apiError = errorHandler(statusCode, responseData);
6031
if (apiError != null) {
61-
return DataResponse.apiError(apiError);
32+
return DataResponse<T>.apiError(apiError);
6233
}
6334
}
6435
return _default<T>(e);
6536
}
6637

6738
DataResponse<T> _default<T>(DioException e) {
68-
final response = e.response?.data;
69-
if (response != null) {
70-
// TODO: process default error there
71-
// TODO: customize DefaultApiError to your purposes
72-
// TODO: also add new error types to DataResponse if needed
73-
74-
final error = DefaultApiError.fromJson(response);
75-
return DataResponse.apiError(error);
39+
try {
40+
final response = e.response?.data;
41+
if (response != null) {
42+
// TODO: process default error there
43+
// TODO: customize DefaultApiError to your purposes
44+
// TODO: also add new error types to DataResponse if needed
45+
46+
final error = DefaultApiError.fromJson(response);
47+
return DataResponse<T>.apiError(error);
48+
}
49+
return DataResponse<T>.undefinedError(e);
50+
} catch (_) {
51+
// This is in case the response is not received
52+
// in the form of ResponseType.json
53+
return DataResponse<T>.undefinedError(e);
7654
}
77-
return DataResponse.undefinedError(e);
7855
}
7956
}

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/domain/entity/common/result.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
44
part 'result.freezed.dart';
55

66
@freezed
7-
sealed class Result<T> with _$Result<T> {
7+
class Result<T> with _$Result<T> {
88
bool get success => this is _ResultSuccess<T>;
99

1010
bool get isError => this is ResultError;

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/widget/common/misk.dart renamed to bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/core/arch/widget/common/clickable_widget.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import 'package:flutter/material.dart';
22

3-
class Delimiter extends SizedBox {
4-
const Delimiter.height(double h, {super.key}) : super(height: h);
5-
6-
const Delimiter.width(double w, {super.key}) : super(width: w);
7-
}
8-
93
class ClickableWidget extends StatelessWidget {
104
const ClickableWidget({
115
super.key,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import 'dart:io';
44
import 'package:flutter/material.dart';
55
import 'package:flutter_bloc/flutter_bloc.dart';
66
import 'package:flutter/services.dart';
7-
import 'package:flutter/foundation.dart';
87
import 'package:{{project_name}}/app/banned_app.dart';
98
import 'package:{{project_name}}/core/arch/bloc/app_bloc_observer.dart';
109
import 'package:{{project_name}}/app/app.dart';

0 commit comments

Comments
 (0)