if (value == null) { // value is still nullable here }
instead you need to first capture the value
final value = this.value if (value == null) { // value is non-null }
Swift's guard and if let syntax seems way nicer here. In swift, it's also nice to destructure nested nullable values using if let.
if let value = object.object?.value { // value is non null }
In dart you'd need to first assign this into a local variable and then do the null check which is unnecessarily verbose.
if (value case final value?) { // value is a fresh final variable }
if let value = value { // a new binding named ‘value’ refers to value, unwrapped }
if let value { // a new binding named ‘value’ refers to value, unwrapped }
if let baz = foo.bar(42) { // a new binding named ‘baz’ refers to foo.bar(42), unwrapped } )
if (value == null) { // value is still nullable here }
instead you need to first capture the value
final value = this.value if (value == null) { // value is non-null }
Swift's guard and if let syntax seems way nicer here. In swift, it's also nice to destructure nested nullable values using if let.
if let value = object.object?.value { // value is non null }
In dart you'd need to first assign this into a local variable and then do the null check which is unnecessarily verbose.