Skip to content

Commit 56b2476

Browse files
authored
Merge pull request #89 from Onix-Systems/dev
1.2.0+29
2 parents ab89eaa + 3ad4238 commit 56b2476

File tree

51 files changed

+737
-589
lines changed

Some content is hidden

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

51 files changed

+737
-589
lines changed

README.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@
1616
</div>
1717

1818
<br/>
19-
<br/>
2019

21-
<div align="center"><strong>Create your new Flutter project just in a few clicks.</strong><br>Flutter project generator is as an open source utility for MacOS designed to provide a quick start with your Flutter application development.<br />
20+
<div align="center"><strong>How does it work? Watch the video!</strong></div>
21+
22+
<div align="center">
23+
<a href="https://www.youtube.com/watch?v=E8kBX7HoqMU">
24+
<img alt="refine logo" src="images/watch_yt_normal.png">
25+
</a>
26+
</div>
27+
28+
<br/>
29+
<div align="center"><strong>Create your new Flutter project just in a few clicks.</strong><br>Flutter project generator is an open source utility for MacOS designed to provide a quick start with your Flutter application development.<br/>
2230
<br/>
2331
</div>
2432
<div align="center">
@@ -33,7 +41,7 @@ If you're a Onix Project Generator user and you like using our tool, don't **for
3341

3442
## What is Project Generator?
3543

36-
**Flutter Project Generator** is a utility for **MacOS** designed to quickly start a Flutter project from scratch.
44+
**Flutter Project Generator** is an utility for **MacOS** designed to quickly start a Flutter project from scratch.
3745

3846
**Flutter Project Generator** creates an empty project on **Clean Architecture** with already defined file structure and dependencies.
3947

