youme 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 33

youme #

A new flutter plugin project.

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

0.0.1 #

  • TODO: Describe initial release.

example/lib/main.dart

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

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

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

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

String appKey = "YOUMEDB869710BF23D30A189FF50537809438B3738C0D";
String appSecret = "2UJvOHVzgy63BMZRLGk6aj8/jsxsqfp50Js9uxyDJgTt0T1jWaBb2kqO7IT8ttsaaceAdjxsTyIB3B7bTZTjIr7XJeNRxfOTcH0A5qw+RuenWnq5UXyS6KDnnn3mbDskrL9XQ0WPcYs+XJDv2tgi8q/kCigqkm0DntvoXIrdjzMBAAE=";
String identifier = "100001";
String identifierOther = "100002";
String userId = "444455556";
String userIdTwo = "444455556";
String pwd = "123456";
String mChatRoomId = "12345";
class _MyAppState extends State<MyApp> {
  Youme _youme = new Youme();
  String _platformVersion = 'Unknown';

  StreamSubscription<dynamic> _messageStreamSubscription;

  @override
  void initState() {
    super.initState();
    initPlatformState();
    init();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await _youme.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    if (_messageStreamSubscription == null) {
      _messageStreamSubscription = _youme.onMessage.listen((dynamic onData) {
        print("我监听到数据了$onData");
      });
    }

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    //flutter 这里应该页面退出栈会调用,但是如果这个是根页面,日志是打不出来的。
    canCelListener();
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: new Center(
          child: new Column(
            children: <Widget>[
              new Text('Running on: $_platformVersion\n'),
              RaisedButton(
                onPressed: () {
                  login();
                },
                child: Text('登录imsdk'),
              ),
              RaisedButton(
                onPressed: () {
                  logout();
                },
                child: Text('登出imsdk'),
              ),
              RaisedButton(
                onPressed: () {
                  postData();
                },
                child: Text('测试发送数据'),
              ),
              RaisedButton(
                onPressed: () {
                  canCelListener();
                },
                child: Text('取消监听'),
              ),
              RaisedButton(
                onPressed: () {
                  sendTextMsg();
                },
                child: Text('发送文本消息'),
              ),
              RaisedButton(
                onPressed: () {
                  sendImageMsg();
                },
                child: Text('发送图片消息'),
              ),
              RaisedButton(
                onPressed: () {
                  sendLocationMsg();
                },
                child: Text('发送位置消息'),
              ),
              RaisedButton(
                onPressed: () {
                  getMessages();
                },
                child: Text('拿到历史消息'),
              ),
              RaisedButton(
                onPressed: () {
                  getUserInfo();
                },
                child: Text('获取个人资料'),
              ),
            ],
          ),
        ),
      ),
    );
  }

  Future<void> postData() async {
    try {
      var result = await _youme.postDataTest();
      print(result);
    } on PlatformException {
      print("listen  失败");
    }
  }

//  Future<void> login() async {
//    try {
//      var result = await _dim.imLogin(1400119955, "18681446372", "eJxlz11PwjAUgOH7-YpmtxjTj32AdwuCMIcGJkq9WWbXlkbsSul0avjvhkniEs-t856cnG8PAOA-ZPllyVjdaFe4T8N9cAV86F-8oTGqKkpXEFv9Q94aZXlRCsdthygMQwxhv1EV104JdS7snvTwUL0W3YXf7QBChGKI4n6iZIeLCR3Pl9dGrMUwj1iyqvSNXNMmmyU5HQ6mVjwumjs5truYbkcbTeR8m6RCRLssu0*pfVrepvmgbdhzFr1MP7gLZ-ir3qxkPGlZsB-1Tjr1xs-vBBBHJA5wT9*5PahadwGGKESYwNP43tH7ARZeXFI_");
////      var result = await _dim.postDataTest();
//      print(result);
//    } on PlatformException {
//      print("登录  失败");
//    }
//  }

  Future<void> sendTextMsg() async {
    try {
      var result = await _youme.sendTextMessages(userIdTwo, "haahah");
      print(result);
    } on PlatformException {
      print("发送消息失败");
    }
  }

  Future<void> sendImageMsg() async {
    try {
      var result = await _youme.sendImageMessages(identifierOther, "tyyhuiijkoi.png");
      print(result);
    } on PlatformException {
      print("发送图片消息失败");
    }
  }

  Future<void> sendLocationMsg() async {
    try {
      var result =
      await _youme.sendLocationMessages(identifierOther, 113.93, 22.54, "腾讯大厦");
      print(result);
    } on PlatformException {
      print("发送位置消息失败");
    }
  }
  Future<void> init() async {
    try {
      print(appKey);
      print(appSecret);
      var result = await _youme.init(appKey, appSecret);
      print(result);
    } on PlatformException {
      print("登录  失败");
    }
  }
  Future<void> login() async {
    try {

      var result = await _youme.login(userId, pwd);
      print(result);
    } on PlatformException {
      print("登录  失败");
    }
  }

  Future<void> logout() async {
    try {
      var result = await _youme.logout();
      print(result);
    } on PlatformException {
      print("登出  失败");
    }
  }

  Future<dynamic> getMessages() async {
    try {
      var result = await _youme.getMessages(
        identifier,
      );
      print(result);
    } on PlatformException {}
  }

  void canCelListener() {
    if (_messageStreamSubscription != null) {
      _messageStreamSubscription.cancel();
    }
  }

  void getUserInfo() async {
    try {
      List<String> users = List();
      users.add(identifier);
      var result = await _youme.getUsersProfile(users);
      print(result);
    } on PlatformException {
      print("获取个人资料失败");
    }
  }
}

Use this package as a library

1. Depend on it

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


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

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

  • Dart: 2.8.4
  • pana: 0.13.9+1
  • Flutter: 1.17.3

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:youme/youme.dart]

Package does not support Flutter platform macos

Because of import path [package:youme/youme.dart]

Package does not support Flutter platform web

Because of import path [package:youme/youme.dart]

Package does not support Flutter platform windows

Because of import path [package:youme/youme.dart]

Package not compatible with SDK dart

because of import path [youme]

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field http://bigwhite.dev was unreachable.

Package is getting outdated. (-32.88 points)

The package was last published 69 weeks ago.

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.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.0
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8