SDK 11.0 Migration Guide for Flutter

This page covers the migration steps from previous versions of the SDK to Instabug Version 11.0+ for Flutter apps.

SDK Initialization from Dart only

Instead of having to add an extra initialization code snippet in Java/Kotlin files for Android, you can now start the SDK for both platforms with a single line of code from the Dart side. The same API Instabug.start used to initialize the SDK for iOS will now do the initialization for iOS and Android.

Migration to Dart-only Initialization

  1. Remove Instabug Android initialization code from android/app/src/main/java/<your_package>/CustomFlutterApplication.java
@Override
  public void onCreate() {
    super.onCreate();
-    ArrayList<String> invocationEvents = new ArrayList<>();
-    invocationEvents.add(InstabugFlutterPlugin.INVOCATION_EVENT_SHAKE);
-    new InstabugFlutterPlugin().start(CustomFlutterApplication.this, "APP_TOKEN", invocationEvents);
  }
  1. Initialize Instabug SDK in Dart, depending on the platforms you use:
import 'package:instabug_flutter/instabug_flutter.dart';

Instabug.start('APP_TOKEN', [InvocationEvent.floatingButton]);
import 'dart:io';
import 'package:instabug_flutter/instabug_flutter.dart';

if (Platform.isIOS) {
  Instabug.start(
      'IOS_APP_TOKEN', [InvocationEvent.floatingButton]);
}
else if (Platform.isAndroid) {
  Instabug.start(
      'ANDROID_APP_TOKEN', [InvocationEvent.floatingButton]);
}
import 'dart:io';
import 'package:instabug_flutter/instabug_flutter.dart';

if (Platform.isIOS) {
  Instabug.start(
      'APP_TOKEN', [InvocationEvent.floatingButton]);
}

Package Importing Style

The package layout has been updated, following Dart’s conventions and guidelines. Accordingly, importing the package will differ. Instead of adding an import statement for every module you want to use, you will now add a single import line for the whole package and then be able to use any module.

Example of the old style

import 'package:instabug_flutter/Instabug.dart';
import 'package:instabug_flutter/BugReporting.dart';
import 'package:instabug_flutter/CrashReporting.dart';

Instabug.start(
      'APP_TOKEN', [InvocationEvent.floatingButton]);
BugReporting.setInvocationOptions(
      InvocationOption.emailFieldOptional);
CrashReporting.setEnabled(true);

Example of the new style

import 'package:instabug_flutter/instabug_flutter.dart';

Instabug.start(
      'APP_TOKEN', [InvocationEvent.floatingButton]);
BugReporting.setInvocationOptions(
      InvocationOption.emailFieldOptional);
CrashReporting.setEnabled(true);

New Package for Instabug Custom Http Client

The network logging logic of Instabug Custom Http Client for dart:io package HttpClient has been removed from instabug_flutter package and separated into a new add-on package instabug_dart_io_http_client.

If you rely on it for network logging, you can opt to install the new package and proceed using it normally. For further details, please refer to Instabug Dart IO Http Client repository.

Deprecated APIs Removal

Chats Module is completely removed. Use Replies instead.

String Keys Changes

  1. Remove the string keys bugReportHeader and feedbackReportHeader. Use reportBug and reportFeedback as an alternative respectively.