rangers_app_log 1.0.0 copy "rangers_app_log: ^1.0.0" to clipboard
rangers_app_log: ^1.0.0 copied to clipboard

outdated

RangersAppLog的Flutter插件。支持埋点上报。

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:rangers_app_log/rangers_app_log.dart';
import 'package:android_id/android_id.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp();

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _initResult = false;
  final _rangersAppLogPlugin = RangersAppLog();
  AndroidId _androidIdPlugin = AndroidId();

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    _initResult =
        await _rangersAppLogPlugin.init(appId: '544828', channel: 'test');

    // 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(() {});
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('初始化结果 : $_initResult'),
            ElevatedButton(
                onPressed: () async {
                  final String? androidId = await _androidIdPlugin.getId();
                  _rangersAppLogPlugin.setUserUniqueID(
                      userUniqueId: androidId ?? '');
                },
                child: Text("设置唯一id")),
            ElevatedButton(
                onPressed: () {
                  _rangersAppLogPlugin.onEventRegister(registerWay: 'wechat');
                },
                child: Text("注册事件")),
            ElevatedButton(
                onPressed: () {
                  ///onEventPurchase("gift","flower", "008",1, "wechat","¥", true, 1);/
                  _rangersAppLogPlugin.onEventPurchaseonEventPurchase(
                    commodityType: "gift",
                    tradeName: "flower",
                    productId: "008",
                    productCount: 13,
                    payWay: 'wechat',
                    payCurrency: "¥",
                    paySuccess: true,
                    payMoney: 100,
                  );
                },
                child: Text("购买事件")),
          ],
        ),
      ),
    );
  }
}
1
likes
0
points
9
downloads

Publisher

unverified uploader

Weekly Downloads

RangersAppLog的Flutter插件。支持埋点上报。

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on rangers_app_log

Packages that implement rangers_app_log