Enhancing app reliability with Flutter null safety starts with one constraint: a Dart 3 toolchain will not build code that has not been migrated. Older Flutter apps that stayed on Dart 2 to avoid the work now hold every SDK, plugin and store requirement update behind that migration.
Facilities, EHS and property operations leads who own a field inspection app built in Flutter will find what the migration involves, the order to do it in, which crashes it removes and which runtime errors it can still leave behind.
How does Flutter null safety enhance app reliability?
Flutter null safety enhances app reliability by making the Dart compiler reject code that could read null where a value is required, so null reference crashes are caught at build time. Agnotic Technologies migrates older Flutter apps to sound null safety, then removes the runtime escapes that remain: the ! operator and unguarded late fields.
Running an older Flutter inspection app?
We migrate it to sound null safety and clear the runtime escapes that remain.
Dart's Dart 3 migration guide states that in Dart 3 null safety is built in and cannot be turned off. A package whose SDK constraint has a lower bound below 2.12 fails dependency resolution when dart pub get runs.
In practice an unmigrated app is frozen. It cannot take a new Flutter release, a plugin that requires Dart 3, or a fix that ships only in a newer SDK.
What changes when an app moves to sound null safety?
Types split into two kinds. A String can never hold null, a String? can, and the compiler makes you check a nullable value before you use it where a non-nullable one is expected.
- Non-nullable by default: a field declared as int must be given a value before anything reads it.
- Nullable on purpose: int? marks a value that may be missing, such as an optional meter reading.
- Flow analysis: after a check that x is not null, the compiler treats x as non-nullable inside that branch.
- Required named parameters: a widget constructor can mark a parameter required instead of relying on a runtime assert.
Soundness is where the reliability comes from. When every library in the app is migrated, a non-nullable type cannot be null at runtime, so each check the compiler asks for replaces a crash report you would otherwise have received from the field.
Which runtime errors can sound null safety still leave behind?
Sound null safety still leaves the errors developers opt into: the ! operator, late fields read too early, and data from outside Dart that does not match the declared types. The compiler trusts these points, so they need their own review.
Dart's guide to understanding null safety says the null assertion operator ! always throws if the value is null, and that reading a late field before it has been assigned throws an exception at runtime.
| Escape | Typical cause | Safer pattern |
|---|---|---|
| ! on a nullable value | Added during migration to silence an error | Check for null, use a default, or change the type |
| late field read too early | Value set after an async call in initState | Make it nullable, or set it in the constructor |
| JSON from an API or local store | A field the model says is required is missing | Parse into model classes that reject bad records |
| Platform channel results | Native code returns null on some devices | Treat the result as nullable and handle the gap |
How do you migrate an older Flutter app step by step?
Migrate in dependency order, from the packages your app relies on up to the app itself, and keep the app releasable at every step. Most of the work is reading code and deciding what may be missing, not running a tool.
The Dart team's archived migration guide says Dart 2.19 is the final release that supports null safety migration, including the dart migrate tool, and strongly recommends migrating the leaves of the dependency graph first.
- Step 1, inventory: list every package in pubspec.yaml and check whether a null-safe version exists for each one.
- Step 2, upgrade or replace: move each dependency to its null-safe version, and replace any package abandoned before it migrated.
- Step 3, migrate your own packages: shared model and API packages sit low in the graph, so they go before the app.
- Step 4, migrate the app: on a Dart 2.19 toolchain if you want the tool's suggestions, or by hand, file by file.
- Step 5, raise the SDK constraint: set a null-safe lower bound, then move to the current Flutter release.
- Step 6, audit the escapes: review every ! and late the migration introduced before the build reaches testers.
Agnotic reviews each suggestion rather than accepting the tool's output in bulk. A tool can only guess whether a value may be missing, while the person who knows the inspection workflow can say whether it ever is.
How should the data model handle values that may be missing?
The data model should state which values may be missing in real field use, and each field's type should follow from that. An inspection record with a skipped reading is a different case from one where the reading was never asked for.
- Required at creation: site id, inspector id and checklist version are non-nullable, because a record without them is not an inspection.
- Optional by design: photos, comments and follow-up dates are nullable, and the screen shows a clear empty state.
- Not known yet: a supervisor sign-off time is nullable until someone signs, rather than a late field that crashes if read early.
- From the server: a parse step turns JSON into these classes and rejects a record that lacks a required field, logging which field it was.
Keeping this decision inside the model classes stops nullable values leaking into every widget. Screens then receive data that has already been checked.
What about plugins and packages that never migrated?
A package with no null-safe release has to be replaced, forked or removed before the app can build on Dart 3. No setting lets unmigrated code run beside migrated code on a current toolchain.
- Replace: find a maintained package with the same capability, such as a barcode scanner or an offline storage layer, and adapt the calling code.
- Fork: if the package is small and its licence allows it, migrate it yourself and host it as a private dependency.
- Remove: some packages wrap a few lines of platform code that are simpler to write directly in the app.
Plan for this early. In older apps, abandoned packages are often the reason the migration kept slipping, and each replacement brings its own testing.
How do you test that the migration did not change behaviour?
Test the paths that handle missing data, because that is where the migration changed code. A migrated app that passes the happy path can still fail when an inspector skips a step or loses signal.
- Unit tests for model parsing: records with each optional field absent, and records missing a required field that must be rejected.
- Widget tests for empty states: a checklist item with no photo, an asset with no previous inspection date.
- Offline runs: start the app with no network and a partly synced local store, then reconnect and sync.
- Device runs on the oldest supported OS versions, since platform channel results are where unexpected nulls still appear.
- Crash reports compared by screen before and after the release, watching for null-related errors.
What are the common mistakes with Flutter null safety migration?
The common mistakes with Flutter null safety migration come from treating it as a syntax change. The compiler errors disappear, but nobody answered the questions about missing data.
- Adding ! everywhere to clear errors, which turns compile-time warnings back into runtime crashes.
- Marking fields late to avoid deciding whether they can be null, then reading them in a build method before they are set.
- Making every model field nullable, which pushes null checks into dozens of widgets.
- Migrating the app before its shared packages, so the same types get migrated twice in different ways.
- Skipping offline and partial-sync tests, which is where field apps meet the most missing data.
A worked example: a site inspection checklist
A field app lets inspectors walk a site, answer a checklist and attach photos. Before migration, the checklist item model has an answer field that is sometimes empty when a question is skipped.
The migration tool makes the field nullable, and an engineer adds ! where the summary screen totals the answers. On the next test run, the summary crashes for any inspection with a skipped question.
The fix is a decision, not syntax. A skipped answer is stored as an explicit not-answered state, the summary counts it separately, and the ! is removed. The crash is gone because the model now describes what actually happens on site.
What does a Flutter null safety migration mean for your build plan?
A null safety migration is a prerequisite for every later upgrade, so plan it as its own release with a feature freeze around it. Mixing it with new features makes any regression hard to trace.
- Start with the dependency inventory, because it decides how much replacement work exists.
- Agree which data may be missing with the people who use the app in the field.
- Plan a test pass on real devices and in offline conditions before the store release.
- Schedule the Flutter and plugin upgrades the migration makes possible as the following release, not the same one.
How does Agnotic migrate older Flutter apps?
Agnotic inventories the dependencies, migrates shared packages and then the app, reviews every ! and late the migration adds, and tests offline and partial-sync behaviour before release. We build and maintain field inspection apps for facilities and EHS teams, so the data decisions are made with the people who use them.
Ready to move an older Flutter app to Dart 3?
We plan the dependency work, migrate the code and test the missing-data paths.
Related reading on Agnotic
Flutter stacks, mobile architecture and engineering practice.


