File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,27 +38,22 @@ void main() async {
3838
3939` Note: ` You need to change your main function to be ` async ` and call ` WidgetsFlutterBinding.ensureInitialized(); ` before initializing the SDK.
4040
41- Afterward, you can start tracking events with ` Aptabase.instance ` :
41+ Afterward, you can start tracking events with ` Aptabase.instance ` anywhere in your Dart. Here's an example :
4242
4343``` dart
4444import 'package:aptabase_flutter/aptabase_flutter.dart';
4545
46- // Tracking how many times the user has clicked the button
47- void _incrementCounter() {
48- Aptabase.instance.trackEvent("increment");
49-
50- setState(() {
51- _counter++;
52- });
53- }
54-
55- // Same as above, but with a custom property
56- void _incrementCounter() {
57- Aptabase.instance.trackEvent("increment", { "counter": _counter });
58-
59- setState(() {
60- _counter++;
61- });
46+ class _CounterState extends State<Counter> {
47+ int _counter = 0;
48+
49+ // Tracking how many times the user has clicked the button, alongside the current counter value
50+ void _incrementCounter() {
51+ Aptabase.instance.trackEvent("increment", { "counter": _counter });
52+
53+ setState(() {
54+ _counter++;
55+ });
56+ }
6257}
6358```
6459
You can’t perform that action at this time.
0 commit comments