Skip to content

Commit

Permalink
refactor: optimize build_runner
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor Komarov committed Oct 29, 2024
1 parent dbe0d49 commit 8a73cb1
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 71 deletions.
22 changes: 22 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,25 @@ targets:
json_serializable:
options:
explicit_to_json: true
generate_for:
- lib/app/service/*.dart
- lib/app/service/**/*.dart
- lib/data/**/*.dart
- lib/http/dto/*.dart
retrofit_generator:
generate_for:
- lib/http/api/*.dart
injectable_generator:injectable_builder:
generate_for:
- lib/di/*.dart
- lib/app/service/*.dart
- lib/app/service/**/*.dart
- lib/http/dio_module.dart
- lib/http/repository/*.dart
freezed:
generate_for:
- lib/app/service/dto/*.dart
- lib/data/**/*.dart
- lib/**/*_cubit.dart
- lib/**/*_bloc.dart
- lib/**/*_state.dart
27 changes: 14 additions & 13 deletions lib/di/di.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/feature/add_seed/enter_seed_phrase/cubit/cubit.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//GENERATED BARREL FILE
export 'enter_seed_phrase_cubit.dart';
export 'enter_seed_phrase_input_model.dart';
export 'enter_seed_phrase_input_state.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:app/app/service/messenger/message.dart';
import 'package:app/app/service/messenger/service/messenger_service.dart';
import 'package:app/app/service/network_connection/network_connection_service.dart';
import 'package:app/di/di.dart';
import 'package:app/feature/add_seed/enter_seed_phrase/cubit/enter_seed_phrase_input_model.dart';
import 'package:app/feature/add_seed/enter_seed_phrase/cubit/enter_seed_phrase_input_state.dart';
import 'package:app/feature/constants.dart';
import 'package:app/generated/locale_keys.g.dart';
import 'package:app/utils/mixins/connection_mixin.dart';
Expand Down Expand Up @@ -50,7 +50,7 @@ class EnterSeedPhraseCubit extends Cubit<EnterSeedPhraseState>
late int _currentValue;

/// Models of input
late List<EnterSeedPhraseInputModel> _inputModels;
late List<EnterSeedPhraseInputState> _inputModels;

@override
@protected
Expand Down Expand Up @@ -82,7 +82,7 @@ class EnterSeedPhraseCubit extends Cubit<EnterSeedPhraseState>

