From aaaadfb19db1648e2f4547b75ba2be7986867965 Mon Sep 17 00:00:00 2001 From: dignow Date: Thu, 22 Jun 2023 15:09:47 +0800 Subject: [PATCH] simple refact Signed-off-by: dignow --- flutter/lib/common/hbbs/hbbs.dart | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/flutter/lib/common/hbbs/hbbs.dart b/flutter/lib/common/hbbs/hbbs.dart index d1e44abc8..2ac72b3f8 100644 --- a/flutter/lib/common/hbbs/hbbs.dart +++ b/flutter/lib/common/hbbs/hbbs.dart @@ -101,13 +101,15 @@ class LoginRequest { Map toJson() { final Map data = {}; - data['username'] = username ?? ''; - data['password'] = password ?? ''; - data['id'] = id ?? ''; - data['uuid'] = uuid ?? ''; - data['trustThisDevice'] = trustThisDevice ?? ''; - data['type'] = type ?? ''; - data['verificationCode'] = verificationCode ?? ''; + if (username != null) data['username'] = username; + if (password != null) data['password'] = password; + if (id != null) data['id'] = id; + if (uuid != null) data['uuid'] = uuid; + if (trustThisDevice != null) data['trustThisDevice'] = trustThisDevice; + if (type != null) data['type'] = type; + if (verificationCode != null) { + data['verificationCode'] = verificationCode; + } data['deviceInfo'] = deviceInfo; return data; }