flutter_quash_sdk 0.0.1 flutter_quash_sdk: ^0.0.1 copied to clipboard
A Flutter SDK for Quash bug reporting and analytics.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_quash_sdk/flutter_quash_sdk.dart';
import 'package:flutter_quash_sdk/ui/bug_reporting/fab_button/fab_button.dart';
import 'package:flutter_quash_sdk_example/screens/splash_screen.dart';
void main() {
FlutterError.onError = (FlutterErrorDetails details) {
FlutterError.dumpErrorToConsole(details);
FlutterQuashSdk().getBugReportingScreen();
};
runZonedGuarded(() async {
runApp(const MyApp());
}, (error, stackTrace) {
FlutterError.dumpErrorToConsole(
FlutterErrorDetails(stack: stackTrace, exception: error),
);
FlutterQuashSdk().getBugReportingScreen();
});
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final _flutterQuashSdkPlugin = FlutterQuashSdk();
Duration _elapsed = Duration();
Timer? _timer;
@override
void initState() {
// _flutterQuashSdkPlugin.intializeApp("0QUAS2dbgb007c2a2fc02c042a98cf9575bf84cdb42b5f549d7da30adaa4dcc9ba70da45e", true);//production
_flutterQuashSdkPlugin.intializeApp("0QUASdbgfdf04d93332743695ab403052fea9f4bd61c442796700736b637f2a7e1cefaa7", true);//bumblebee
// _flutterQuashSdkPlugin.intializeApp("0DSFAdbgc3e0d2579e909c148b504fca509b751a4435b184e3ed969239285807fea56bc5", true); //staging
// _flutterQuashSdkPlugin.intializeApp("01dbgaff15ffc72c6650f2c5efc26e427447fd20a4683aaded3d9c101af7b8d857af6", true); //staging
// _startTimer();
super.initState();
}
@override
void dispose() {
// _timer?.cancel();
super.dispose();
}
void _startTimer() {
_timer = Timer.periodic(Duration(milliseconds: 1), (timer) {
setState(() {
_elapsed = Duration(milliseconds: _elapsed.inMilliseconds + 1);
});
});
}
///TODO Remove post adding pegion
// 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.
// We also handle the message potentially returning null.
try {
platformVersion =
await _flutterQuashSdkPlugin.getPlatformVersion() ?? 'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// 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;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: _flutterQuashSdkPlugin.getNavigatorKey(),
home: FabInjector(child: SplashScreen()),
// home: Scaffold(
// backgroundColor: Colors.blue,
// appBar: AppBar(
// title: const Text('Plugin example app'),
// ),
// body: Column(
// children: [
//
// Text('${_elapsed.inSeconds}.${_elapsed.inMilliseconds.remainder(1000).toString().padLeft(3, '0')}'),
// Center(
// child: ElevatedButton(
// onPressed: () {
// throw Exception('Manual crash triggered');
// },
// child: Text('Trigger Crash'),
// ),
// ),
//
// Center(
// child: ElevatedButton(
// onPressed: (){
// _flutterQuashSdkPlugin.getScreenshotDisplayScreen();
// },
// child: Text('Open Screenshot Page'),
// ),
// ),
// ],
// ),
// ),
);
}
}