Skip to content

Commit 93aabf6

Browse files
authored
Update README.md
1 parent 2901f53 commit 93aabf6

1 file changed

Lines changed: 12 additions & 17 deletions

File tree

README.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff 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
4444
import '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

0 commit comments

Comments
 (0)