bugbattle_sdk 3.0.7 bugbattle_sdk: ^3.0.7 copied to clipboard
The BugBattle SDK for Flutter is the easiest way to integrate BugBattle into your apps!
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:bugbattle_sdk/bugbattle_sdk.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
try {
// Init Bugbattle with token and ActivationMethod
BugBattle.initWithToken("YOURTOKEN", ActivationMethod.SCREENSHOT);
// // Customizations
BugBattle.setCustomerEmail('hello@bugbattle.io');
const Map<String, dynamic> customData = {
'role': 'USER',
'data': 'More custom data'
};
BugBattle.attachCustomData(customData);
BugBattle.enablePrivacyPolicy(true);
BugBattle.setPrivacyPolicyUrl("https://awesomeproject.com/privacypolicy");
BugBattle.setNavigationBarTint(Colors.blue);
BugBattle.setNavigationTint(Colors.black);
BugBattle.setNavigationBarTitleColor(Colors.black);
BugBattle.setApiUrl("https://internalbugbattle.server");
} catch (err) {
print(err);
}
}
// to start bug reporting manually
void reportBug() {
BugBattle.startBugReporting();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Bugbattle Example'),
),
body: Center(
child: GestureDetector(
onTap: () {
reportBug();
},
child: Container(
alignment: Alignment.center,
height: 50,
width: 150,
color: Color(0xFF3578e5),
child: Text(
'Report Bug',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
),
),
),
);
}
}