umeng_sdk 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 42

third_um_sdk #

基于友盟统计的SDK封装

使用说明 #

// 发送自定义事件(目前属性值支持字符、整数、浮点、长整数,暂不支持NULL、布尔、MAP、数组) UmengSdk.onEvent("VideoPlay", {"userID":"神秘账号", "channel":"wx", "playTime":10});

// 设置用户账号 UmengSdk.onProfileSignIn("user_id");

// 取消用户账号 UmengSdk.onProfileSignOff();

// 如果需要使用页面统计,则先打开该设置 UmengSdk.setPageCollectionModeManual();

// 进入页面统计 UmengSdk.onPageStart("viewName");

// 离开页面统计 UmengSdk.onPageEnd("viewName");

// 如果不需要上述页面统计,在完成后可关闭该设置;如果没有用该功能可忽略; UmengSdk.setPageCollectionModeAuto();

// 错误发送 UmengSdk.reportError("后台程序执行时间过长");

1.0.0 #

  • basic umeng sdk

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

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

  // 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 UmengSdk.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;

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Running on: $_platformVersion'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
              children:<Widget>[
                FlatButton(
                    color: Colors.blue,
                    highlightColor: Colors.blue[700],
                    colorBrightness: Brightness.dark,
                    child: Text("onEvent(bool, {name:jack, age:18, male:true})"),
                    shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                    onPressed: (){
                      UmengSdk.onEvent('bool', {'name':'jack', 'age':18, 'male':true});
                    }
                ),
                FlatButton(
                    color: Colors.blue,
                    highlightColor: Colors.blue[700],
                    colorBrightness: Brightness.dark,
                    child: Text("onEvent(float, {name:jack, age:18, degree:1.6})"),
                    shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                    onPressed: (){
                      UmengSdk.onEvent('float', {'name':'jack', 'age':18, 'degree':1.6});
                    }
                ),
                FlatButton(
                    color: Colors.blue,
                    highlightColor: Colors.blue[700],
                    colorBrightness: Brightness.dark,
                    child: Text("onEvent(long, {name:jack, age:18, mobile:13910012345})"),
                    shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                    onPressed: (){
                      UmengSdk.onEvent('long', {'name':'jack', 'age':18, 'mobile':8613910012345});
                    }
                ),
                FlatButton(
                    color: Colors.blue,
                    highlightColor: Colors.blue[700],
                    colorBrightness: Brightness.dark,
                    child: Text("onEvent(array, {name:jack, age:18, children:[tom, jerry]})"),
                    shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                    onPressed: (){
                      UmengSdk.onEvent('array', {'name':'jack', 'age':18, 'male':true, 'mobile':13910012345, 'degree':1.6, 'children':['tom', 'jerry'], 'work':{'2000':'TC', '2005':'BAIDU', '2010':'ALI'}});
                    }
                ),
                FlatButton(
                    color: Colors.blue,
                    highlightColor: Colors.blue[700],
                    colorBrightness: Brightness.dark,
                    child: Text("onEvent(map, {name:jack, age:18, work:{2000:TC, 2005:BAIDU, 2010:ALI}})"),
                    shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                    onPressed: (){
                      UmengSdk.onEvent('map', {'name':'jack', 'age':18, 'work':{'2000':'TC', '2005':'BAIDU', '2010':'ALI'}});
                    }
                ),
                FlatButton(
                    color: Colors.blue,
                    highlightColor: Colors.blue[700],
                    colorBrightness: Brightness.dark,
                    child: Text("onEvent(null, {name:jack, age:18, like:null })"),
                    shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                    onPressed: (){
                      UmengSdk.onEvent('null', {'name':'jack', 'age':18, 'like':null});
                    }
                ),
                FlatButton(
                    color: Colors.blue,
                    highlightColor: Colors.blue[700],
                    colorBrightness: Brightness.dark,
                    child: Text("onEvent(map_array, {name:jack, age:18, work:{2000:TC, 2005:BAIDU, 2010:ALI}, children:[tom, jerry]})"),
                    shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                    onPressed: (){
                      UmengSdk.onEvent('map_array', {'name':'jack', 'age':18, 'children':['tom', 'jerry'],'work':{'2000':'TC', '2005':'BAIDU', '2010':'ALI'}});
                    }
                ),
                FlatButton(
                    color: Colors.blue,
                    highlightColor: Colors.blue[700],
                    colorBrightness: Brightness.dark,
                    child: Text("onProfileSignIn(jack)"),
                    shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                    onPressed: (){
                      UmengSdk.onProfileSignIn('jack');
                    }
                ),
                FlatButton(
                    color: Colors.blue,
                    highlightColor: Colors.blue[700],
                    colorBrightness: Brightness.dark,
                    child: Text("onProfileSignOff()"),
                    shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                    onPressed: (){
                      UmengSdk.onProfileSignOff();
                    }
                ),
                FlatButton(
                    color: Colors.blue,
                    highlightColor: Colors.blue[700],
                    colorBrightness: Brightness.dark,
                    child: Text("onPageStart(homeView)"),
                    shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                    onPressed: (){
                      UmengSdk.onPageStart('homeView');
                    }
                ),
                FlatButton(
                    color: Colors.blue,
                    highlightColor: Colors.blue[700],
                    colorBrightness: Brightness.dark,
                    child: Text("onPageEnd(homeView)"),
                    shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                    onPressed: (){
                      UmengSdk.onPageEnd('homeView');
                    }
                ),
                FlatButton(
                    color: Colors.blue,
                    highlightColor: Colors.blue[700],
                    colorBrightness: Brightness.dark,
                    child: Text("reportError(lost space)"),
                    shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                    onPressed: (){
                      UmengSdk.reportError('lost space');
                    }
                )
              ]
          ),
        ),
        bottomNavigationBar:BottomNavigationBar(
          type: BottomNavigationBarType.fixed,
          currentIndex: 1,
          items: [
            BottomNavigationBarItem(
                icon: Icon(Icons.account_balance), title: Text('主页')),
            BottomNavigationBarItem(
                icon: Icon(Icons.contacts), title: Text('列表')),
            BottomNavigationBarItem(
                icon: Icon(Icons.library_music), title: Text('个人'))
          ],
        )
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


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

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:umeng_sdk/umeng_sdk.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:umeng_sdk/umeng_sdk.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:umeng_sdk/umeng_sdk.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:umeng_sdk/umeng_sdk.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [umeng_sdk] that is in a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

12 out of 12 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/umeng_sdk.dart.

Run flutter format to format lib/umeng_sdk.dart.

Maintenance issues and suggestions

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

At the time of the analysis the homepage field https://songliangitis.gmail.com was unreachable.

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.

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.1
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