app_center_plugin 2.0.0
app_center_plugin: ^2.0.0 copied to clipboard
A AppCenter Flutter plugin with Analytics and Crashes.
AppCenter Plugin #
Android Prerequisites #
- You're targeting devices running Android Version 5.0 (API level 21) or later.
For more details: Get Started with Android.
iOS Prerequisites #
-
You're targeting devices running on iOS 9.0 or later.
-
Run
pod install
insideios folder
in your project to install AppCenter dependencies.
[!NOTE] If you see an error like
[!] Unable to find a specification for `AppCenter`
while runningpod install
, runpod repo update
to get the latest pods from the Cocoapods repository and then runpod install
For more details: Get Started with iOS.
Usage #
Simple package usage:
import 'package:app_center_plugin/app_center_plugin.dart';
final secret = Platform.isAndroid ? 'ANDROID_SECRET' : 'IOS_SECRET';
await AppCenter.start(secret);
AppCenter.trackEvent('my event', <String, String> {
'prop1': 'prop1',
'prop2': 'prop2',
});
AppCenter.trackError('error message');
How to catch Flutter and Dart errors:
WidgetsFlutterBinding.ensureInitialized();
// Start AppCenter
await AppCenter.start(secret);
// Log Flutter errors with FlutterError.onError
FlutterError.onError = (FlutterErrorDetails errorDetails) {
FlutterError.presentError(errorDetails);
// Send Flutter errors to AppCenter
AppCenter.trackError(
errorDetails.exceptionAsString(),
properties: {"library": errorDetails.library ?? ""},
stackTrace: errorDetails.stack,
);
};
// Log errors not caught by Flutter with PlatformDispatcher.instance.onError
PlatformDispatcher.instance.onError = (error, stack) {
AppCenter.trackError(
error.toString(),
stackTrace: stack,
);
return true;
};
runApp(const MyApp());
Check out the official documentation for more information on how to handle errors in Flutter