init method

  1. @override
Future<void> init(
  1. String appKey, {
  2. Uri? apiUri,
  3. Uri? baseUri,
  4. int? maximumLocalStorageSize,
  5. bool printToConsole = true,
  6. bool enableUIEventLogging = true,
  7. bool enableCrashReporting = true,
  8. bool enableAndroidLogcatLogging = true,
  9. String? overrideDeviceName,
  10. String? version,
  11. String? build,
})
override

Implementation

@override
Future<void> init(
  String appKey, {
  Uri? apiUri,
  Uri? baseUri,
  int? maximumLocalStorageSize, // note this is ignored in web
  bool printToConsole = true,
  bool enableUIEventLogging = true,
  bool enableCrashReporting = true,
  bool enableAndroidLogcatLogging = true,
  String? overrideDeviceName,
  String? version,
  String? build,
}) async {
  WidgetsFlutterBinding.ensureInitialized();

  // options keys are variable. For example, the "apiURL" key may or may not be present.
  // We can't use Dart classes with automatic conversion because Dart properties of a class are null when unset, but Bugfender.init() expects undefined.
  var options = {
    'appKey': appKey,
    'overrideConsoleMethods': false,
    'printToConsole': printToConsole,
    'registerErrorHandler': enableCrashReporting,
    'logBrowserEvents': enableUIEventLogging,
    'logUIEvents': enableUIEventLogging,
  };
  if (apiUri != null) {
    options['apiURL'] = apiUri.toString();
  }
  if (baseUri != null) {
    options['baseURL'] = baseUri.toString();
  }
  if (overrideDeviceName != null) {
    options['deviceName'] = overrideDeviceName;
  }
  if (version != null) {
    options['version'] = version;
  }
  if (build != null) {
    options['build'] = build;
  }
  return _initWithMap(options);
}