0

Following the sample on the Dartson documentation page,

import 'package:dartson/dartson.dart';
import 'package:some_dependency/some_class.dart';

import 'my_class.dart';

@Serializer(
  entities: [
    MyClass,
    SomeClass,
  ],
)
final Dartson<Map<String, dynamic>> serializer = _serializer$dartson;

I'm getting undefined name _serializer$dartson.useCodec(json) and also wondering where _serializer is referenced from.

Yes, I have added the required dependencies to my pubspec.yaml.

dependencies:
  dartson: ^1.0.0-alpha+2

dev_dependencies:
  build_runner: ^0.10.0
Olantobi
  • 869
  • 1
  • 8
  • 16
  • It doesn't look like dartson is still maintained and it foesn't look Flutter compatible. Why are younot using json_serializable? – Günter Zöchbauer Dec 25 '18 at 18:47
  • There was still a commit to the project last month and they have a published road map. Anyway, i'll try out json_serializable. Thanks. – Olantobi Dec 25 '18 at 19:06

1 Answers1

0

The required dependency on build_runner indicates that a build step is needed. Depending on how Dartson define's its builders it may be enough to run pub run build_runner build (or for flutter, flutter packages pub run build_runner build.

You might want to file an issue on Dartson to make the build instructions more clear.

Nate Bosch
  • 10,145
  • 2
  • 26
  • 22