diff --git a/example/lib/src/rtm_api_demo.dart b/example/lib/src/rtm_api_demo.dart index 21c827d..3456c86 100644 --- a/example/lib/src/rtm_api_demo.dart +++ b/example/lib/src/rtm_api_demo.dart @@ -160,7 +160,7 @@ class _RtmApiDemoState extends State { await RTM(config.appId, _userIdController.text); if (status.error) { logSink.log( - '[error] operation: ${status.operation}, reason: ${status.reason}'); + '[error] errorCode: ${status.errorCode}, operation: ${status.operation}, reason: ${status.reason}'); return; } _rtmClient = client; @@ -264,11 +264,9 @@ class _RtmApiDemoState extends State { _button('RtmClient.unsubscribe', () async { final (status, result) = await _rtmClient.unsubscribe(_channelNameController.text); - if (status.error) { - return; - } + logSink.log( - '[UnsubscribeResult] channelName: ${result!.channelName}, errorCode: ${status.errorCode}'); + '[UnsubscribeResult] channelName: ${result?.channelName}, errorCode: ${status.errorCode}'); }), ], ), @@ -312,12 +310,9 @@ class _RtmApiDemoState extends State { recordUserId: _isSetChannelMetadataRecordUserId, lockName: _setChannelMetadataLockNameController.text, ); - if (status.error) { - return; - } logSink.log( - '[SetChannelMetadataResult] channelName: ${result!.channelName}, channelType: ${result.channelType}, errorCode: ${status.errorCode}'); + '[SetChannelMetadataResult] channelName: ${result?.channelName}, channelType: ${result?.channelType}, errorCode: ${status.errorCode}'); }), _button('RtmStorage.updateChannelMetadata', () async { final storage = _rtmClient.getStorage(); @@ -339,12 +334,8 @@ class _RtmApiDemoState extends State { lockName: _setChannelMetadataLockNameController.text, ); - if (status.error) { - return; - } - logSink.log( - '[UpdateChannelMetadataResult] channelName: ${result!.channelName}, channelType: ${result.channelType}, errorCode: ${status.errorCode}'); + '[UpdateChannelMetadataResult] channelName: ${result?.channelName}, channelType: ${result?.channelType}, errorCode: ${status.errorCode}'); }), _button('RtmStorage.removeChannelMetadata', () async { final storage = _rtmClient.getStorage(); @@ -360,23 +351,17 @@ class _RtmApiDemoState extends State { .toList(), lockName: _setChannelMetadataLockNameController.text, ); - if (status.error) { - return; - } logSink.log( - '[RemoveChannelMetadataResult] channelName: ${result!.channelName}, channelType: ${result.channelType}, errorCode: ${status.errorCode}'); + '[RemoveChannelMetadataResult] channelName: ${result?.channelName}, channelType: ${result?.channelType}, errorCode: ${status.errorCode}'); }), _button('RtmStorage.getChannelMetadata', () async { final storage = _rtmClient.getStorage(); final (status, result) = await storage.getChannelMetadata( _channelNameController.text, _rtmChannelType); - if (status.error) { - return; - } logSink.log( - '[GetChannelMetadataResult] channelName: ${result!.channelName}, channelType: ${result.channelType}, data: ${result.data.toJson()} errorCode: ${status.errorCode}'); + '[GetChannelMetadataResult] channelName: ${result?.channelName}, channelType: ${result?.channelType}, data: ${result?.data.toJson()} errorCode: ${status.errorCode}'); }), ], ), @@ -406,12 +391,9 @@ class _RtmApiDemoState extends State { includeUserId: _isWhoNowIncludeUserId, page: _isWhoNowPageController.text, ); - if (status.error) { - return; - } logSink.log( - '[WhoNowResult] userStateList: [${result!.userStateList.map((e) => e.toJson())}], nextPage: ${result.nextPage}, errorCode: ${status.errorCode}'); + '[WhoNowResult] userStateList: [${(result?.userStateList ?? []).map((e) => e.toJson())}], nextPage: ${result?.nextPage}, errorCode: ${status.errorCode}'); }), ], ),