im_flutter_sdk 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 66

im_flutter_sdk #

A new flutter plugin project.

Getting Started #

生成文档 #

SDK API文档由以下命令生成,线上文档请参看Easemob IM Flutter SDK API文档:


dartdoc --exclude dart:io,dart:async,dart:ui,dart:math,dart:collection,dart:convert,dart:core,dart:developer,dart:isolate,dart:typed_data --output doc

SDK简要说明 #

1.0.0 #

  • NEW
  1. 实现初始化、注册、登录、退出、被踢功能;
  2. 实现加好友、删除好友功能;
  3. 实现群聊基本操作,如创建群、申请群、加入群、离开群、设置管理员、设置黑名单等;
  4. 实现聊天室基本操作,如加入聊天室、离开聊天室等;
  5. 实现消息种类:文字消息、语音消息、图片消息、短视频消息、短音频消息、CMD消息;
  • FIX:
  • TODO:
  1. 消息提醒;

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'package:flutter_localizations/flutter_localizations.dart';

import 'package:im_flutter_sdk/im_flutter_sdk.dart';
import 'package:im_flutter_sdk_example/pages/chatgroup_list_page.dart';
import 'package:im_flutter_sdk_example/pages/chatroom_list_page.dart';
import 'package:im_flutter_sdk_example/pages/public_group_list_page.dart';
import 'utils/localizations.dart';
import 'pages/home_page.dart';
import 'package:im_flutter_sdk_example/pages/login_page.dart';
import 'package:im_flutter_sdk_example/pages/register_page.dart';
import 'package:im_flutter_sdk_example/pages/contacts_list_page.dart';
import 'package:im_flutter_sdk_example/pages/items/contact_add.dart';
import 'package:im_flutter_sdk_example/pages/chat_page.dart';
import 'utils/style.dart';
import 'common/common.dart';

void main() => runApp(MyApp());

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

class _MyAppState extends State<MyApp> implements EMConnectionListener{
  @override
  void initState() {
    //TODO: init sdk;
    EMOptions options = new EMOptions(appKey: "easemob-demo#chatdemoui");
//    EMPushConfig config = new EMPushConfig();
//    config.enableAPNS('证书名称');
//    options.setPushConfig(config);
    EMClient.getInstance().init(options);
    EMClient.getInstance().setDebugMode(true);
    EMClient.getInstance().addConnectionListener(this);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      /// 配置跳转路由
      routes: <String, WidgetBuilder>{
        Constant.toRegisterPage:(BuildContext context)=>new RegisterPage(),
        Constant.toLoginPage:(BuildContext context)=>new LoginPage(),
        Constant.toHomePage: (BuildContext context) => new HomePage(),
        Constant.toChatRoomListPage: (BuildContext context) => new EMChatRoomListPage(),
        Constant.toChatPage: (BuildContext context) => new ChatPage(),
        Constant.toAddContact: (BuildContext context) => new EMContactAddPage(),
        Constant.toContactList: (BuildContext context) => new EMContactsListPage(),
        Constant.toChatGroupListPage: (BuildContext context) => new EMChatGroupListPage(),
        Constant.toPublicGroupListPage: (BuildContext context) => new PublicGroupListPage(),
      },
      /// 配置国际化语言
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        DemoLocalizationsDelegate.delegate,
      ],
      supportedLocales: [
        const Locale('en', 'US'), // 美国英语
        const Locale('zh', 'CH'), // 中文简体
        // ... other locales the app supports
      ],


      title: '环信即时通讯云',

