I am writing a test case for the null-aware operation '!', but not able to catch the exception.
Function:
int? notNullAssertionForException() {
String? country;
return country!.length;
}
Test:
test('Not Null Assertion For Exception Test', () {
final nullSafety = NullSafety();
expect(nullSafety.notNullAssertionForException(), null);
});
Error: Null check operator used on a null value
I am not able to figure out the way to test this. How I can pass this test?