File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
android/src/main/java/com/jiguang/jmessageflutter Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -414,6 +414,10 @@ static Message JsonToMessage(JSONObject json) {
414414 static HashMap toJson (Conversation conversation ) {
415415
416416 final HashMap json = new HashMap <String , Object >();
417+ if (null == conversation ){
418+ return json ;
419+ }
420+
417421 json .put ("title" , conversation .getTitle () != null ? conversation .getTitle () : "" );
418422 json .put ("unreadCount" , conversation .getUnReadMsgCnt ());
419423
Original file line number Diff line number Diff line change @@ -1003,7 +1003,7 @@ class _MyHomePageState extends State<MyHomePage> {
10031003 });
10041004
10051005 test ('getChatRoomConversation' , () async {
1006- JMConversationInfo conv =
1006+ JMConversationInfo ? conv =
10071007 await jmessage.getChatRoomConversation (roomId: kMockChatRoomid);
10081008 verifyConversation (conv);
10091009 });
@@ -1267,8 +1267,11 @@ void verifyGroupMember(JMGroupMemberInfo groupMember) {
12671267 verifyUser (groupMember.user);
12681268}
12691269
1270- void verifyConversation (JMConversationInfo conversation) {
1270+ void verifyConversation (JMConversationInfo ? conversation) {
12711271 expect (conversation, isNotNull, reason: 'conversation is null' );
1272+ if (null == conversation){
1273+ return ;
1274+ }
12721275 expect (conversation.conversationType, isNotNull,
12731276 reason: 'conversation conversationType is null' );
12741277 expect (conversation.title, isNotNull, reason: 'conversation title is null' );
Original file line number Diff line number Diff line change @@ -1508,12 +1508,14 @@ class JmessageFlutter {
15081508 return ;
15091509 }
15101510
1511- Future <JMConversationInfo > getChatRoomConversation ({
1511+ Future <JMConversationInfo ? > getChatRoomConversation ({
15121512 required String ? roomId,
15131513 }) async {
15141514 Map resJson = await _channel.invokeMethod ('getChatRoomConversation' ,
15151515 {'roomId' : roomId}..removeWhere ((key, value) => value == null ));
1516-
1516+ if (resJson == null || resJson.isEmpty){
1517+ return null ;
1518+ }
15171519 return JMConversationInfo .fromJson (resJson);
15181520 }
15191521
You can’t perform that action at this time.
0 commit comments