flutter_quash_sdk 0.0.1 flutter_quash_sdk: ^0.0.1 copied to clipboard
A Flutter SDK for Quash bug reporting and analytics.
Flutter App with Quash Integration #
This README provides instructions on how to integrate Quash SDK into your Flutter application to capture errors, enable screen recording, and intercept network calls.
Getting Started #
Follow the steps below to set up Quash SDK in your Flutter app.
1. Capture All Errors #
To capture all errors occurring in the app, wrap your runApp
call with runZonedGuarded
. This ensures that any uncaught errors are logged and handled appropriately.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_quash_sdk/flutter_quash_sdk.dart';
void main() {
runZonedGuarded(() async {
runApp(const MyApp());
}, (error, stackTrace) {
FlutterError.dumpErrorToConsole(
FlutterErrorDetails(stack: stackTrace, exception: error),
);
FlutterQuashSdk().getBugReportingScreen();
});
}
1.2. Initialize Quash SDK #
Initialize the Quash SDK in the initState method of your main widget. Obtain your API key from the Quash website and replace "your_api_key_here" with your actual key. dart
import 'package:flutter/material.dart';
import 'package:flutter_quash_sdk/flutter_quash_sdk.dart';
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _flutterQuashSdkPlugin = FlutterQuashSdk();
@override
void initState() {
super.initState();
_flutterQuashSdkPlugin.intializeApp("your_api_key_here", true); // production
}
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: _flutterQuashSdkPlugin.getNavigatorKey(),
home: FabInjector(child: SplashScreen()), // Replace SplashScreen with your own widget
);
}
}
- Enable Screen Recording To enable screen recording functionality in your app, use the navigatorKey provided by Quash SDK and wrap your home widget with FabInjector. dart
import 'package:flutter/material.dart';
import 'package:flutter_quash_sdk/flutter_quash_sdk.dart';
class MyApp extends StatelessWidget {
final _flutterQuashSdkPlugin = FlutterQuashSdk();
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: _flutterQuashSdkPlugin.getNavigatorKey(),
home: FabInjector(child: SplashScreen()), // Replace SplashScreen with your own widget
);
}
}
- Intercept Network Calls To log all network calls made by your app, add the QuashCurlInterceptor to your Dio instance.
import 'package:dio/dio.dart';
import 'package:flutter_quash_sdk/flutter_quash_sdk.dart';
final Dio _dio = Dio();
void setupDio() {
_dio.interceptors.add(QuashCurlInterceptor());
}