Fix bug in dartgen: The property 'isEmpty' can't be unconditionally accessed because the receiver can be 'null'

master
zhoumingji 2 years ago committed by Kevin Wan
parent 97ada59175
commit ba71964b16

@ -31,7 +31,7 @@ Future<Tokens> getTokens() async {
try { try {
var sp = await SharedPreferences.getInstance(); var sp = await SharedPreferences.getInstance();
var str = sp.getString('tokens'); var str = sp.getString('tokens');
if (str.isEmpty) { if (str == null || str.isEmpty) {
return null; return null;
} }
return Tokens.fromJson(jsonDecode(str)); return Tokens.fromJson(jsonDecode(str));
@ -65,7 +65,7 @@ Future<Tokens?> getTokens() async {
try { try {
var sp = await SharedPreferences.getInstance(); var sp = await SharedPreferences.getInstance();
var str = sp.getString('tokens'); var str = sp.getString('tokens');
if (str.isEmpty) { if (str == null || str.isEmpty) {
return null; return null;
} }
return Tokens.fromJson(jsonDecode(str)); return Tokens.fromJson(jsonDecode(str));

Loading…
Cancel
Save