- 👋 Hi, I’m @miaozhenkun
- 👀 I’m interested in ...
- 🌱 I’m currently learning ...
- 💞️ I’m looking to collaborate on ...
- 📫 How to reach me ...
miaozhenkun / fl_baidu_mob_stat_ys Goto Github PK
View Code? Open in Web Editor NEWflutter 百度分析插件
License: Other
flutter 百度分析插件
License: Other
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
在小米自动审核的时候出现的问题,想请问下是我否是使用错误而导致的
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.