bugbattle_sdk 5.0.1 copy "bugbattle_sdk: ^5.0.1" to clipboard
bugbattle_sdk: ^5.0.1 copied to clipboard

discontinued
PlatformAndroidiOS

The BugBattle SDK for Flutter is the easiest way to integrate BugBattle into your apps!

example/lib/main.dart

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 {
      // Initialize Bugbattle with auto configuration
      BugBattle.autoConfigure("YOUR_SDK_KEY");

      // OR

      // Initialize Bugbattle with token and activationMethod
      /*BugBattle.initWithToken(
        'YOUR_TOKEN',
        ActivationMethod.SHAKE,
      );*/

      // OR

      // Initialize Bugbattle with token and many activationMethods (available for android, ios)
      /*BugBattle.initializeMany(
        'YOUR_TOKEN',
        [ActivationMethod.SCREENSHOT, ActivationMethod.SHAKE],
      );*/

      // Customizations
      //BugBattle.startBugReporting();

      BugBattle.enableReplays();

      const Map<String, dynamic> customData = {
        'role': 'USER',
        'data': 'More custom data'
      };
      BugBattle.attachCustomData(customData);

      BugBattle.enablePrivacyPolicy(true);

      BugBattle.setPrivacyPolicyUrl(
        'https://awesomeproject.com/privacypolicy',
      );

      // BugBattle.setApiUrl('https://internalbugbattle.server');

      BugBattle.logEvent("User signed in", {"name": "Franz", "age": 99});

      BugBattle.setLanguage("en");

      BugBattle.setCustomerEmail('hello@bugbattle.io');

      BugBattle.addCustomActionCallback((call) async {
        try {
          if (call.method == "customActionCalled" &&
              call.arguments['name'] == "MAGIC_ACTION") {
            // Magic action :)
            print("Magic action called.");
          }
        } catch (err) {
          print(err);
        }
      });
    } 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,
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
5
likes
110
pub points
0%
popularity

Publisher

verified publisherbugbattle.io

The BugBattle SDK for Flutter is the easiest way to integrate BugBattle into your apps!

Homepage

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on bugbattle_sdk