Code Monkey home page Code Monkey logo

fl_baidu_mob_stat_ys's Introduction

  • 👋 Hi, I’m @miaozhenkun
  • 👀 I’m interested in ...
  • 🌱 I’m currently learning ...
  • 💞️ I’m looking to collaborate on ...
  • 📫 How to reach me ...

fl_baidu_mob_stat_ys's People

Contributors

chenxing0201 avatar miaozhenkun avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

fl_baidu_mob_stat_ys's Issues

示例代码报错

import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mob_stat/fl_baidu_mob_stat_ys.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final bool key = await FlBaiduMobStatYs()
      .setApiKey(androidKey: 'androidKey', iosKey: 'iosKey');
  debugPrint('初始化是否成功:$key');

  String channelName = 'flutter';
  if (Platform.isAndroid) channelName += '- Android';
  if (Platform.isIOS) channelName += '- IOS';

  final bool channel = await FlBaiduMobStatYs().setAppChannel(channelName);
  debugPrint('设置channel:$channelName = $channel');

  final bool version = await FlBaiduMobStatYs().setAppVersionName('1.0.0');
  debugPrint('设置version name:$version');

  final bool debug = await FlBaiduMobStatYs().setDebug(true);
  debugPrint('设置是否开启debug模式:$debug');

  runApp(MaterialApp(
    home: _MyApp(),
    debugShowCheckedModeBanner: false,
    title: 'FlBaiduMobStatYs',
  ));
}

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

class _MyAppState extends State<_MyApp> {
  bool _eventStartEndButtonSelected = false;
  String text = '';

  Future<void> _getDeviceCuId() async {
    final String? cuId = await FlBaiduMobStatYs().getDeviceCuId();
    if (cuId == null) return;
    text = 'CuId:\n' + cuId;
    setState(() {});
  }

  Future<void> _getTestDeviceId() async {
    final String? id = await FlBaiduMobStatYs().getTestDeviceId();
    if (id == null) return;
    text = 'TestId\n' + id;
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('FlBaiduMobStatYs Example')),
      body: Center(
        child: Column(children: <Widget>[
          Container(
              height: 100, child: Text(text), alignment: Alignment.center),
          ElevatedButton(
              child: const Text('logEvent'),
              onPressed: () async {
                final bool state = await FlBaiduMobStatYs().logEvent(
                    eventId: 'Event1',
                    attributes: <String, String>{'k1': 'v1', 'k2': 'v2'});
                text = 'logEvent: $state';
                setState(() {});
              }),
          ElevatedButton(
              child: const Text('logDurationEvent'),
              onPressed: () async {
                final bool state = await FlBaiduMobStatYs().logDurationEvent(
                    eventId: 'Event2',
                    duration: 3000,
                    label: 'event',
                    attributes: <String, String>{'k1': 'v1'});
                text = 'logDurationEvent: $state';
                setState(() {});
              }),
          ElevatedButton(
              child: Text(
                  _eventStartEndButtonSelected ? 'eventEnd' : 'eventStart'),
              onPressed: () async {
                _eventStartEndButtonSelected = !_eventStartEndButtonSelected;
                if (_eventStartEndButtonSelected) {
                  final bool state =
                  await FlBaiduMobStatYs().eventStart(eventId: 'Event3');
                  text = 'eventStart: $state';
                } else {
                  final bool state = await FlBaiduMobStatYs().eventEnd(
                      eventId: 'Event3',
                      attributes: <String, String>{'k1': 'v1'});
                  text = 'eventEnd: $state';
                }
                setState(() {});
              }),
          ElevatedButton(
              child: const Text('open page'),
              onPressed: () async {
                final bool state =
                await FlBaiduMobStatYs().pageStart('AnotherPage');
                text = 'pageStart: $state';
                setState(() {});
              }),
          ElevatedButton(
              child: const Text('close page'),
              onPressed: () async {
                final bool state =
                await FlBaiduMobStatYs().pageEnd('AnotherPage');
                text = 'pageEnd: $state';
                setState(() {});
              }),
          ElevatedButton(
              child: const Text('getDeviceCuId'), onPressed: _getDeviceCuId),
          ElevatedButton(
              child: const Text('getTestDeviceId'),
              onPressed: _getTestDeviceId),
        ]),
      ),
    );
  }
}

报错:


package:flutter/src/services/platform_channel.dart 332:7                                        MethodChannel._invokeMethod
===== asynchronous gap ===========================
package:flutter_baidu_mob_stat/fl_baidu_mob_stat_ys.dart 30:15                                  FlBaiduMobStatYs.setApiKey
===== asynchronous gap ===========================
test\needy_test.dart 9:20                                                                       main
===== asynchronous gap ===========================
d:/AppData/Local/Temp/flutter_tools.b072b3e4/flutter_test_listener.f33798b1/listener.dart 19:3  _testMain

Failed to load "C:/.../test/needy_test.dart": MissingPluginException(No implementation found for method setApiKey on channel fl_baidu_mob_stat_ys)

版本:

flutter_baidu_mob_stat: ^1.2.8
Dart version 3.4.3
Flutter version 3.22.2 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.