Skip to content

Commit

Permalink
Merge pull request #89 from Onix-Systems/dev
Browse files Browse the repository at this point in the history
1.2.0+29
  • Loading branch information
cozvtieg9 authored Aug 9, 2024
2 parents ab89eaa + 3ad4238 commit 56b2476
Show file tree
Hide file tree
Showing 51 changed files with 737 additions and 589 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@
</div>

<br/>
<br/>

<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 />
<div align="center"><strong>How does it work? Watch the video!</strong></div>

<div align="center">
<a href="https://www.youtube.com/watch?v=E8kBX7HoqMU">
<img alt="refine logo" src="images/watch_yt_normal.png">
</a>
</div>

<br/>
<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/>
<br/>
</div>
<div align="center">
Expand All @@ -33,7 +41,7 @@ If you're a Onix Project Generator user and you like using our tool, don't **for

## What is Project Generator?

**Flutter Project Generator** is a utility for **MacOS** designed to quickly start a Flutter project from scratch.
**Flutter Project Generator** is an utility for **MacOS** designed to quickly start a Flutter project from scratch.

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

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

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


## Key Features
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//@formatter:off
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
{{^web_only}}import 'package:loader_overlay/loader_overlay.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';{{/web_only}}
import 'package:{{project_name}}/core/arch/bloc/base_block_state.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';
{{#isGoRouter}}import 'package:{{project_name}}/app/router/app_router.dart';{{/isGoRouter}}
Expand All @@ -30,11 +30,12 @@ class _AppState extends BaseState<AppScreenState, AppBloc, AppSR, App> {
{{#isGoRouter}}AppRouter.init();{{/isGoRouter}}
return {{^web_only}}GlobalLoaderOverlay(
overlayColor: Colors.black.withOpacity(0.5),
child: ScreenUtilInit(
child: {{/web_only}}
{{#screen_util}}ScreenUtilInit(
designSize: const Size(375, 812),
minTextAdapt: true,
builder: (context, child) {
return{{/web_only}} blocBuilder(
return{{/screen_util}} blocBuilder(
builder: (context, state) {
return MaterialApp.router(
debugShowCheckedModeBanner: false,
Expand Down Expand Up @@ -83,10 +84,25 @@ class _AppState extends BaseState<AppScreenState, AppBloc, AppSR, App> {
{{/handLocalization}}
);
},
{{^web_only}}
{{#screen_util}}
);
},
{{#web_only}}
);
{{/web_only}}
{{^web_only}}
),
);
{{/web_only}}
{{/screen_util}}
{{^screen_util}}
{{#web_only}}
);
},
),{{/web_only}}
);
{{/web_only}}
{{^web_only}}
),
);
{{/web_only}}
{{/screen_util}}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Constants {
const Constants._();

final class Constants {
static const String filterParamAll = 'All';

const Constants._();
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
//@formatter:off
{{^isGoRouter}}import 'package:auto_route/auto_route.dart';{{/isGoRouter}}
{{#isGoRouter}}import 'package:{{project_name}}/app/router/app_route.dart';{{/isGoRouter}}
{{#isGoRouter}}import 'package:flutter_bloc/flutter_bloc.dart';{{/isGoRouter}}
import 'package:flutter/material.dart';
{{#isGoRouter}}import 'package:go_router/go_router.dart';{{/isGoRouter}}
{{#isGoRouter}}import 'package:{{project_name}}/core/di/services.dart';{{/isGoRouter}}
{{^isGoRouter}}import 'package:{{project_name}}/app/router/guard/init_guard.dart';{{/isGoRouter}}

//{imports end}

{{^isGoRouter}}
part 'app_router.gr.dart';

@AutoRouterConfig(){{/isGoRouter}}
class AppRouter {{^isGoRouter}}extends _$AppRouter{{/isGoRouter}}{
class AppRouter {{^isGoRouter}}extends RootStackRouter{{/isGoRouter}}{
{{#isGoRouter}}static const _initialLocation = '/';

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

final InitGuard init;
@override
late final List<AutoRouteGuard> guards;

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

AppRouter({
required this.init,
}) : super();{{/isGoRouter}}
required List<AutoRouteGuard> globalGuards,
}) : guards = globalGuards;{{/isGoRouter}}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:{{project_name}}/app/router/router_logging_observer.dart';

abstract class RouterModule {
AppRouter appRouter() {
return AppRouter(init: InitGuard());
return AppRouter(globalGuards: [InitGuard()]);
}

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

class Dimensions {
{{^web_only}}static final delimiterH10 = 10.h;{{/web_only}}
{{#web_only}}static final delimiterH10 = 10.0;{{/web_only}}
}
final class Dimensions {
{{#screen_util}} static final delimiterH10 = 10.h;{{/screen_util}}
{{^screen_util}} static const delimiterH10 = 10.0;{{/screen_util}}

const Dimensions._();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:{{project_name}}/core/arch/widget/common/toast.dart';
import 'package:{{project_name}}/core/arch/logger/app_logger_impl.dart';
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';

class QaUtils {
final class QaUtils {
static Widget buildCharlesProxyBtn(_) {
return const SizedBox();
//TODO SHOW set proxy ONLY FOR QA BUILDS
Expand Down Expand Up @@ -84,4 +84,6 @@ class QaUtils {
builder: (context) => alert,
);
}

const QaUtils._();
}
Original file line number Diff line number Diff line change
@@ -1,52 +1,17 @@
import 'dart:async';

import 'package:{{project_name}}/core/arch/bloc/sr_mixin.dart';
import 'package:{{project_name}}/core/arch/domain/entity/failure/failure.dart';
import 'package:flutter/material.dart';
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<Event, State, SR> extends Bloc<Event, State>
with SingleResultMixin<Event, State, SR> {
@protected
late StreamController<Failure> _errorStreamController;

@protected
late StreamController<bool> _progressStreamController;

Stream<Failure> get failureStream => _errorStreamController.stream;

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

BaseBloc(super.initialState) {
_errorStreamController = StreamController<Failure>.broadcast();
_progressStreamController = StreamController<bool>.broadcast();
}

void showProgress() {
if (!_progressStreamController.isClosed) {
_progressStreamController.add(true);
}
}

Future<void> hideProgress() async {
await Future<void>.delayed(const Duration(milliseconds: 50));
if (!_progressStreamController.isClosed) {
_progressStreamController.add(false);
}
}

void onFailure(Failure failure) {
if (!_errorStreamController.isClosed) {
_errorStreamController.add(failure);
}
}
with
SingleResultMixin<Event, State, SR>,
ProgressStreamMixin,
FailureStreamMixin {
BaseBloc(super.initialState);

void dispose() {
if (!_errorStreamController.isClosed) {
_errorStreamController.close();
}
if (!_progressStreamController.isClosed) {
_progressStreamController.close();
}
closeProgressStream();
closeFailureStream();
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
//@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}}/core/extension/loader.dart';{{/web_only}}


typedef ListenDelegate<S> = void Function(BuildContext context, S state);
typedef StateListener<S> = Widget Function(S state);
typedef SingleResultListener<SR> = void Function(
BuildContext context,
SR singleResult,
);
import 'package:{{project_name}}/app/util/extension/loader.dart';{{/web_only}}

abstract class BaseState<S, B extends BaseBloc<dynamic, S, SR>, SR,
W extends StatefulWidget> extends State<W> {
W extends StatefulWidget> extends State<W>
with BlocBuildersMixin<B, S, SR> {
bool lazyBloc = false;
B? _bloc;

Expand Down Expand Up @@ -47,7 +43,7 @@ abstract class BaseState<S, B extends BaseBloc<dynamic, S, SR>, SR,
context.loaderOverlay.hide();
}{{/web_only}}
if (_bloc != null) {
_bloc?.dispose();
_bloc?.dispose();
}
super.dispose();
}
Expand All @@ -70,35 +66,16 @@ abstract class BaseState<S, B extends BaseBloc<dynamic, S, SR>, SR,
);
}

Widget blocConsumer({
required StateListener<S> stateListener,
required ListenDelegate<S>? listenDelegate,
BlocBuilderCondition<S>? buildWhen,
BlocListenerCondition<S>? listenWhen,
}) {
return BlocConsumer<B, S>(
builder: (_, state) => stateListener(state),
listener: listenDelegate ?? _defaultListenDelegate,
buildWhen: buildWhen,
listenWhen: listenWhen,
);
}

Widget blocBuilder({
required BlocWidgetBuilder<S> builder,
BlocBuilderCondition<S>? buildWhen,
}) {
return BlocBuilder<B, S>(builder: builder, buildWhen: buildWhen);
}

void onBlocCreated(BuildContext context, B bloc) {
bloc.progressStream.listen((event) async {
if (event) {
{{#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}}
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}}
}
}
});
}
Expand All @@ -107,7 +84,4 @@ abstract class BaseState<S, B extends BaseBloc<dynamic, S, SR>, SR,
void initParams(BuildContext context) {}

Widget buildWidget(BuildContext context);

// ignore: no-empty-block
void _defaultListenDelegate(BuildContext context, S state) {}
}
Loading

0 comments on commit 56b2476

Please sign in to comment.