flutter_mimc 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 76

客服系统开发者QQ交流群: 623661658

Flutter_mimc v 1.0.0 #

[English] - 中文

thank@Xiaomi MIMC team's contribution #

Make IM easy

features #

  • Single chat
  • Ordinary group chat
  • Infinite group chat
  • Live stream(Not yet implemented)

Use needs #

useflutter_mimc,It is recommended to read firstXiaomi instant message cloud official document, This helps you to use flutter_mimc

Install flutter_mimc #

import #

pubspec.yaml Add the following dependency to the file:

dependencies:
  flutter_mimc: ^${latestVersion}

initialization #

Use flutter_mimc Before, need to perform initialization:


    import 'package:flutter_mimc/flutter_mimc.dart';

     // The first(String generated by server authentication)recommend
     String tokenString = http.get(); // '{"code":200,"message":"success","data":{}}';
     FlutterMimc flutterMimc =  FlutterMimc.stringTokenInit(
          tokenString,
          debug: true,
     );
     
     // The Second(Write sensitive data on the client)
      FlutterMimc flutterMimc = FlutterMimc.init(
           debug: true,
           appId: "xxxxxxxx",
           appKey: "xxxxxxxx",
           appSecret: "xxxxxxxx",
           appAccount: "xxxxxxxx"
     );

    /// init push api
    mImcPush = MIMCPush(mImcAppId: "2882303761517669588", mImcAppKey: "5111766983588", mImcAppSecret: "b0L3IOz/9Ob809v8H2FbVg==");


Message body #

flutter_mimc Provide MIMCMessage model class

     MIMCMessage message = MIMCMessage();
     message.bizType = "bizType";      // Message type (developer custom)
     message.toAccount = "";           // Recipient account number (send single chat leave null)
     message.topicId = "";             // Specify the group ID to send (null when sending group chat)
     message.payload = "";             // Developer custom message body
 
     // Custom message body And Base64 encoding
     Map<String, dynamic> payloadMap = {
       "from_account": appAccount,
       "to_account": id,
       "biz_type": "text",
       "version": "0",
       "timestamp": DateTime.now().millisecondsSinceEpoch,
       "read": 0,
       "transfer_account": 0,
       "payload": content
     };

     // base64 Handling custom messages
     message.payload = base64Encode(utf8.encode(json.encode(payloadMap)));
     
     // Send a single chat
     var pid = await flutterMimc.sendMessage(message);
     
     // Send a normal group chat
     var gid = await flutterMimc.sendGroupMsg(message);
     
     // Send unlimited group chat
     var gid = flutterMimc.sendGroupMsg(message, isUnlimitedGroup: true);

Example documentation tips #

Some interface APIs are not shown in the examples below. You need to personally explore the complete demo code of the production test, or directly look at the source code. All the http interfaces in the official document have been packaged in the class library

