bonree_flutter_plugin 2.2.0
bonree_flutter_plugin: ^2.2.0 copied to clipboard
The Bonree Flutter plugin working with SDK for Android and iOS,assists in measuring the performance of the Flutter application.
example/lib/main.dart
import 'dart:io';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:bonree_flutter_plugin/bonree_flutter_plugin.dart';
void main() {
Bonree().start(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@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.
// 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(() {});
}
static Future<void> sendNetworkRequest() async {
HttpClient client = HttpClient();
final request = await client.getUrl(Uri.parse('http://www.bonree.com'));
final response = await request.close();
print(response.headers);
}
static void createError() {
var testList = ["1", "2"];
print(testList[2]); //输出0
}
static Map<String, VoidCallback> actionsMap = {
'Send a network request': sendNetworkRequest,
'create an errror': createError,
};
@override
Widget build(BuildContext context) {
final ScrollController sController = ScrollController();
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Scrollbar(
controller: sController,
isAlwaysShown: true,
child: SingleChildScrollView(
controller: sController,
padding: const EdgeInsets.all(20.0),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
for (int i = 0; i < actionsMap.keys.length; i++)
Container(
width: 280.0,
height: 100.0,
padding: const EdgeInsets.all(18.0),
child: RaisedButton(
textColor: Colors.white,
color: Colors.blue,
onPressed: actionsMap.values.elementAt(i),
child: Text(actionsMap.keys.elementAt(i)),
),
),
],
),
),
),
),
),
);
}
}