@@ -58,7 +66,6 @@ Generated project tech consist of such libraries and packages:
5866
* **State Management** - [BLoC](https://pub.dev/packages/flutter_bloc).
5967
* **Networking** - [Dio](https://pub.dev/packages/dio).
6068
* **Service Locator** - [GetIt](https://pub.dev/packages/get_it)
61-
* **UI** - [ScreenUtil](https://pub.dev/packages/flutter_screenutil)
6269
* **Code generator** - [Freezed](https://pub.dev/packages/freezed)
6370
* **Navigation** - [GoRouter](https://pub.dev/packages/go_router) or [AutoRoute](https://pub.dev/packages/auto_route)
6471

@@ -69,6 +76,7 @@ Also there an option to select **optional packages to include** to the project:
6976
* **Flavors** - [Flavorizr](https://pub.dev/packages/flutter_flavorizr)
7077
* **Localization** - [Intl](https://pub.dev/packages/intl_utils)
7178
* **Theming** - [ThemeTailor](https://pub.dev/packages/theme_tailor)
79+
* **UI** - [ScreenUtil](https://pub.dev/packages/flutter_screenutil)
7280

7381

7482
## Key Features

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

+25-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//@formatter:off
22
import 'package:flutter/cupertino.dart';
33
import 'package:flutter/material.dart';
4-
{{^web_only}}import 'package:loader_overlay/loader_overlay.dart';
5-
import 'package:flutter_screenutil/flutter_screenutil.dart';{{/web_only}}
6-
import 'package:{{project_name}}/core/arch/bloc/base_block_state.dart';
4+
{{^web_only}}import 'package:loader_overlay/loader_overlay.dart';{{/web_only}}
5+
{{#screen_util}}import 'package:flutter_screenutil/flutter_screenutil.dart';{{/screen_util}}
6+
import 'package:{{project_name}}/core/arch/bloc/base_bloc_state.dart';
77
import 'package:{{project_name}}/app/bloc/app_bloc_imports.dart';
88
import 'package:{{project_name}}/presentation/style/theme/theme_imports.dart';
99
{{#isGoRouter}}import 'package:{{project_name}}/app/router/app_router.dart';{{/isGoRouter}}
@@ -30,11 +30,12 @@ class _AppState extends BaseState<AppScreenState, AppBloc, AppSR, App> {
3030
{{#isGoRouter}}AppRouter.init();{{/isGoRouter}}
3131
return {{^web_only}}GlobalLoaderOverlay(
3232
overlayColor: Colors.black.withOpacity(0.5),
33-
child: ScreenUtilInit(
33+
child: {{/web_only}}
34+
{{#screen_util}}ScreenUtilInit(
3435
designSize: const Size(375, 812),
3536
minTextAdapt: true,
3637
builder: (context, child) {
37-
return{{/web_only}} blocBuilder(
38+
return{{/screen_util}} blocBuilder(
3839
builder: (context, state) {
3940
return MaterialApp.router(
4041
debugShowCheckedModeBanner: false,
@@ -83,10 +84,25 @@ class _AppState extends BaseState<AppScreenState, AppBloc, AppSR, App> {
8384
{{/handLocalization}}
8485
);
8586
},
86-
{{^web_only}}
87+
{{#screen_util}}
88+
);
89+
},
90+
{{#web_only}}
91+
);
92+
{{/web_only}}
93+
{{^web_only}}
94+
),
95+
);
96+
{{/web_only}}
97+
{{/screen_util}}
98+
{{^screen_util}}
99+
{{#web_only}}
87100
);
88-
},
89-
),{{/web_only}}
90-
);
101+
{{/web_only}}
102+
{{^web_only}}
103+
),
104+
);
105+
{{/web_only}}
106+
{{/screen_util}}
91107
}
92108
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
class Constants {
2-
const Constants._();
3-
1+
final class Constants {
42
static const String filterParamAll = 'All';
3+
4+
const Constants._();
55
}

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

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
//@formatter:off
22
{{^isGoRouter}}import 'package:auto_route/auto_route.dart';{{/isGoRouter}}
33
{{#isGoRouter}}import 'package:{{project_name}}/app/router/app_route.dart';{{/isGoRouter}}
4-
{{#isGoRouter}}import 'package:flutter_bloc/flutter_bloc.dart';{{/isGoRouter}}
5-
import 'package:flutter/material.dart';
64
{{#isGoRouter}}import 'package:go_router/go_router.dart';{{/isGoRouter}}
75
{{#isGoRouter}}import 'package:{{project_name}}/core/di/services.dart';{{/isGoRouter}}
8-
{{^isGoRouter}}import 'package:{{project_name}}/app/router/guard/init_guard.dart';{{/isGoRouter}}
9-
106
//{imports end}
117

128
{{^isGoRouter}}
139
part 'app_router.gr.dart';
1410

1511
@AutoRouterConfig(){{/isGoRouter}}
16-
class AppRouter {{^isGoRouter}}extends _$AppRouter{{/isGoRouter}}{
12+
class AppRouter {{^isGoRouter}}extends RootStackRouter{{/isGoRouter}}{
1713
{{#isGoRouter}}static const _initialLocation = '/';
1814

1915
static final AppRouter _instance = AppRouter._privateConstructor();
@@ -45,12 +41,13 @@ class AppRouter {{^isGoRouter}}extends _$AppRouter{{/isGoRouter}}{
4541
//{routes end}
4642
];
4743

48-
final InitGuard init;
44+
@override
45+
late final List<AutoRouteGuard> guards;
4946

5047
@override
5148
RouteType get defaultRouteType => const RouteType.adaptive();
5249

5350
AppRouter({
54-
required this.init,
55-
}) : super();{{/isGoRouter}}
51+
required List<AutoRouteGuard> globalGuards,
52+
}) : guards = globalGuards;{{/isGoRouter}}
5653
}

bricks/flutter_clean_base/__brick__/{{project_name.snakeCase()}}/lib/app/router/{{^isGoRouter}}router_module.dart{{/isGoRouter}}

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:{{project_name}}/app/router/router_logging_observer.dart';
44

55
abstract class RouterModule {
66
AppRouter appRouter() {
7-
return AppRouter(init: InitGuard());
7+
return AppRouter(globalGuards: [InitGuard()]);
88
}
99

1010
RouterLoggingObserver routerLoggingObserver(
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
{{^web_only}}import 'package:flutter_screenutil/flutter_screenutil.dart';{{/web_only}}
1+
{{#screen_util}}import 'package:flutter_screenutil/flutter_screenutil.dart';{{/screen_util}}
22

3-
class Dimensions {
4-
{{^web_only}}static final delimiterH10 = 10.h;{{/web_only}}
5-
{{#web_only}}static final delimiterH10 = 10.0;{{/web_only}}
6-
}
3+
final class Dimensions {
4+
{{#screen_util}} static final delimiterH10 = 10.h;{{/screen_util}}
5+
{{^screen_util}} static const delimiterH10 = 10.0;{{/screen_util}}
6+
7+
const Dimensions._();
8+
}

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import 'package:{{project_name}}/core/arch/widget/common/toast.dart';
2-
import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
31
import 'package:flutter/material.dart';
2+
import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
3+
import 'package:{{project_name}}/core/arch/widget/common/toast.dart';
44

5-
class QaUtils {
5+
final class QaUtils {
66
static Widget buildCharlesProxyBtn(_) {
77
return const SizedBox();
88
//TODO SHOW set proxy ONLY FOR QA BUILDS
@@ -84,4 +84,6 @@ class QaUtils {
8484
builder: (context) => alert,
8585
);
8686
}
87+
88+
const QaUtils._();
8789
}
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,17 @@
1-
import 'dart:async';
2-
3-
import 'package:{{project_name}}/core/arch/bloc/sr_mixin.dart';
4-
import 'package:{{project_name}}/core/arch/domain/entity/failure/failure.dart';
5-
import 'package:flutter/material.dart';
61
import 'package:flutter_bloc/flutter_bloc.dart';
2+
import 'package:{{project_name}}/core/arch/bloc/failure_stream_mixin.dart';
3+
import 'package:{{project_name}}/core/arch/bloc/progress_stream_mixin.dart';
4+
import 'package:{{project_name}}/core/arch/bloc/sr_mixin.dart';
75

86
abstract class BaseBloc<Event, State, SR> extends Bloc<Event, State>
9-
with SingleResultMixin<Event, State, SR> {
10-
@protected
11-
late StreamController<Failure> _errorStreamController;
12-
13-
@protected
14-
late StreamController<bool> _progressStreamController;
15-
16-
Stream<Failure> get failureStream => _errorStreamController.stream;
17-
18-
Stream<bool> get progressStream => _progressStreamController.stream;
19-
20-
BaseBloc(super.initialState) {
21-
_errorStreamController = StreamController<Failure>.broadcast();
22-
_progressStreamController = StreamController<bool>.broadcast();
23-
}
24-
25-
void showProgress() {
26-
if (!_progressStreamController.isClosed) {
27-
_progressStreamController.add(true);
28-
}
29-
}
30-
31-
Future<void> hideProgress() async {
32-
await Future<void>.delayed(const Duration(milliseconds: 50));
33-
if (!_progressStreamController.isClosed) {
34-
_progressStreamController.add(false);
35-
}
36-
}
37-
38-
void onFailure(Failure failure) {
39-
if (!_errorStreamController.isClosed) {
40-
_errorStreamController.add(failure);
41-
}
42-
}
7+
with
8+
SingleResultMixin<Event, State, SR>,
9+
ProgressStreamMixin,
10+
FailureStreamMixin {
11+
BaseBloc(super.initialState);
4312

4413
void dispose() {
45-
if (!_errorStreamController.isClosed) {
46-
_errorStreamController.close();
47-
}
48-
if (!_progressStreamController.isClosed) {
49-
_progressStreamController.close();
50-
}
14+
closeProgressStream();
15+
closeFailureStream();
5116
}
5217
}
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
//@formatter:off
22
import 'package:{{project_name}}/core/arch/bloc/base_bloc.dart';
3+
import 'package:{{project_name}}/core/arch/bloc/bloc_builders_mixin.dart';
4+
import 'package:{{project_name}}/core/arch/bloc/bloc_typedefs.dart';
35
import 'package:{{project_name}}/core/arch/bloc/stream_listener.dart';
6+
import 'package:{{project_name}}/core/arch/domain/entity/progress_state/progress_state.dart';
47
import 'package:flutter/material.dart';
58
import 'package:flutter_bloc/flutter_bloc.dart';
69
import 'package:get_it/get_it.dart';
710
{{^web_only}}import 'package:loader_overlay/loader_overlay.dart';{{/web_only}}
811
{{#web_only}}import 'package:flutter_overlay_loader/flutter_overlay_loader.dart';
9-
import 'package:{{project_name}}/core/extension/loader.dart';{{/web_only}}
10-
11-
12-
typedef ListenDelegate<S> = void Function(BuildContext context, S state);
13-
typedef StateListener<S> = Widget Function(S state);
14-
typedef SingleResultListener<SR> = void Function(
15-
BuildContext context,
16-
SR singleResult,
17-
);
12+
import 'package:{{project_name}}/app/util/extension/loader.dart';{{/web_only}}
1813

1914
abstract class BaseState<S, B extends BaseBloc<dynamic, S, SR>, SR,
20-
W extends StatefulWidget> extends State<W> {
15+
W extends StatefulWidget> extends State<W>
16+
with BlocBuildersMixin<B, S, SR> {
2117
bool lazyBloc = false;
2218
B? _bloc;
2319

@@ -47,7 +43,7 @@ abstract class BaseState<S, B extends BaseBloc<dynamic, S, SR>, SR,
4743
context.loaderOverlay.hide();
4844
}{{/web_only}}
4945
if (_bloc != null) {
50-
_bloc?.dispose();
46+
_bloc?.dispose();
5147
}
5248
super.dispose();
5349
}
@@ -70,35 +66,16 @@ abstract class BaseState<S, B extends BaseBloc<dynamic, S, SR>, SR,
7066
);
7167
}
7268

73-
Widget blocConsumer({
74-
required StateListener<S> stateListener,
75-
required ListenDelegate<S>? listenDelegate,
76-
BlocBuilderCondition<S>? buildWhen,
77-
BlocListenerCondition<S>? listenWhen,
78-
}) {
79-
return BlocConsumer<B, S>(
80-
builder: (_, state) => stateListener(state),
81-
listener: listenDelegate ?? _defaultListenDelegate,
82-
buildWhen: buildWhen,
83-
listenWhen: listenWhen,
84-
);
85-
}
86-
87-
Widget blocBuilder({
88-
required BlocWidgetBuilder<S> builder,
89-
BlocBuilderCondition<S>? buildWhen,
90-
}) {
91-
return BlocBuilder<B, S>(builder: builder, buildWhen: buildWhen);
92-
}
93-
9469
void onBlocCreated(BuildContext context, B bloc) {
9570
bloc.progressStream.listen((event) async {
96-
if (event) {
97-
{{#web_only}}context.progressShow();{{/web_only}}
98-
{{^web_only}}context.loaderOverlay.show();{{/web_only}}
99-
} else {
100-
{{#web_only}}context.progressHide();{{/web_only}}
101-
{{^web_only}}context.loaderOverlay.hide();{{/web_only}}
71+
if (event is DefaultProgressState) {
72+
if (event.showProgress) {
73+
{{#web_only}}context.progressShow();{{/web_only}}
74+
{{^web_only}}context.loaderOverlay.show();{{/web_only}}
75+
} else {
76+
{{#web_only}}context.progressHide();{{/web_only}}
77+
{{^web_only}}context.loaderOverlay.hide();{{/web_only}}
78+
}
10279
}
10380
});
10481
}
@@ -107,7 +84,4 @@ abstract class BaseState<S, B extends BaseBloc<dynamic, S, SR>, SR,
10784
void initParams(BuildContext context) {}
10885

10986
Widget buildWidget(BuildContext context);
110-
111-
// ignore: no-empty-block
112-
void _defaultListenDelegate(BuildContext context, S state) {}
11387
}

0 commit comments

Comments
 (0)