example #


  FlutterMimc flutterMimc;
  final String appAccount = "100";         // My IM account
  String groupID = "21351198708203520";    // Ordinary group Account id
  String maxGroupID = "21360839299170304"; // Unlimited group Account id
  bool isOnline = false;
  List<Map<String, String>> logs = [];
  TextEditingController accountCtr = TextEditingController();
  TextEditingController contentCtr = TextEditingController();

  @override
  void initState() {
    super.initState();
    
    // init FlutterMimc
    initFlutterMimc();

  }

  // init
  void initFlutterMimc() async{
    flutterMimc = FlutterMimc.init(
      debug: true,
      appId: "xxxxxxxx",
      appKey: "xxxxxxxx",
      appSecret: "xxxxxxxx",
      appAccount: appAccount
    );
    addLog("init== init success ");
    listener();
  }

  // login
  void login() async{
    await flutterMimc.login();
  }

  // add log
  addLog(String content){
    print(content);
    logs.insert(0,{
      "date": DateTime.now().toIso8601String(),
      "content": content
    });
    setState(() {});
  }

  // logout
  void logout() async{
    await flutterMimc.logout();
  }

  ///  Send a single chat message or Send an online message
  /// [type] 0 Single 1 General group chat, 2 Infinite group, 3 online Single message
  void sendMessage(int type) async {
    String id = accountCtr.value.text;
    String content = contentCtr.value.text;

    if (id == null || id.isEmpty || content == null || content.isEmpty) {
      _scaffoldKey.currentState.showSnackBar(SnackBar(
        content: Text("id 或 content参数错误"),
        backgroundColor: Colors.pink,
      ));
      return;
    }

    // message body
    MIMCMessage message = MIMCMessage();
    message.bizType = "bizType";      // Message type (developer-defined)
    // message.toAccount = id;        // Receiver account (send a single chat to leave null)
    // message.topicId                // Specify the group ID to send (leave null when sending a group chat)

    // Custom message body
    Map<String, dynamic> payloadMap = {
      "from_account": appAccount,
      "to_account": id,
      "biz_type": "text",
      "version": "0",
      "timestamp": DateTime.now().millisecondsSinceEpoch,
      "read": 0,
      "transfer_account": 0,
      "payload": content
    };

    // base64 Custom message body
    message.payload = base64Encode(utf8.encode(json.encode(payloadMap)));

    if (type == 0) {
      /// Single caht
      message.toAccount = id;
      addLog("send to$id: $content");
      var pid = await flutterMimc.sendMessage(message);
      print("pid====$pid");
    } else if (type == 1) {
      /// General group chat
      message.topicId = int.parse(id);
      addLog("send group chat: $content");
      var gid = await flutterMimc.sendGroupMsg(message);
      print("gid====$gid");
    } else if (type == 2) {
      /// Infinite group
      message.topicId = int.parse(id);
      addLog("send Infinite group chat: $content");
      flutterMimc.sendGroupMsg(message, isUnlimitedGroup: true);
    } else if (type == 3) {
      /// online message
      message.toAccount = id;
      addLog("send online message: $content");
      flutterMimc.sendOnlineMessage(message);
    }
    print(json.encode(message.toJson()));
    contentCtr.clear();
  }

  // get token
  void getToken() async{
    String token = await flutterMimc.getToken();
    addLog("Get token successfully:$token");
  }

  // Get current account
  void getAccount() async{
    String account = await flutterMimc.getAccount();
    addLog("Get current account successfully:$account");
  }

  // Get current status
  void getStatus() async{
    bool isOnline =  await flutterMimc.isOnline();
    addLog("Get current status:${isOnline ? 'Online' :'Offline'}");
  }

  // Create a group
  void createGroup() async{
    var res = await flutterMimc.createGroup("ios_group_name", appAccount);
    if (res.code == 200) {
      groupID = res.data['topicInfo']['topicId'];
      addLog("success ${res.toJson()}");
    } else {
      addLog("error :${res.message}");
    }
    accountCtr.text = groupID;
    setState(() {});
  }

  // query group
  void queryGroupInfo() async {
    var res = await flutterMimc.queryGroupInfo(groupID);
    if (res.code == 200) {
      groupID = res.data['topicInfo']['topicId'];
      addLog("success :${res.toJson()}");
    } else {
      addLog("error :${res.message}");
    }
  }

  // Querying Group Information
  void queryGroupsOfAccount() async {
    var res = await flutterMimc.queryGroupsOfAccount();
    if (res.code == 200) {
      addLog("success${res.toJson()}");
    } else {
      addLog("error:${res.message}");
    }
  }

  // Inviting users to join a group
  void joinGroup() async {
    var res =
        await flutterMimc.joinGroup(topicId: groupID, accounts: "101,102,103");
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error :${res.message}");
    }
  }

  // Non-group owner users leave the group
  void quitGroup() async {
    var res = await flutterMimc.quitGroup(groupID);
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error :${res.message}");
    }
  }

  // Group leader kicks members out of the group
  void kickGroup() async {
    var res = await flutterMimc.kickGroup(groupID, "101,102,103");
    if (res.code == 200) {
      addLog("success${res.toJson()}");
    } else {
      addLog("error :${res.message}");
    }
  }

  // Group owner updates group information
  void updateGroup() async {
    var res =
        await flutterMimc.updateGroup(topicId: groupID, topicName: "newName");
    if (res.code == 200) {
      addLog("success :${res.toJson()}");
    } else {
      addLog("error ${res.message}");
    }
  }

  // Group owner destroys group
  void dismissGroup() async {
    var res = await flutterMimc.dismissGroup(groupID);
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error :${res.message}");
    }
  }

  // Pull single chat message records (including multiple versions of the interface)
  void pullP2PHistory() async {
    int thisTimer = DateTime.now().millisecondsSinceEpoch;
    String fromAccount = appAccount;
    String toAccount = "101";
    String utcFromTime = (thisTimer - 85400000).toString();
    String utcToTime = thisTimer.toString();
    var res = await flutterMimc.pullP2PHistory(PullHistoryType.queryOnCount,
        toAccount: toAccount,
        fromAccount: fromAccount,
        utcFromTime: utcFromTime,
        utcToTime: utcToTime);
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error :${res.message}");
    }
  }

  // Pull group chat message records (including multiple versions of the interface)
  void pullP2THistory() async {
    int thisTimer = DateTime.now().millisecondsSinceEpoch;
    String account = appAccount;
    String topicId = groupID;
    String utcFromTime = (thisTimer - 86400000).toString();
    String utcToTime = thisTimer.toString();
    var res = await flutterMimc.pullP2THistory(PullHistoryType.queryOnCount,
        account: account,
        topicId: topicId,
        utcFromTime: utcFromTime,
        utcToTime: utcToTime);
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error :${res.message}");
    }
  }

  // Pull an infinitely large group of message records (including multiple versions of the interface)
  void pullP2UHistory() async {
    int thisTimer = DateTime.now().millisecondsSinceEpoch;
    String account = appAccount;
    String topicId = maxGroupID;
    String utcFromTime = (thisTimer - 86400000).toString();
    String utcToTime = thisTimer.toString();
    var res = await flutterMimc.pullP2UHistory(PullHistoryType.queryOnCount,
        account: account,
        topicId: topicId,
        utcFromTime: utcFromTime,
        utcToTime: utcToTime);
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error :${res.message}");
    }
  }

  // delete Unlimited Group
  void deleteUnlimitedGroup() async {
    var res = await flutterMimc.deleteUnlimitedGroup(topicId: maxGroupID);
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error :${res.message}");
    }
  }

  // create Unlimited Group
  void createUnlimitedGroup() async {
    var res =
        await flutterMimc.createUnlimitedGroup(topicName: "fuck group", extra: "");
    if (res.code == 200) {
      maxGroupID = res.data['topicId'];
      addLog("success ${res.toJson()}");
    } else {
      addLog("error :${res.message}");
    }
  }

  // join Unlimited Group
  void joinUnlimitedGroup() async {
    await flutterMimc.joinUnlimitedGroup("21395272047788032");
    addLog("join Unlimited Group $maxGroupID");
  }

  // quit Unlimited Group
  void quitUnlimitedGroup() async {
    await flutterMimc.quitUnlimitedGroup("21395272047788032");
    addLog("quit Unlimited Group $maxGroupID");
  }

  // dismiss Unlimited Group
  void dismissUnlimitedGroup() async {
    await flutterMimc.dismissUnlimitedGroup(maxGroupID);
    addLog("dismiss Unlimited Group $maxGroupID");
  }

  // query Unlimited Group Members
  void queryUnlimitedGroupMembers() async {
    var res = await flutterMimc.queryUnlimitedGroupMembers(topicId: maxGroupID);
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error :${res.message}");
    }
  }

  // query Unlimited Groups
  void queryUnlimitedGroups() async {
    var res = await flutterMimc.queryUnlimitedGroups();
    if (res.code == 200) {
      addLog("success${res.toJson()}");
    } else {
      addLog("error:${res.message}");
    }
  }

  // query Unlimited Group Online Users
  void queryUnlimitedGroupOnlineUsers() async {
    var res = await flutterMimc.queryUnlimitedGroupOnlineUsers(maxGroupID);
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error: ${res.message}");
    }
  }

  // query Unlimited GroupInfo
  void queryUnlimitedGroupInfo() async {
    var res = await flutterMimc.queryUnlimitedGroupInfo(maxGroupID);
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error: ${res.message}");
    }
  }

  // update Unlimited Group
  void updateUnlimitedGroup() async {
    var res = await flutterMimc.updateUnlimitedGroup(
        topicId: maxGroupID, topicName: "新大群名称1");
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error: ${res.message}");
    }
  }

  // get Contact
  void getContact() async {
    var res = await flutterMimc.getContact(isV2: true);
   if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error:${res.message}");
    }

  // set BlackList
  void setBlackList() async {
    var res = await flutterMimc.setBlackList("200");
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error: ${res.message}");
    }
  }

  // delete BlackList
  void deleteBlackList() async {
    var res = await flutterMimc.deleteBlackList("200");
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error: ${res.message}");
    }
  }

  // has BlackList
  void hasBlackList() async {
    var res = await flutterMimc.hasBlackList("200");
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error: ${res.message}");
    }
  }

  // set GroupBlackList
  void setGroupBlackList() async {
    var res = await flutterMimc.setGroupBlackList(
        blackTopicId: "21351198708203520", blackAccount: "102");
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error: ${res.message}");
    }
  }

  // delete GroupBlackList
  void deleteGroupBlackList() async {
    var res = await flutterMimc.deleteGroupBlackList(
        blackTopicId: "21351198708203520", blackAccount: "102");
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error: ${res.message}");
    }
  }

  // has GroupBlackList
  void hasGroupBlackList() async {
    var res = await flutterMimc.hasGroupBlackList(
        blackTopicId: "21351198708203520", blackAccount: "102");
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error: ${res.message}");
    }
  }

  // push P2PMessage
  void pushP2PMessage() async{
    var res = await mImcPush.pushP2PMessage(
      fromAccount: "100",
      toAccount: "101",
      msg: "data",
      fromResource: "keith");
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error:${res.message}");
    }
  }

  // push P2PMoreMessage
  void pushP2PMoreMessage() async{
    var res = await mImcPush.pushP2PMoreMessage(
      fromAccount: "100",
      toAccounts: ["101","102"],
      msg: "data",
      fromResource: "keith"
    );
    if (res.code == 200) {
      addLog("success ${res.toJson()}");
    } else {
      addLog("error: ${res.message}");
    }
  }

  // push P2TMessage
  void pushP2TMessage() async{
    var res = await mImcPush.pushP2TMessage(
        fromAccount: "100",
        topicId: "21351235479666688",
        msg: "data",
        fromResource: "keith"
    );
    if (res.code == 200) {
      addLog("success${res.toJson()}");
    } else {
      addLog("error:${res.message}");
    }
  }

  // push P2TMoreMessage
  void pushP2TMoreMessage() async{
    var res = await mImcPush.pushP2TMoreMessage(
        fromAccount: "100",
        topicIds: ["21351235479666688", "21351318392668160"],
        msg: "data",
        fromResource: "keith"
    );
    if (res.code == 200) {
      addLog("success${res.toJson()}");
    } else {
      addLog("error:${res.message}");
    }
  }

  // pushP2UMessage
  void pushP2UMessage() async{
    var res = await mImcPush.pushP2UMessage(
        fromAccount: "100",
        topicId: "21361055926583296",
        message: "data",
        fromResource: "keith"
    );
    if (res.code == 200) {
      addLog("success${res.toJson()}");
    } else {
      addLog("error:${res.message}");
    }
  }

  // pushP2UMoreMessage
  void pushP2UMoreMessage() async{
    var res = await mImcPush.pushP2UMoreMessage(
        fromAccount: "100",
        topicId: "21361055926583296",
        messages: ["data","data1"],
        fromResource: "keith"
    );
    if (res.code == 200) {
      addLog("success${res.toJson()}");
    } else {
      addLog("error:${res.message}");
    }
  }

  // push MultiTopic Message
  void pushMultiTopicMessage() async{
    var res = await mImcPush.pushMultiTopicMessage(
        fromAccount: "100",
        topicIds: ["21361055926583296"],
        message: "data",
        fromResource: "keith"
    );
    if (res.code == 200) {
      addLog("success${res.toJson()}");
    } else {
      addLog("error:${res.message}");
    }
  }

  // listener
  void listener() {
    // listener onlone status
    flutterMimc.addEventListenerStatusChanged().listen((status) {
      isOnline = status;
      if (status) {
        addLog("$appAccount====status====online");
      } else {
        addLog("$appAccount====status====offlone");
      }
      setState(() {});
    }).onError((err) {
      addLog(err);
    });

    // receive Single chat
    flutterMimc.addEventListenerHandleMessage().listen((MIMCMessage message) {
      String content = utf8.decode(base64.decode(message.payload));
      addLog("receive${message.fromAccount} message: $content");
      setState(() {});
    }).onError((err) {
      addLog(err);
    });

    // receive group chat
    flutterMimc
        .addEventListenerHandleGroupMessage()
        .listen((MIMCMessage message) {
      String content = utf8.decode(base64.decode(message.payload));
      addLog("receive group${message.topicId}message: $content");
      setState(() {});
    }).onError((err) {
      addLog(err);
    });

    // Send message callback
    flutterMimc.addEventListenerServerAck().listen((MimcServeraAck ack) {
      addLog("Send message callback==${ack.toJson()}");
    }).onError((err) {
      addLog(err);
    });

    // Send online message callback
    flutterMimc.addEventListenerOnlineMessageAck().listen((MimcServeraAck ack) {
      addLog("Send online message callback==${ack.toJson()}");
    }).onError((err) {
      addLog(err);
    });

    // Send single chat timeout
    flutterMimc
        .addEventListenerSendMessageTimeout()
        .listen((MIMCMessage message) {
      addLog("Send single chat timeout==${message.toJson()}");
    }).onError((err) {
      addLog(err);
    });

    // Send group chat timeout
    flutterMimc
        .addEventListenerSendGroupMessageTimeout()
        .listen((MIMCMessage message) {
      addLog("Send group chat timeout==${message.toJson()}");
    }).onError((err) {
      addLog(err);
    });

    // Send unlimited group chat timeout
    flutterMimc
        .addEventListenerSendUnlimitedGroupMessageTimeout()
        .listen((MIMCMessage message) {
      addLog("Send unlimited group chat timeout==${message.toJson()}");
    }).onError((err) {
      addLog(err);
    });

    // Create large group callbacks
    flutterMimc
        .addEventListenerHandleCreateUnlimitedGroup()
        .listen((Map<dynamic, dynamic> res) {
      addLog("Create large group callbacks==$res");
      maxGroupID = (res['topicId'] as int).toString();
    }).onError((err) {
      addLog(err);
    });

    // Join large group callback
    flutterMimc
        .addEventListenerHandleJoinUnlimitedGroup()
        .listen((Map<dynamic, dynamic> res) {
      addLog("Join large group callback==$res");
    }).onError((err) {
      addLog(err);
    });

    // Exit large group callback
    flutterMimc
        .addEventListenerHandleQuitUnlimitedGroup()
        .listen((Map<dynamic, dynamic> res) {
      addLog("Exit large group callback==$res");
    }).onError((err) {
      addLog(err);
    });

    // Disbanding large groups of callbacks
    flutterMimc
        .addEventListenerHandleDismissUnlimitedGroup()
        .listen((Map<dynamic, dynamic> res) {
      addLog("Disbanding large groups of callbacks==$res");
    }).onError((err) {
      addLog(err);
    });

    // Receive online message
    flutterMimc.addEventListenerOnlineMessage().listen((msg) {
      addLog("message==${msg.toJson()}");
    }).onError((err) {
      addLog(err);
    });

    // Receive and send online message callback
    flutterMimc.addEventListenerOnlineMessageAck().listen((ack) {
      addLog("Receive and send online message callback==${ack.toJson()}");
    }).onError((err) {
      addLog(err);
    });




LICENSE #

Copyright 2019 keith

Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements.  See the NOTICE file distributed with this work for
additional information regarding copyright ownership.  The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License.  You may obtain a copy of
the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
License for the specific language governing permissions and limitations under
the License.

1.0.1 #

  • format file
  • update version code
  • remove Unused import: '../services/enums.dart'.

1.0.0 #

  • This version tries a major update. The SDK update of Xiaomi Messaging Cloud and the addition of corresponding new features require flutter SDK 1.12.13.
  • Update MIMC SDK to the latest version
  • Add online message interface
  • Remove the underlying http library and encapsulate the http interface in the upper and upper layers
  • Add push message library
  • Add and delete infinite group interface
  • Purify sdk reduce volume

0.1.0 #

  • Add blacklist api
  • Add get contact list API
  • Add string token init func
  • Fix IOS import AFNetworking error

0.0.3+3 #

  • update api documentation

0.0.3+2 #

  • update api documentation

0.0.3+1 #

  • 1.Update README.md
  • 2.Fix BUG

0.0.3 #

  • Restore the message body, no restrictions, there is a misunderstanding before this has been fixed
  • Fix service ID returned by Android sending message is null
  • Update README.md

0.0.2 #

  • Delete the Android local JSON static library to avoid conflicts and compile

0.0.1 #

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_mimc/flutter_mimc.dart';
import 'dart:convert';

void main() => runApp(MaterialApp(home: MyApp()));

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  FlutterMIMC flutterMimc;
  MIMCPush mImcPush;
  final String appAccount = "100"; // 我的账号
  String groupID = "21351198708203520"; // 操作的普通群ID
  String maxGroupID = "21360844399443968"; // 操作的无限通群ID
  bool isOnline = false;
  List<Map<String, String>> logs = [];
  TextEditingController accountCtr = TextEditingController();
  TextEditingController contentCtr = TextEditingController();
  final _scaffoldKey = GlobalKey<ScaffoldState>();

  @override
  void initState() {
    super.initState();

    // 初始化 FlutterMIMC
    initFlutterMIMC();
  }

  // 初始化
  void initFlutterMIMC() async {
    // token String init
//    String tokenString = '{"code":200,"message":"success","data":{}}';
//    flutterMimc =  FlutterMIMC.stringTokenInit(tokenString, debug: true);

    // const data init
    flutterMimc = FlutterMIMC.init(
        debug: true,
        appId: "2882303761517669588",
        appKey: "5111766983588",
        appSecret: "b0L3IOz/9Ob809v8H2FbVg==",
        appAccount: appAccount);
    addLog("init==实例化完成");
    listener();

    /// 实例化推送消息接口
    mImcPush = MIMCPush(mImcAppId: "2882303761517669588", mImcAppKey: "5111766983588", mImcAppSecret: "b0L3IOz/9Ob809v8H2FbVg==");

  }

  // 登录
  void login() async {
    await flutterMimc.login();
  }

  // add log
  addLog(String content) {
    debugPrint(content);
    logs.insert(
        0, {"date": DateTime.now().toIso8601String(), "content": content});
    setState(() {});
  }

  // 退出登录
  void logout() async {
    await flutterMimc.logout();
  }

  ///  发送单聊消息 或 发送在线消息
  /// [type] 0 单聊, 1 普通群聊, 2 无限大群, 3 在线消息
  void sendMessage(int type) async {
    String id = accountCtr.value.text;
    String content = contentCtr.value.text;

    if (id == null || id.isEmpty || content == null || content.isEmpty) {
      _scaffoldKey.currentState.showSnackBar(SnackBar(
        content: Text("id 或 content参数错误"),
        backgroundColor: Colors.pink,
      ));
      return;
    }

    // 消息
    MIMCMessage message = MIMCMessage();
    message.bizType = "bizType"; // 消息类型(开发者自定义)
    // message.toAccount = id;        // 接收者账号(发送单聊留null)
    // message.topicId                // 指定发送的群ID(发送群聊时留null)

    // 自定义消息体
    Map<String, dynamic> payloadMap = {
      "from_account": appAccount,
      "to_account": id,
      "biz_type": "text",
      "version": "0",
      "timestamp": DateTime.now().millisecondsSinceEpoch,
      "read": 0,
      "transfer_account": 0,
      "payload": content
    };

    // base64处理自定义消息
    message.payload = base64Encode(utf8.encode(json.encode(payloadMap)));

    if (type == 0) {
      /// 单聊消息
      message.toAccount = id;
      addLog("发送给$id: $content");
      var pid = await flutterMimc.sendMessage(message);
      print("pid====$pid");
    } else if (type == 1) {
      /// 普通群消息
      message.topicId = int.parse(id);
      addLog("发送普通群消息: $content");
      var gid = await flutterMimc.sendGroupMsg(message);
      print("gid====$gid");
    } else if (type == 2) {
      /// 无限群消息
      message.topicId = int.parse(id);
      addLog("发送无限群消息: $content");
      flutterMimc.sendGroupMsg(message, isUnlimitedGroup: true);
    } else if (type == 3) {
      /// 在线消息
      message.toAccount = id;
      addLog("发送在线消息: $content");
      flutterMimc.sendOnlineMessage(message);
    }
    print(json.encode(message.toJson()));
    contentCtr.clear();
  }

  // 获取token
  void getToken() async {
    String token = await flutterMimc.getToken();
    addLog("获取token成功:$token");
  }

  // 获取当前账号
  void getAccount() async {
    String account = await flutterMimc.getAccount();
    addLog("获取当前账号成功:$account");
  }

  // 获取当前状态
  void getStatus() async {
    bool isOnline = await flutterMimc.isOnline();
    addLog("获取当前状态:${isOnline ? '在线' : '离线'}");
  }

  // 创建一个群
  void createGroup() async {
    MIMCResponse res = await flutterMimc.createGroup(
        topicName: "ios群", accounts: appAccount, extra: "");
    if (res.code == 200) {
      groupID = res.data['topicInfo']['topicId'];
      addLog("创建群成功:${res.toJson()}");
    } else {
      addLog("创建群失败:${res.message}");
    }
    accountCtr.text = groupID;
    setState(() {});
  }

  // 查询群
  void queryGroupInfo() async {
    var res = await flutterMimc.queryGroupInfo(groupID);
    if (res.code == 200) {
      groupID = res.data['topicInfo']['topicId'];
      addLog("查询群成功:${res.toJson()}");
    } else {
      addLog("查询群失败:${res.message}");
    }
  }

  // 查询所属群信息
  void queryGroupsOfAccount() async {
    var res = await flutterMimc.queryGroupsOfAccount();
    if (res.code == 200) {
      addLog("查询所属群成功:${res.toJson()}");
    } else {
      addLog("查询所属群失败:${res.message}");
    }
  }

  // 邀请用户加入群
  void joinGroup() async {
    var res =
        await flutterMimc.joinGroup(topicId: groupID, accounts: "101,102,103");
    if (res.code == 200) {
      addLog("邀请用户加入群执行成功:${res.toJson()}");
    } else {
      addLog("邀请用户加入群执行失败:${res.message}");
    }
  }

  // 非群主用户退群
  void quitGroup() async {
    var res = await flutterMimc.quitGroup(groupID);
    if (res.code == 200) {
      addLog("非群主用户退群执行成功:${res.toJson()}");
    } else {
      addLog("非群主用户退群执行失败:${res.message}");
    }
  }

  // 群主踢成员出群
  void kickGroup() async {
    var res = await flutterMimc.kickGroup(groupID, "101,102,103");
    if (res.code == 200) {
      addLog("群主踢成员出群执行成功:${res.toJson()}");
    } else {
      addLog("群主踢成员出群执行失败:${res.message}");
    }
  }

  // 群主更新群信息
  void updateGroup() async {
    var res =
        await flutterMimc.updateGroup(topicId: groupID, topicName: "newName");
    if (res.code == 200) {
      addLog("群主更新群信息执行成功:${res.toJson()}");
    } else {
      addLog("群主更新群信息执行失败:${res.message}");
    }
  }

  // 群主销毁群
  void dismissGroup() async {
    var res = await flutterMimc.dismissGroup(groupID);
    if (res.code == 200) {
      addLog("群主销毁群执行成功:${res.toJson()}");
    } else {
      addLog("群主销毁群执行失败:${res.message}");
    }
  }

  // 拉取单聊消息记录(包含多个版本的接口)
  void pullP2PHistory() async {
    int thisTimer = DateTime.now().millisecondsSinceEpoch;
    String fromAccount = appAccount;
    String toAccount = "101";
    String utcFromTime = (thisTimer - 85400000).toString();
    String utcToTime = thisTimer.toString();
    var res = await flutterMimc.pullP2PHistory(PullHistoryType.queryOnCount,
        toAccount: toAccount,
        fromAccount: fromAccount,
        utcFromTime: utcFromTime,
        utcToTime: utcToTime);
    if (res.code == 200) {
      addLog("单聊消息记录执行成功:${res.toJson()}");
    } else {
      addLog("单聊消息记录执行失败:${res.message}");
    }
  }

  // 拉取群聊消息记录(包含多个版本的接口)
  void pullP2THistory() async {
    int thisTimer = DateTime.now().millisecondsSinceEpoch;
    String account = appAccount;
    String topicId = groupID;
    String utcFromTime = (thisTimer - 86400000).toString();
    String utcToTime = thisTimer.toString();
    var res = await flutterMimc.pullP2THistory(PullHistoryType.queryOnCount,
        account: account,
        topicId: topicId,
        utcFromTime: utcFromTime,
        utcToTime: utcToTime);
    if (res.code == 200) {
      addLog("群聊消息记录执行成功:${res.toJson()}");
    } else {
      addLog("群聊消息记录执行失败:${res.message}");
    }
  }

  // 拉取无限大群消息记录(包含多个版本的接口)
  void pullP2UHistory() async {
    int thisTimer = DateTime.now().millisecondsSinceEpoch;
    String account = appAccount;
    String topicId = maxGroupID;
    String utcFromTime = (thisTimer - 86400000).toString();
    String utcToTime = thisTimer.toString();
    var res = await flutterMimc.pullP2UHistory(PullHistoryType.queryOnCount,
        account: account,
        topicId: topicId,
        utcFromTime: utcFromTime,
        utcToTime: utcToTime);
    if (res.code == 200) {
      addLog("无限群聊消息记录执行成功:${res.toJson()}");
    } else {
      addLog("无限群聊消息记录执行失败:${res.message}");
    }
  }

  // 删除无限大群
  void deleteUnlimitedGroup() async {
    var res = await flutterMimc.deleteUnlimitedGroup(topicId: maxGroupID);
    if (res.code == 200) {
      addLog("删除无限大群成功:${res.toJson()}");
    } else {
      addLog("删除无限大群失败:${res.message}");
    }
  }

  // 创建无限大群
  void createUnlimitedGroup() async {
    var res =
        await flutterMimc.createUnlimitedGroup(topicName: "创建无限大群", extra: "");
    if (res.code == 200) {
      maxGroupID = res.data['topicId'];
      addLog("创建无限大群成功:${res.toJson()}");
    } else {
      addLog("创建无限大群失败:${res.message}");
    }
  }

  // 加入无限大群
  void joinUnlimitedGroup() async {
    await flutterMimc.joinUnlimitedGroup("21395272047788032");
    addLog("加入无限大群$maxGroupID");
  }

  // 退出无限大群
  void quitUnlimitedGroup() async {
    await flutterMimc.quitUnlimitedGroup("21395272047788032");
    addLog("退出无限大群$maxGroupID");
  }

  // 解散无限大群
  void dismissUnlimitedGroup() async {
    await flutterMimc.dismissUnlimitedGroup(maxGroupID);
    addLog("解散无限大群$maxGroupID");
  }

  // 查询无限大群成员
  void queryUnlimitedGroupMembers() async {
    var res = await flutterMimc.queryUnlimitedGroupMembers(topicId: maxGroupID);
    if (res.code == 200) {
      addLog("查询无限大群成员成功:${res.toJson()}");
    } else {
      addLog("查询无限大群成员失败:${res.message}");
    }
  }

  // 查询无限大群
  void queryUnlimitedGroups() async {
    var res = await flutterMimc.queryUnlimitedGroups();
    if (res.code == 200) {
      addLog("我所在的大群成功:${res.toJson()}");
    } else {
      addLog("我所在的大群失败:${res.message}");
    }
  }

  // 查询无限大群在线用户数
  void queryUnlimitedGroupOnlineUsers() async {
    var res = await flutterMimc.queryUnlimitedGroupOnlineUsers(maxGroupID);
    if (res.code == 200) {
      addLog("查询无限大群在线用户数成功:${res.toJson()}");
    } else {
      addLog("查询无限大群在线用户数失败:${res.message}");
    }
  }

  // 查询无限大群基本信息
  void queryUnlimitedGroupInfo() async {
    var res = await flutterMimc.queryUnlimitedGroupInfo(maxGroupID);
    if (res.code == 200) {
      addLog("查询无限大群基本信息成功:${res.toJson()}");
    } else {
      addLog("查询无限大群基本信息失败:${res.message}");
    }
  }

  // 更新大群基本信息
  void updateUnlimitedGroup() async {
    var res = await flutterMimc.updateUnlimitedGroup(
        topicId: maxGroupID, topicName: "新大群名称1");
    if (res.code == 200) {
      addLog("更新大群基本信息成功:${res.toJson()}");
    } else {
      addLog("更新大群基本信息失败:${res.message}");
    }
  }

  // 获取最近会话列表
  void getContact() async {
    var res = await flutterMimc.getContact(isV2: true);
    if (res.code == 200) {
      addLog("获取最近会话列表成功:${res.toJson()}");
    } else {
      addLog("获取最近会话列表失败:${res.message}");
    }
  }

  // 拉黑对方
  void setBlackList() async {
    var res = await flutterMimc.setBlackList("200");
    if (res.code == 200) {
      addLog("拉黑对方成功:${res.toJson()}");
    } else {
      addLog("拉黑对方失败:${res.message}");
    }
  }

  // 取消拉黑对方
  void deleteBlackList() async {
    var res = await flutterMimc.deleteBlackList("200");
    if (res.code == 200) {
      addLog("取消拉黑对方成功:${res.toJson()}");
    } else {
      addLog("取消拉黑对方失败:${res.message}");
    }
  }

  // 判断账号是否被拉黑
  void hasBlackList() async {
    var res = await flutterMimc.hasBlackList("200");
    if (res.code == 200) {
      addLog("判断账号是否被拉黑成功:${res.toJson()}");
    } else {
      addLog("判断账号是否被拉黑失败:${res.message}");
    }
  }

  // 普通群拉黑成员
  void setGroupBlackList() async {
    var res = await flutterMimc.setGroupBlackList(
        blackTopicId: "21351198708203520", blackAccount: "102");
    if (res.code == 200) {
      addLog("普通群拉黑成员成功:${res.toJson()}");
    } else {
      addLog("普通群拉黑成员失败:${res.message}");
    }
  }

  // 普通群取消拉黑成员
  void deleteGroupBlackList() async {
    var res = await flutterMimc.deleteGroupBlackList(
        blackTopicId: "21351198708203520", blackAccount: "102");
    if (res.code == 200) {
      addLog("普通群取消拉黑成员成功:${res.toJson()}");
    } else {
      addLog("普通群取消拉黑成员失败:${res.message}");
    }
  }

  // 判断账号是否被普通群拉黑
  void hasGroupBlackList() async {
    var res = await flutterMimc.hasGroupBlackList(
        blackTopicId: "21351198708203520", blackAccount: "102");
    if (res.code == 200) {
      addLog("判断账号是否被普通群拉黑成功:${res.toJson()}");
    } else {
      addLog("判断账号是否被普通群拉黑失败:${res.message}");
    }
  }

  // 推送单聊信息
  void pushP2PMessage() async{
    var res = await mImcPush.pushP2PMessage(
      fromAccount: "100",
      toAccount: "101",
      msg: "data",
      fromResource: "keith");
    if (res.code == 200) {
      addLog("推送单聊信息成功:${res.toJson()}");
    } else {
      addLog("推送单聊信息失败:${res.message}");
    }
  }

  // 批量推送单聊信息
  void pushP2PMoreMessage() async{
    var res = await mImcPush.pushP2PMoreMessage(
      fromAccount: "100",
      toAccounts: ["101","102"],
      msg: "data",
      fromResource: "keith"
    );
    if (res.code == 200) {
      addLog("批量推送单聊信息成功:${res.toJson()}");
    } else {
      addLog("批量推送单聊信息失败:${res.message}");
    }
  }

  // 推送群聊信息
  void pushP2TMessage() async{
    var res = await mImcPush.pushP2TMessage(
        fromAccount: "100",
        topicId: "21351235479666688",
        msg: "data",
        fromResource: "keith"
    );
    if (res.code == 200) {
      addLog("推送群聊信息成功:${res.toJson()}");
    } else {
      addLog("推送群聊信息失败:${res.message}");
    }
  }

  // 批量推送群聊信息
  void pushP2TMoreMessage() async{
    var res = await mImcPush.pushP2TMoreMessage(
        fromAccount: "100",
        topicIds: ["21351235479666688", "21351318392668160"],
        msg: "data",
        fromResource: "keith"
    );
    if (res.code == 200) {
      addLog("批量推送群聊信息成功:${res.toJson()}");
    } else {
      addLog("批量推送群聊信息失败:${res.message}");
    }
  }

  // 单条推送无限群聊消息
  void pushP2UMessage() async{
    var res = await mImcPush.pushP2UMessage(
        fromAccount: "100",
        topicId: "21361055926583296",
        message: "data",
        fromResource: "keith"
    );
    if (res.code == 200) {
      addLog("单条推送无限群聊消息成功:${res.toJson()}");
    } else {
      addLog("单条推送无限群聊消息失败:${res.message}");
    }
  }

  // 单条推送无限群聊消息
  void pushP2UMoreMessage() async{
    var res = await mImcPush.pushP2UMoreMessage(
        fromAccount: "100",
        topicId: "21361055926583296",
        messages: ["data","data1"],
        fromResource: "keith"
    );
    if (res.code == 200) {
      addLog("批量推送无限群聊消息成功:${res.toJson()}");
    } else {
      addLog("批量推送无限群聊消息失败:${res.message}");
    }
  }

  // 多群推送单条消息
  void pushMultiTopicMessage() async{
    var res = await mImcPush.pushMultiTopicMessage(
        fromAccount: "100",
        topicIds: ["21361055926583296"],
        message: "data",
        fromResource: "keith"
    );
    if (res.code == 200) {
      addLog("多群推送单条消息成功:${res.toJson()}");
    } else {
      addLog("多群推送单条消息失败:${res.message}");
    }
  }

  // 监听回调消息
  void listener() {
    // 监听登录状态
    flutterMimc.addEventListenerStatusChanged().listen((status) {
      isOnline = status;
      if (status) {
        addLog("$appAccount====状态变更====上线");
      } else {
        addLog("$appAccount====状态变更====下线");
      }
      setState(() {});
    }).onError((err) {
      addLog(err);
    });

    // 接收单聊
    flutterMimc.addEventListenerHandleMessage().listen((MIMCMessage message) {
      String content = utf8.decode(base64.decode(message.payload));
      addLog("收到${message.fromAccount}消息: $content");
      setState(() {});
    }).onError((err) {
      addLog(err);
    });

    // 接收群聊
    flutterMimc
        .addEventListenerHandleGroupMessage()
        .listen((MIMCMessage message) {
      String content = utf8.decode(base64.decode(message.payload));
      addLog("收到群${message.topicId}消息: $content");
      setState(() {});
    }).onError((err) {
      addLog(err);
    });

    // 发送消息回调
    flutterMimc.addEventListenerServerAck().listen((MimcServeraAck ack) {
      addLog("发送消息回调==${ack.toJson()}");
    }).onError((err) {
      addLog(err);
    });

    // 发送在线消息回调
    flutterMimc.addEventListenerOnlineMessageAck().listen((MimcServeraAck ack) {
      addLog("发送在线消息回调==${ack.toJson()}");
    }).onError((err) {
      addLog(err);
    });

    // 发送单聊超时
    flutterMimc
        .addEventListenerSendMessageTimeout()
        .listen((MIMCMessage message) {
      addLog("发送单聊超时==${message.toJson()}");
    }).onError((err) {
      addLog(err);
    });

    // 发送群聊超时
    flutterMimc
        .addEventListenerSendGroupMessageTimeout()
        .listen((MIMCMessage message) {
      addLog("发送群聊超时==${message.toJson()}");
    }).onError((err) {
      addLog(err);
    });

    // 发送无限群聊超时
    flutterMimc
        .addEventListenerSendUnlimitedGroupMessageTimeout()
        .listen((MIMCMessage message) {
      addLog("发送无限群聊超时==${message.toJson()}");
    }).onError((err) {
      addLog(err);
    });

    // 创建大群回调
    flutterMimc
        .addEventListenerHandleCreateUnlimitedGroup()
        .listen((Map<dynamic, dynamic> res) {
      addLog("创建大群回调==$res");
      maxGroupID = (res['topicId'] as int).toString();
    }).onError((err) {
      addLog(err);
    });

    // 加入大群回调
    flutterMimc
        .addEventListenerHandleJoinUnlimitedGroup()
        .listen((Map<dynamic, dynamic> res) {
      addLog("加入大群回调==$res");
    }).onError((err) {
      addLog(err);
    });

    // 退出大群回调
    flutterMimc
        .addEventListenerHandleQuitUnlimitedGroup()
        .listen((Map<dynamic, dynamic> res) {
      addLog("退出大群回调==$res");
    }).onError((err) {
      addLog(err);
    });

    // 解散大群回调
    flutterMimc
        .addEventListenerHandleDismissUnlimitedGroup()
        .listen((Map<dynamic, dynamic> res) {
      addLog("解散大群回调==$res");
    }).onError((err) {
      addLog(err);
    });

    // 收到在线消息
    flutterMimc.addEventListenerOnlineMessage().listen((msg) {
      addLog("收到在线消息==${msg.toJson()}");
    }).onError((err) {
      addLog(err);
    });

    // 收到发送在线消息回调
    flutterMimc.addEventListenerOnlineMessageAck().listen((ack) {
      addLog("收到发送在线消息回调==${ack.toJson()}");
    }).onError((err) {
      addLog(err);
    });

  }

  Widget button(String title, VoidCallback onPressed) {
    return SizedBox(
      child: GestureDetector(
          child: Container(
            padding: EdgeInsets.all(3.0),
            margin: EdgeInsets.symmetric(vertical: 2.0, horizontal: 3.0),
            decoration: BoxDecoration(
                color: Colors.blue,
                borderRadius: BorderRadius.all(Radius.circular(3.0))),
            child: Text(
              title,
              style: TextStyle(color: Colors.white),
            ),
          ),
          onTap: onPressed),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        key: _scaffoldKey,
        appBar: AppBar(
          title: const Text('FlutterMimc example app'),
          actions: <Widget>[
            RaisedButton(
              color: Colors.blue,
              onPressed: isOnline ? logout : login,
              child: Text(
                isOnline ? "退出登录" : "登录",
                style: TextStyle(color: Colors.white),
              ),
            ),
          ],
        ),
        body: ListView(
          children: <Widget>[
            Padding(
              padding: EdgeInsets.symmetric(horizontal: 5.0),
              child: Column(
                children: <Widget>[
                  Text(
                      "\r\n当前账号:$appAccount,  当前状态:${isOnline ? '在线' : '离线'}\r\n"),
                  SizedBox(
                    height: 35.0,
                    child: TextField(
                        controller: accountCtr,
                        decoration: InputDecoration(hintText: "输入对方群ID、或对方账号")),
                  ),
                  SizedBox(
                    height: 35.0,
                    child: TextField(
                        controller: contentCtr,
                        decoration: InputDecoration(hintText: "输入发送的内容")),
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      RaisedButton(
                        color: Colors.blue,
                        onPressed: () => sendMessage(0),
                        child: Text(
                          "发送单聊",
                          style: TextStyle(color: Colors.white),
                        ),
                      ),
                      VerticalDivider(
                        width: 10.0,
                      ),
                      RaisedButton(
                        color: Colors.blue,
                        onPressed: () => sendMessage(3),
                        child: Text(
                          "发送在线消息",
                          style: TextStyle(color: Colors.white),
                        ),
                      ),
                      VerticalDivider(
                        width: 10.0,
                      ),
                    ],
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      RaisedButton(
                        color: Colors.blue,
                        onPressed: () => sendMessage(1),
                        child: Text(
                          "发送群聊",
                          style: TextStyle(color: Colors.white),
                        ),
                      ),
                      VerticalDivider(
                        width: 10.0,
                      ),
                      RaisedButton(
                        color: Colors.blue,
                        onPressed: () => sendMessage(2),
                        child: Text(
                          "发送无限群聊",
                          style: TextStyle(color: Colors.white),
                        ),
                      ),
                    ],
                  ),
                  Row(
                    children: <Widget>[
                      button("获取token", getToken),
                      button("当前账号", getAccount),
                      button("账号状态", getStatus),
                      button("单聊记录", pullP2PHistory),
                      button("会话列表", getContact),
                    ],
                  ),
                  Text(
                    '\r\n----普通群----',
                    style: TextStyle(color: Colors.grey),
                  ),
                  Divider(),
                  Row(
                    children: <Widget>[
                      button("创建群", createGroup),
                      button("查询群信息", queryGroupInfo),
                      button("查询所属", queryGroupsOfAccount),
                      button("邀请加入群", joinGroup),
                      button("群主删除群", dismissGroup),
                    ],
                  ),
                  Row(
                    children: <Widget>[
                      button("非群主退群", quitGroup),
                      button("踢成员出群", kickGroup),
                      button("更新群信息", updateGroup),
                      button("拉取群聊记录", pullP2THistory),
                    ],
                  ),
                  Text(
                    '\r\n----无限大群----',
                    style: TextStyle(color: Colors.grey),
                  ),
                  Divider(),
                  Row(
                    children: <Widget>[
                      button("创建大群", createUnlimitedGroup),
                      button("加入大群", joinUnlimitedGroup),
                      button("退出大群", quitUnlimitedGroup),
                      button("解散大群", dismissUnlimitedGroup),
                      button("大群信息", queryUnlimitedGroupInfo),
                    ],
                  ),
                  Row(
                    children: <Widget>[
                      button("大群更新", updateUnlimitedGroup),
                      button("大群成员", queryUnlimitedGroupMembers),
                      button("在线用户数", queryUnlimitedGroupOnlineUsers),
                      button("所在的无限大群", queryUnlimitedGroups),
                    ],
                  ),
                  Row(
                    children: <Widget>[
                      button("超级大群聊消息记录", pullP2UHistory),
                      button("删除无限大群", deleteUnlimitedGroup),
                    ],
                  ),
                  Text(
                    '\r\n----黑名单----',
                    style: TextStyle(color: Colors.grey),
                  ),
                  Divider(),
                  Row(
                    children: <Widget>[
                      button("拉黑对方", setBlackList),
                      button("取消拉黑", deleteBlackList),
                      button("检查是否被拉黑", hasBlackList),
                    ],
                  ),
                  Text(
                    '\r\n----群禁言----',
                    style: TextStyle(color: Colors.grey),
                  ),
                  Divider(),
                  Row(
                    children: <Widget>[
                      button("禁言群成员", setGroupBlackList),
                      button("取消禁言群成员", deleteGroupBlackList),
                      button("检查是否禁言", hasGroupBlackList),
                    ],
                  ),
                  Text(
                    '\r\n----推送消息----',
                    style: TextStyle(color: Colors.grey),
                  ),
                  Divider(),
                  Row(
                    children: <Widget>[
                      button("推送单聊信息", pushP2PMessage),
                      button("批量推送单聊信息", pushP2PMoreMessage),
                      button("推送群聊信息", pushP2TMessage),
                    ],
                  ),
                  Row(
                    children: <Widget>[
                      button("批量推送群聊信息", pushP2TMoreMessage),
                      button("单条推送无限群聊消息", pushP2UMessage),
                    ],
                  ),
                  Row(
                    children: <Widget>[
                      button("批量推送无限群聊消息", pushP2UMoreMessage),
                      button("多群推送单条消息", pushMultiTopicMessage),
                    ],
                  ),
                  Divider(),
                ],
              ),
            ),
            Container(
              width: double.infinity,
              color: Colors.white70,
              height: 500.0,
              padding: EdgeInsets.symmetric(horizontal: 5.0),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text("操作日志(部分接口需要登录后才能操作)"),
                      button("清空日志", () {
                        logs = [];
                        setState(() {});
                      }),
                    ],
                  ),
                  Divider(),
                  Expanded(
                    child: ListView.builder(
                        itemCount: logs.length,
                        itemBuilder: (context, index) {
                          return ListTile(
                            title: Text(logs[index]['content']),
                            subtitle: Text(logs[index]['date']),
                          );
                        }),
                  )
                ],
              ),
            )
          ],
        ));
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_mimc: ^1.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_mimc/flutter_mimc.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
52
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
76
Learn more about scoring.

We analyzed this package on Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.7
  • Flutter: 1.12.13+hotfix.9

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
dio ^3.0.8 3.0.9
flutter 0.0.0
Transitive dependencies
charcode 1.1.3
collection 1.14.11 1.14.12
http_parser 3.1.4
meta 1.1.8
path 1.6.4
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test