app_center_plugin 1.0.0
app_center_plugin: ^1.0.0 copied to clipboard
A AppCenter Flutter plugin with Analytics and Crashes.
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:app_center_plugin/app_center_plugin.dart';
const androidSecret = '043be909-44a3-4675-b8b3-3078cb55d379';
const iOSSecret = '894914f3-91d8-48c0-a929-d02e8b5b2178';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final secret = Platform.isAndroid ? androidSecret : iOSSecret;
await AppCenter.start(secret);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
AppCenter.trackEvent('MyApp');
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
AppCenter.trackEvent(
'Increment Counter', {'counter': _counter.toString()});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}