Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add freezed support to feature_brick #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bricks/feature_brick/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mason make feature_brick --feature_name login --state_management bloc
| `feature_name` | The name of the feature | login | `string` | false | N/A |
| `state_management` | The state management of the app | bloc | `enum` | false | N/A |
| `use_equatable` | Use the equatable package | true | `boolean` | true | Using bloc/cubit |
| `use_freezed` | Use the freezed package | false | `boolean` | true | Using bloc |

## Outputs 📦

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export 'package:flutter_bloc/flutter_bloc.dart';
export '{{feature_name.snakeCase()}}_bloc.dart';
export '{{feature_name.snakeCase()}}_bloc.dart';{{#use_freezed}}
export '{{feature_name.snakeCase()}}_event.dart';
export '{{feature_name.snakeCase()}}_state.dart';{{/use_freezed}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
// 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

part of '{{feature_name.snakeCase()}}_event.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

T _$identity<T>(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#custom-getters-and-methods');

/// @nodoc
mixin _${{feature_name.pascalCase()}}Event {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() event,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? event,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? event,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(Custom{{feature_name.pascalCase()}}Event value) event,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult Function(Custom{{feature_name.pascalCase()}}Event value)? event,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(Custom{{feature_name.pascalCase()}}Event value)? event,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class ${{feature_name.pascalCase()}}EventCopyWith<$Res> {
factory ${{feature_name.pascalCase()}}EventCopyWith(
{{feature_name.pascalCase()}}Event value, $Res Function({{feature_name.pascalCase()}}Event) then) =
_${{feature_name.pascalCase()}}EventCopyWithImpl<$Res>;
}

/// @nodoc
class _${{feature_name.pascalCase()}}EventCopyWithImpl<$Res> implements ${{feature_name.pascalCase()}}EventCopyWith<$Res> {
_${{feature_name.pascalCase()}}EventCopyWithImpl(this._value, this._then);

final {{feature_name.pascalCase()}}Event _value;
// ignore: unused_field
final $Res Function({{feature_name.pascalCase()}}Event) _then;
}

/// @nodoc
abstract class _$$Custom{{feature_name.pascalCase()}}EventCopyWith<$Res> {
factory _$$Custom{{feature_name.pascalCase()}}EventCopyWith(_$Custom{{feature_name.pascalCase()}}Event value,
$Res Function(_$Custom{{feature_name.pascalCase()}}Event) then) =
__$$Custom{{feature_name.pascalCase()}}EventCopyWithImpl<$Res>;
}

/// @nodoc
class __$$Custom{{feature_name.pascalCase()}}EventCopyWithImpl<$Res>
extends _${{feature_name.pascalCase()}}EventCopyWithImpl<$Res>
implements _$$Custom{{feature_name.pascalCase()}}EventCopyWith<$Res> {
__$$Custom{{feature_name.pascalCase()}}EventCopyWithImpl(
_$Custom{{feature_name.pascalCase()}}Event _value, $Res Function(_$Custom{{feature_name.pascalCase()}}Event) _then)
: super(_value, (v) => _then(v as _$Custom{{feature_name.pascalCase()}}Event));

@override
_$Custom{{feature_name.pascalCase()}}Event get _value => super._value as _$Custom{{feature_name.pascalCase()}}Event;
}

/// @nodoc

class _$Custom{{feature_name.pascalCase()}}Event implements Custom{{feature_name.pascalCase()}}Event {
const _$Custom{{feature_name.pascalCase()}}Event();

@override
String toString() {
return '{{feature_name.pascalCase()}}Event.event()';
}

@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$Custom{{feature_name.pascalCase()}}Event);
}

@override
int get hashCode => runtimeType.hashCode;

@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() event,
}) {
return event();
}

@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? event,
}) {
return event?.call();
}

@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? event,
required TResult orElse(),
}) {
if (event != null) {
return event();
}
return orElse();
}

@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(Custom{{feature_name.pascalCase()}}Event value) event,
}) {
return event(this);
}

@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult Function(Custom{{feature_name.pascalCase()}}Event value)? event,
}) {
return event?.call(this);
}

@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(Custom{{feature_name.pascalCase()}}Event value)? event,
required TResult orElse(),
}) {
if (event != null) {
return event(this);
}
return orElse();
}
}

abstract class Custom{{feature_name.pascalCase()}}Event implements {{feature_name.pascalCase()}}Event {
const factory Custom{{feature_name.pascalCase()}}Event() = _$Custom{{feature_name.pascalCase()}}Event;
}
Loading