Freezed: 0.2.0: copyWith not accessible when including json_serializable

Created on 11 Feb 2020  路  3Comments  路  Source: rrousselGit/freezed

Hi there! Your package looks very promising - we can't wait to replace built_value with it.

This is what I found out while trying the laaaatest version:

// main.dart
import 'package:flutter/foundation.dart';
import 'package:json_annotation/json_annotation.dart';

part 'model.freezed.dart';
part 'model.g.dart';

@immutable
abstract class Model with _$Model {
  factory Model({String a, List<Model> models}) = _Model;

  factory Model.fromJson(Map<String, dynamic> json) => _$ModelFromJson(json);
}

main() {
  var model = Model(
    a: 'hol',
    models: [
      Model(
        a: 'no',
        models: const [],
      ),
    ],
  );

  model.copyWith(a: 't'); // => no
}

In the last line copyWith is not accessible - I could, however, use _Model instead

bug

Most helpful comment

Oh, interesting.

I kinda know why. I'll fix it very soon

All 3 comments

Oh, interesting.

I kinda know why. I'll fix it very soon

Is this closed because it's solved? I have the same issue...

This is fixed, yes.

Was this page helpful?
0 / 5 - 0 ratings