      ///浅色模式,设置的颜色可能影响其他组件,可以通过判断ThemeUtils.isDark去设置对应颜色
      theme: new ThemeData(
        brightness: Brightness.light,
        accentColor: EMColor.buttonDisabled,
        backgroundColor: EMColor.bgColor,
        bottomAppBarColor: EMColor.appMain,
        buttonColor: EMColor.buttonDisabled,
        dialogBackgroundColor: EMColor.appMain,
        hintColor: EMColor.textGray,
        errorColor: EMColor.red,
        primaryColor: EMColor.buttonDisabled,
        scaffoldBackgroundColor: EMColor.bgColor,
      ),
      ///深色模式
      darkTheme: ThemeData(
        brightness: Brightness.dark,
        accentColor: EMColor.darkButtonDisabled,
        backgroundColor: EMColor.darkBgColor,
        bottomAppBarColor: EMColor.darkAppMain,
        buttonColor: EMColor.darkButtonDisabled,
        dialogBackgroundColor: EMColor.darkAppMain,
        hintColor: EMColor.darkTextGray,
        errorColor: EMColor.darkRed,
        primaryColor: EMColor.darkAppMain,
        scaffoldBackgroundColor: EMColor.darkBgColor,
      ),
      home: LoginPage(),
    );
  }

  /// EMConnectionListener
  @override
  void onConnected() {
    // TODO: implement onConnected
    print("网络连接成功");
    EMClient.getInstance().callManager().registerCallReceiver();
  }

  @override
  void onDisconnected(int errorCode) {
    // TODO: implement onDisconnected
    print("网络连接断开 ");
  }

}

Use this package as a library

1. Depend on it

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


dependencies:
  im_flutter_sdk: ^1.0.0

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:im_flutter_sdk/im_flutter_sdk.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
46
Health:
Code health derived from static analysis. [more]
94
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
75
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:im_flutter_sdk/im_flutter_sdk.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:im_flutter_sdk/im_flutter_sdk.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:im_flutter_sdk/im_flutter_sdk.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:im_flutter_sdk/im_flutter_sdk.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • im_flutter_sdk that is a package requiring null.

Health suggestions

Fix lib/src/em_call_manager.dart. (-3.93 points)

Analysis of lib/src/em_call_manager.dart reported 8 hints, including:

line 118 col 18: This function has a return type of 'Future

line 126 col 24: This function has a return type of 'Future

line 134 col 18: This function has a return type of 'Future

line 142 col 18: This function has a return type of 'Future

line 150 col 18: This function has a return type of 'Future

Fix lib/src/em_chat_manager.dart. (-1 points)

Analysis of lib/src/em_chat_manager.dart reported 2 hints:

line 9 col 8: Unused import: 'em_log.dart'.

line 425 col 15: Name non-constant identifiers using lowerCamelCase.

Fix lib/src/em_chatroom_manager.dart. (-0.50 points)

Analysis of lib/src/em_chatroom_manager.dart reported 1 hint:

line 4 col 8: Unused import: 'package:flutter/widgets.dart'.

Fix additional 11 files with analysis or formatting issues. (-1 points)

Additional issues in the following files:

  • lib/src/em_client.dart (1 hint)
  • lib/src/em_group.dart (1 hint)
  • lib/im_flutter_sdk.dart (Run flutter format to format lib/im_flutter_sdk.dart.)
  • lib/src/em_call_setup.dart (Run flutter format to format lib/src/em_call_setup.dart.)
  • lib/src/em_chatroom.dart (Run flutter format to format lib/src/em_chatroom.dart.)
  • lib/src/em_group_manager.dart (Run flutter format to format lib/src/em_group_manager.dart.)
  • lib/src/em_listeners.dart (Run flutter format to format lib/src/em_listeners.dart.)
  • lib/src/em_log.dart (Run flutter format to format lib/src/em_log.dart.)
  • lib/src/em_message_body.dart (Run flutter format to format lib/src/em_message_body.dart.)
  • lib/src/em_push_manager.dart (Run flutter format to format lib/src/em_push_manager.dart.)
  • lib/src/em_sdk_method.dart (Run flutter format to format lib/src/em_sdk_method.dart.)

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Homepage URL is insecure. (-5 points)

Update the homepage field and use a secure (https) URL.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test