Ced
Ced

Reputation: 17367

Writing null safe package for flutter

As of today, null safety isn't available on the stable channel for flutter.

However I would like to write a package that is null safe.

If I want people that don't opt-in null safety to use said package, do I need to maintain 2 versions of that package ? One with null safety and one without ? If so are there tools for automatically transpose from null safe code to old non null safe ?

Upvotes: 0

Views: 139

Answers (1)

Randal Schwartz
Randal Schwartz

Reputation: 44131

For now you're encouraged to submit it to pub with a pubspec requiring 2.12.0-259.9.beta as a minimum. The pub solver will note that it's out of reach for any non-null-safe dart, and ignore it. (pub outdated still reports it though.) More details at https://dart.dev/null-safety/migration-guide#version.

And yes, you'll have to publish two different versions (hopefully under different major numbers) until flutter stable includes 2.12 (actually, it might already... no, it's dart stable 2.10).

Upvotes: 1

Related Questions