flutter_bl_umpush 0.0.1 flutter_bl_umpush: ^0.0.1 copied to clipboard
A new flutter plugin project.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_bl_umpush/flutter_bl_umpush.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();
}
// 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 FlutterBlUmpushPlugin.platformVersion;
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
bool isInit = await FlutterBlUmpushPlugin.initWithAppkey(
'5dde76d03fc19512a80000d3', "替换secret", 'app store');
bool isScenarioType = await FlutterBlUmpushPlugin.setScenarioType();
// 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;
});
}
void startPage() async {
bool isStart = await FlutterBlUmpushPlugin.umengOutViewWithName('启动统计');
}
void endPage() async {
bool isEnd = await FlutterBlUmpushPlugin.umengEnterViewWithName('启动统计');
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('测试app'),
),
body: Column(
children: <Widget>[
Center(
child: Text('Running on: $_platformVersion\n'),
),
GestureDetector(
onTap: () {
endPage();
print('start Page .............................');
},
child: Container(
color: Colors.lightBlueAccent,
padding: const EdgeInsets.only(top: 20, bottom: 20),
child: Center(
child: Text('页面统计进入'),
),
),
),
GestureDetector(
onTap: () {
startPage();
},
child: Container(
color: Colors.lightBlueAccent,
margin: const EdgeInsets.only(top: 10),
padding: const EdgeInsets.only(top: 20, bottom: 20),
child: Center(
child: Text('页面统计退出'),
),
),
),
],
),
),
);
}
}