eredo / dartson

Dartson is a Dart library that can be used to convert Dart objects into a JSON string.
MIT License
79 stars 29 forks source link

how to use with flutter? #38

Closed droundy closed 6 years ago

droundy commented 8 years ago

I'm new to dart and new to flutter, but I know that flutter doesn't work with mirrors, and that dartson doesn't require mirrors. However, I don't know how to use dartson with flutter. I get the following errors:

$ flutter build apk
Building APK in release mode (android-arm-release)...      
Dart snapshot generator failed with exit code 254
Errors encountered while loading: 'dart:mirrors': error: line 1 pos 1: unexpected token 'Unhandled'
Unhandled exception:
^
'package:dartson/dartson.dart': error: line 10 pos 1: library handler failed
import 'dart:mirrors';
^
'file:///home/droundy/src/student-pairs/lib/main.dart': error: line 5 pos 1: library handler failed
import 'package:dartson/dartson.dart';
^
Error: 'dart:mirrors': error: line 1 pos 1: unexpected token 'Unhandled'
Unhandled exception:
^
'package:dartson/dartson.dart': error: line 10 pos 1: library handler failed
import 'dart:mirrors';
^
'file:///home/droundy/src/student-pairs/lib/main.dart': error: line 5 pos 1: library handler failed
import 'package:dartson/dartson.dart';
^
Failed to build AOT snapshot

I expect that this is simple to manage, but am not sure how to tell flutter that I want the non-mirrors version of dartson.

Thanks!

eredo commented 7 years ago

There's currently no option to use dartson with flutter, because dartson relies on pub transformers in order to provide a static (no mirrors) way. Take a look at built_value and it's serialization implementation.

eredo commented 6 years ago

Will be taken in account for #48 . Just out of interest what was your solution / package for your project?