instabug_flutter 0.0.4-alpha.1 copy "instabug_flutter: ^0.0.4-alpha.1" to clipboard
instabug_flutter: ^0.0.4-alpha.1 copied to clipboard

outdated

Instabug is an in-app feedback and bug reporting tool for mobile apps. With just a simple shake, your users or beta testers can report bugs or send in-app feedback and the SDK will capture an enviro [...]

example/lib/main.dart

import 'dart:async';
import 'dart:io' show Platform;
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:instabug_flutter/Instabug.dart';
import 'package:instabug_flutter/BugReporting.dart';
import 'package:instabug_flutter/InstabugLog.dart';
import 'package:instabug_flutter/Surveys.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // 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.
    try {
      if (Platform.isIOS) {
        Instabug.start('068ba9a8c3615035e163dc5f829c73be', <InvocationEvent>[InvocationEvent.shake]);
      }
      //Instabug.showWelcomeMessageWithMode(WelcomeMessageMode.beta);
      //Instabug.setWelcomeMessageMode(WelcomeMessageMode.beta);
      Instabug.identifyUserWithEmail('aezz@instabug.com', 'Aly Ezz');
      InstabugLog.logInfo('Test Log Info Message from Flutter!');
      InstabugLog.logDebug('Test Debug Message from Flutter!');
      InstabugLog.logVerbose('Test Verbose Message from Flutter!');
      InstabugLog.clearAllLogs();
      InstabugLog.logError('Test Error Message from Flutter!');
      InstabugLog.logWarn('Test Warn Message from Flutter!');
      Instabug.logOut();
      //Instabug.setLocale(Locale.German);
      Instabug.setColorTheme(ColorTheme.dark);
      Instabug.appendTags(<String>['tag1', 'tag2']);
      Instabug.setUserAttributeWithKey('19', 'Age');
      Instabug.setUserAttributeWithKey('female', 'gender');
      Instabug.removeUserAttributeForKey('gender');
      final String value = await Instabug.getUserAttributeForKey('Age');
      print('User Attribute ' + value);
      final Map<String, String> userAttributes = await Instabug.getUserAttributes();
      print(userAttributes.toString()); 
      Instabug.logUserEventWithName('Aly Event');
      Instabug.setValueForStringWithKey('What\'s the problem', IBGCustomTextPlaceHolderKey.reportBug);
      Instabug.setValueForStringWithKey('Send some ideas', IBGCustomTextPlaceHolderKey.reportFeedback);
      Instabug.setSessionProfilerEnabled(false);
      Color c = const Color.fromRGBO(255, 0, 255, 1.0);
      Instabug.setPrimaryColor(c);
      Instabug.setUserData("This is some useful data");
      var list = Uint8List(10);
      Instabug.addFileAttachmentWithData(list, "My File");
      Instabug.clearFileAttachments();
      //Instabug.clearFileAttachments();
      //BugReporting.setEnabled(false);
      BugReporting.setOnInvokeCallback(sdkInvoked);
      BugReporting.setOnDismissCallback(sdkDismissed);
      BugReporting.setInvocationEvents(<InvocationEvent>[InvocationEvent.floatingButton]);
      Surveys.setEnabled(true);
      Surveys.setAutoShowingEnabled(false);
      Surveys.setOnShowCallback(surveyShown);
      Surveys.setOnDismissCallback(surveyDismiss);
      //BugReporting.setEnabledAttachmentTypes(false, false, false, false);
      //BugReporting.setReportTypes(<ReportType>[ReportType.FEEDBACK,ReportType.BUG]);
      //BugReporting.setExtendedBugReportMode(ExtendedBugReportMode.ENABLED_WITH_REQUIRED_FIELDS);
      //BugReporting.setInvocationOptions(<InvocationOption>[InvocationOption.EMAIL_FIELD_HIDDEN]);
      
    } 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;
    });
  }

  void resetTags() {
    Instabug.resetTags();
  }

  void getSurveys(List<String> surveys) {
    int x = surveys.length;
    debugPrint(x.toString());
  }

  void sdkInvoked() {
    debugPrint("I am called before invocation");
  }

  void surveyShown() {
    debugPrint("The user will se a survey nwoww");
  }

  void surveyDismiss() {
    debugPrint("The survey is Dismissed");
  }

  void sdkDismissed(DismissType dismissType, ReportType reportType) {
    debugPrint('SDK Dismissed DismissType: ' + dismissType.toString());
     debugPrint('SDK Dismissed ReportType: ' + reportType.toString());
  }

   void hasResponded(bool hasResponded) {
    debugPrint(hasResponded.toString());
  }
  void show() {
    //Instabug.show();
    // Surveys.getAvailableSurveys(getSurveys);
    // Surveys.showSurveyIfAvailable();
    // Surveys.setShouldShowWelcomeScreen(true);
    Surveys.showSurvey("BHJI1iaKYhr4CYHHcUAaTg");
    //BugReporting.showWithOptions(ReportType.bug, <InvocationOption>[InvocationOption.emailFieldHidden]);
  }

  void invokeWithMode() {
    Surveys.hasRespondedToSurvey("BHJI1iaKYhr4CYHHcUAaTg", hasResponded);
   // BugReporting.invokeWithMode(InvocationMode.bug, [InvocationOption.emailFieldHidden]);
  }

  void getTags() async {
    final List<String> tags = await Instabug.getTags();
    print(tags.toString());
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
            child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text('Running on: $_platformVersion\n'),
            RaisedButton(
                onPressed: show,
                child: Text('show'),
                color: Colors.lightBlue),
            RaisedButton(
                onPressed: invokeWithMode,
                child: Text('invokeWithMode'),
                color: Colors.lightBlue),
            RaisedButton(
                onPressed: resetTags,
                child: Text('reset tags'),
                color: Colors.lightBlue),
            RaisedButton(
                onPressed: getTags,
                child: Text('get tags'),
                color: Colors.lightBlue)
          ],
        )),
      ),
    );
  }
}
39
likes
0
pub points
92%
popularity

Publisher

verified publisherinstabug.com

Instabug is an in-app feedback and bug reporting tool for mobile apps. With just a simple shake, your users or beta testers can report bugs or send in-app feedback and the SDK will capture an environment snapshot of your user's device including all console logs, server-side network requests and bug reproduction steps compiling all these details in one organised dashboard to help you debug and fix bugs faster.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on instabug_flutter