Code Monkey home page Code Monkey logo

Comments (4)

marcglasberg avatar marcglasberg commented on June 21, 2024

I have never used freezed, so I would need someone to help me fix this. A PR is welcomed.

from fast_immutable_collections.

tjarvstrand avatar tjarvstrand commented on June 21, 2024

I use freezed together with FIC and I don't see thing behavior. I tried your snippet and this is my generated code:

// **************************************************************************
// 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 _$MyClass {
  IList<int> get numbers => throw _privateConstructorUsedError;

  @JsonKey(ignore: true)
  $MyClassCopyWith<MyClass> get copyWith => throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $MyClassCopyWith<$Res> {
  factory $MyClassCopyWith(MyClass value, $Res Function(MyClass) then) =
      _$MyClassCopyWithImpl<$Res, MyClass>;
  @useResult
  $Res call({IList<int> numbers});
}

/// @nodoc
class _$MyClassCopyWithImpl<$Res, $Val extends MyClass>
    implements $MyClassCopyWith<$Res> {
  _$MyClassCopyWithImpl(this._value, this._then);

  // ignore: unused_field
  final $Val _value;
  // ignore: unused_field
  final $Res Function($Val) _then;

  @pragma('vm:prefer-inline')
  @override
  $Res call({
    Object? numbers = null,
  }) {
    return _then(_value.copyWith(
      numbers: null == numbers
          ? _value.numbers
          : numbers // ignore: cast_nullable_to_non_nullable
              as IList<int>,
    ) as $Val);
  }
}

/// @nodoc
abstract class _$$_MyClassCopyWith<$Res> implements $MyClassCopyWith<$Res> {
  factory _$$_MyClassCopyWith(
          _$_MyClass value, $Res Function(_$_MyClass) then) =
      __$$_MyClassCopyWithImpl<$Res>;
  @override
  @useResult
  $Res call({IList<int> numbers});
}

/// @nodoc
class __$$_MyClassCopyWithImpl<$Res>
    extends _$MyClassCopyWithImpl<$Res, _$_MyClass>
    implements _$$_MyClassCopyWith<$Res> {
  __$$_MyClassCopyWithImpl(_$_MyClass _value, $Res Function(_$_MyClass) _then)
      : super(_value, _then);

  @pragma('vm:prefer-inline')
  @override
  $Res call({
    Object? numbers = null,
  }) {
    return _then(_$_MyClass(
      numbers: null == numbers
          ? _value.numbers
          : numbers // ignore: cast_nullable_to_non_nullable
              as IList<int>,
    ));
  }
}

/// @nodoc

class _$_MyClass implements _MyClass {
  const _$_MyClass({this.numbers = const IListConst([])});

  @override
  @JsonKey()
  final IList<int> numbers;

  @override
  String toString() {
    return 'MyClass(numbers: $numbers)';
  }

  @override
  bool operator ==(dynamic other) {
    return identical(this, other) ||
        (other.runtimeType == runtimeType &&
            other is _$_MyClass &&
            const DeepCollectionEquality().equals(other.numbers, numbers));
  }

  @override
  int get hashCode =>
      Object.hash(runtimeType, const DeepCollectionEquality().hash(numbers));

  @JsonKey(ignore: true)
  @override
  @pragma('vm:prefer-inline')
  _$$_MyClassCopyWith<_$_MyClass> get copyWith =>
      __$$_MyClassCopyWithImpl<_$_MyClass>(this, _$identity);
}

abstract class _MyClass implements MyClass {
  const factory _MyClass({final IList<int> numbers}) = _$_MyClass;

  @override
  IList<int> get numbers;
  @override
  @JsonKey(ignore: true)
  _$$_MyClassCopyWith<_$_MyClass> get copyWith =>
      throw _privateConstructorUsedError;
}

Are you on the latest versions of freezed/FIC?

from fast_immutable_collections.

marcglasberg avatar marcglasberg commented on June 21, 2024

@shtse8 Could you please try the current version 9.1.5 ?

from fast_immutable_collections.

shtse8 avatar shtse8 commented on June 21, 2024

@shtse8 Could you please try the current version 9.1.5 ?

I am confirmed it is working fine on the latest version.

from fast_immutable_collections.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.