In a Dart class I have String? deviceName;. Inside a method, if (deviceName != null) { print(deviceName.length); } gives an error that the property cannot be accessed because the receiver can be null, although the same check works on a local variable. Adding ! fixes the compile error, but elsewhere in the app I then hit "Null check operator used on a null value" at runtime.
How do promotion, !, ?., ?? and late fit together, and what is the clean way to write this?




