init static method

Future<void> init({
  1. required String apiKey,
  2. String? version,
})

Initalizes the Raygun client with your Raygun API apiKey.

version is optional, if not provided it will be obtained from your pubspec.yaml.

Implementation

static Future<void> init({
  required String apiKey,
  String? version,
}) async {
  Settings.apiKey = apiKey;
  setVersion(version);
  // Send stored crash reports
  await CrashReporting.sendStored();
  // Listen to connectivity changed and send stored reports when online
  if (Settings.listenToConnectivityChanges) {
    Connectivity().onConnectivityChanged.listen((event) async {
      if (event.isNotEmpty && !event.contains(ConnectivityResult.none)) {
        RaygunLogger.d('Connectivity recovered, sending stored payloads');
        await CrashReporting.sendStored();
      }
    });
  }
}