bugly_pro_flutter 0.4.12
bugly_pro_flutter: ^0.4.12 copied to clipboard
bugly for flutter pro
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:tencent_flutter_apm_example/exception_page.dart';
import 'package:bugly_pro_flutter/bugly.dart';
import 'package:trouter/router/router_container.dart';
import 'package:trouter/t_router.dart';
import 'main_page.dart';
import 'jank/jank_main_page.dart';
import 'jank/jank_io_page.dart';
import 'jank/jank_listview_page.dart';
void main() {
BuglyOptions options = BuglyOptions(
appId: '',
appKey: '',
bundleId: '');
options.userId = '1234567';
options.isDebug = true;
options.onErrorCallback = (error) {
print("------------------------- bugly callback -------------------------");
print("$error");
print("------------------------- bugly callback -------------------------");
};
options.monitorTypes = [
MonitorType.launchMetric,
MonitorType.looperMetric,
MonitorType.looperStack,
MonitorType.exception
];
Bugly.enableLooperStack(true);
Bugly.init(options, appRunner: () {
runApp(MyApp());
// TRouter.registerRouter({
// "home_page": (info) => MyHome(),
// });
},
beforeInitRunner: (options) {
options.userId = 'pro_tester';
options.appId = 'your appId';
options.appKey = 'your appKey';
options.bundleId = 'your app bundleId';
},
);
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
String _platformVersion = 'Unknown';
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHome(),
navigatorObservers: [BuglyNavigatorObserver()],
routes: {
'MainPage': (context) => MainPage(),
'FirstPage': (context) => FirstPage(),
'SecondPage': (context) => SecondPage(),
'JankMainPage': (context) => JankMainPage(),
'JankListviewPage': (context) => JankListviewPage(),
'JankIoPage': (context) => JankIoPage(),
'ExceptionPage': (context) => ExceptionPage(),
},
);
}
}
class MyHome extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
child: Text('FPS 测试页面', style: TextStyle(fontSize: 16)),
onPressed: () => Navigator.of(context).pushNamed('MainPage'),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
child: Text('卡顿测试页面', style: TextStyle(fontSize: 16)),
onPressed: () => Navigator.of(context).pushNamed('JankMainPage'),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
child: Text('异常测试页面', style: TextStyle(fontSize: 16)),
onPressed: () => Navigator.of(context).pushNamed('ExceptionPage'),
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
child: Text('开始上报', style: TextStyle(fontSize: 16)),
onPressed: () => Bugly.enableReport(),
),
],
)
],
));
}
}