Dart VM ↔ Flutter: Is null safety enforced when passing data into widget build methods?
0 reputation · 23 Oct 2022, 01:15 UTC
Dart VM ↔ Flutter: Null‑Safety Interop
When a null‑unsafe Dart library is imported into a null‑safe Flutter application, the compiler issues a warning but does not prevent the library’s methods from being called at runtime. The Flutter framework’s Widget.build method is invoked via dynamic dispatch, which may bypass the Dart VM’s static type checks. The goal is to determine whether null safety is preserved across this integration boundary.
Key constraints include the presence of a null‑unsafe library, a null‑safe Flutter widget tree, and the dynamic nature of widget build calls. Uncertainty remains about whether the VM’s runtime type checks are sufficient to catch null dereferences originating from the library when they reach widget build methods.
Questions for investigation:
- Does the Dart VM perform type checks on method calls that originate in null‑unsafe libraries and are invoked within Flutter’s widget build?
- If not, would a runtime guard be necessary to coerce null‑unsafe values into nullable types across the Dart VM ↔ Flutter boundary?
- What verification steps can confirm that null safety is maintained throughout the integration?