_inputModels = List.generate(
max,
(index) => EnterSeedPhraseInputModel.input(
(index) => EnterSeedPhraseInputState.input(
controller: _controllers[index],
focus: _focuses[index],
index: index,
Expand Down Expand Up @@ -394,7 +394,7 @@ class EnterSeedPhraseCubit extends Cubit<EnterSeedPhraseState>
inputModel is EnterSeedPhraseInput) {
// if input entered, not focused and not completed yet
_inputModels[index] =
_inputModels[index] = EnterSeedPhraseInputModel.input(
_inputModels[index] = EnterSeedPhraseInputState.input(
controller: controller,
focus: focus,
index: index,
Expand All @@ -404,7 +404,7 @@ class EnterSeedPhraseCubit extends Cubit<EnterSeedPhraseState>
} else if (controller.text.isEmpty &&
inputModel is EnterSeedPhraseEntered) {
// if input is empty but still completed
_inputModels[index] = EnterSeedPhraseInputModel.input(
_inputModels[index] = EnterSeedPhraseInputState.input(
controller: controller,
focus: focus,
index: index,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@ mixin _$EnterSeedPhraseState {
TResult when<TResult extends Object?>({
required TResult Function() initial,
required TResult Function(List<int> allowedValues, int currentValue,
List<EnterSeedPhraseInputModel> inputs, bool displayPasteButton)
List<EnterSeedPhraseInputState> inputs, bool displayPasteButton)
tab,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? initial,
TResult? Function(List<int> allowedValues, int currentValue,
List<EnterSeedPhraseInputModel> inputs, bool displayPasteButton)?
List<EnterSeedPhraseInputState> inputs, bool displayPasteButton)?
tab,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? initial,
TResult Function(List<int> allowedValues, int currentValue,
List<EnterSeedPhraseInputModel> inputs, bool displayPasteButton)?
List<EnterSeedPhraseInputState> inputs, bool displayPasteButton)?
tab,
required TResult orElse(),
}) =>
Expand Down Expand Up @@ -127,7 +127,7 @@ class _$InitialImpl implements _Initial {
TResult when<TResult extends Object?>({
required TResult Function() initial,
required TResult Function(List<int> allowedValues, int currentValue,
List<EnterSeedPhraseInputModel> inputs, bool displayPasteButton)
List<EnterSeedPhraseInputState> inputs, bool displayPasteButton)
tab,
}) {
return initial();
Expand All @@ -138,7 +138,7 @@ class _$InitialImpl implements _Initial {
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? initial,
TResult? Function(List<int> allowedValues, int currentValue,
List<EnterSeedPhraseInputModel> inputs, bool displayPasteButton)?
List<EnterSeedPhraseInputState> inputs, bool displayPasteButton)?
tab,
}) {
return initial?.call();
Expand All @@ -149,7 +149,7 @@ class _$InitialImpl implements _Initial {
TResult maybeWhen<TResult extends Object?>({
TResult Function()? initial,
TResult Function(List<int> allowedValues, int currentValue,
List<EnterSeedPhraseInputModel> inputs, bool displayPasteButton)?
List<EnterSeedPhraseInputState> inputs, bool displayPasteButton)?
tab,
required TResult orElse(),
}) {
Expand Down Expand Up @@ -203,7 +203,7 @@ abstract class _$$TabImplCopyWith<$Res> {
$Res call(
{List<int> allowedValues,
int currentValue,
List<EnterSeedPhraseInputModel> inputs,
List<EnterSeedPhraseInputState> inputs,
bool displayPasteButton});
}

Expand Down Expand Up @@ -236,7 +236,7 @@ class __$$TabImplCopyWithImpl<$Res>
inputs: null == inputs
? _value._inputs
: inputs // ignore: cast_nullable_to_non_nullable
as List<EnterSeedPhraseInputModel>,
as List<EnterSeedPhraseInputState>,
displayPasteButton: null == displayPasteButton
? _value.displayPasteButton
: displayPasteButton // ignore: cast_nullable_to_non_nullable
Expand All @@ -251,7 +251,7 @@ class _$TabImpl implements _Tab {
const _$TabImpl(
{required final List<int> allowedValues,
required this.currentValue,
required final List<EnterSeedPhraseInputModel> inputs,
required final List<EnterSeedPhraseInputState> inputs,
required this.displayPasteButton})
: _allowedValues = allowedValues,
_inputs = inputs;
Expand All @@ -266,9 +266,9 @@ class _$TabImpl implements _Tab {

@override
final int currentValue;
final List<EnterSeedPhraseInputModel> _inputs;
final List<EnterSeedPhraseInputState> _inputs;
@override
List<EnterSeedPhraseInputModel> get inputs {
List<EnterSeedPhraseInputState> get inputs {
if (_inputs is EqualUnmodifiableListView) return _inputs;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_inputs);
Expand Down Expand Up @@ -317,7 +317,7 @@ class _$TabImpl implements _Tab {
TResult when<TResult extends Object?>({
required TResult Function() initial,
required TResult Function(List<int> allowedValues, int currentValue,
List<EnterSeedPhraseInputModel> inputs, bool displayPasteButton)
List<EnterSeedPhraseInputState> inputs, bool displayPasteButton)
tab,
}) {
return tab(allowedValues, currentValue, inputs, displayPasteButton);
Expand All @@ -328,7 +328,7 @@ class _$TabImpl implements _Tab {
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? initial,
TResult? Function(List<int> allowedValues, int currentValue,
List<EnterSeedPhraseInputModel> inputs, bool displayPasteButton)?
List<EnterSeedPhraseInputState> inputs, bool displayPasteButton)?
tab,
}) {
return tab?.call(allowedValues, currentValue, inputs, displayPasteButton);
Expand All @@ -339,7 +339,7 @@ class _$TabImpl implements _Tab {
TResult maybeWhen<TResult extends Object?>({
TResult Function()? initial,
TResult Function(List<int> allowedValues, int currentValue,
List<EnterSeedPhraseInputModel> inputs, bool displayPasteButton)?
List<EnterSeedPhraseInputState> inputs, bool displayPasteButton)?
tab,
required TResult orElse(),
}) {
Expand Down Expand Up @@ -385,12 +385,12 @@ abstract class _Tab implements EnterSeedPhraseState {
const factory _Tab(
{required final List<int> allowedValues,
required final int currentValue,
required final List<EnterSeedPhraseInputModel> inputs,
required final List<EnterSeedPhraseInputState> inputs,
required final bool displayPasteButton}) = _$TabImpl;

List<int> get allowedValues;
int get currentValue;
List<EnterSeedPhraseInputModel> get inputs;
List<EnterSeedPhraseInputState> get inputs;
bool get displayPasteButton;

/// Create a copy of EnterSeedPhraseState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import 'package:flutter/widgets.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'enter_seed_phrase_input_model.freezed.dart';
part 'enter_seed_phrase_input_state.freezed.dart';

/// Model of input word in seed phrase.
/// This model allows display 2 different states of every input.
/// input - ready to enter seed word
/// entered - displayed card with entered (but not 100% correct word).
@freezed
class EnterSeedPhraseInputModel with _$EnterSeedPhraseInputModel {
const factory EnterSeedPhraseInputModel.input({
class EnterSeedPhraseInputState with _$EnterSeedPhraseInputState {
const factory EnterSeedPhraseInputState.input({
required TextEditingController controller,
required FocusNode focus,
required int index,
required bool hasError,
}) = EnterSeedPhraseInput;

const factory EnterSeedPhraseInputModel.entered({
const factory EnterSeedPhraseInputState.entered({
required String text,
required int index,
required bool hasError,
Expand Down
Loading

0 comments on commit 8a73cb1

Please sign in to comment.