Json_serializable.dart: Use Flutter 2.0 without sound null safety

Created on 4 Apr 2021  Â·  3Comments  Â·  Source: google/json_serializable.dart

Hi,
I'm working on an app on Flutter stable channel, and I'm currently on Flutter version 2.0.4. This app is not null-safe, as its development has started long before null-safety announcement.

I updated all libraries to be able to use Flutter 2.0, but I'm not intending to migrate to null-safety.

I found out that, on these premises, I cannot regenerate my serializable files (.g.dart files) as json_serializable incurs in the following error:

[SEVERE] json_serializable:json_serializable on lib/models/social/like_model.dart:

Generator cannot target libraries that have not been migrated to null-safety.
package:resmedia_manita_flutter/models/social/like_model.dart:6:7
  â•·
6 │ class LikeModel {
  │       ^^^^^^^^^
  ╵
[INFO] 13.1s elapsed, 108/114 actions completed.

I understand that retrocompatibility is a torture, but I think that this library should, as many others, be able to be used on latest Flutter without null-safety.

Here's the output of my flutter --version.

Flutter 2.0.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b1395592de (3 days ago) • 2021-04-01 14:25:01 -0700
Engine • revision 2dce47073a
Tools • Dart 2.12.2

All 3 comments

You can always use an old version of json_serializable. Set your constraint to ^3.0.0 and you should be good.

json_serializable

That is not always feasible: older versions of json_serializable are not compatible with other dependencies of the app.

I'm sorry, @emiliodallatorre – we have no plans to offer something in-the-middle here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fzyzcjy picture fzyzcjy  Â·  5Comments

HosseinArabbeigi picture HosseinArabbeigi  Â·  3Comments

FaisalAbid picture FaisalAbid  Â·  5Comments

4BooM04 picture 4BooM04  Â·  3Comments

kevmoo picture kevmoo  Â·  3Comments