Closed minhqdao closed 2 years ago
window.location.pathname is supposed to return a String?, which is why you would typically use it as:
window.location.pathname
String?
final isHome = window.location.pathname?.contains('home') ?? false;
If you do that, however, you will receive the following warning under macOS:
: Warning: Operand of null-aware operation '?.' has type 'String' which excludes null.
Seems like somewhere a String is returned, while a String? would be more appropriate. 🤔
String
There is same issue for window.location.origin
window.location.origin
window.location.pathname
is supposed to return aString?
, which is why you would typically use it as:final isHome = window.location.pathname?.contains('home') ?? false;
If you do that, however, you will receive the following warning under macOS:
: Warning: Operand of null-aware operation '?.' has type 'String' which excludes null.
Seems like somewhere a
String
is returned, while aString?
would be more appropriate. 🤔