Skip to content

Commit 2a00191

Browse files
authored
feat(docs): add onFetureFlags docs for Flutter (#14096)
1 parent c69d94c commit 2a00191

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

contents/docs/integrate/feature-flags-code/_snippets/feature-flags-code-flutter.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ Every time a user opens the app, we send a request in the background to fetch th
2626

2727
This means that for most screens, the feature flags are available immediately – **except for the first time a user visits**.
2828

29+
To handle this, you can use the `onFeatureFlags` callback in your config to be notified when flags are loaded:
30+
31+
```dart
32+
final config = PostHogConfig('<ph_project_api_key>');
33+
config.host = '<ph_client_api_host>';
34+
config.onFeatureFlags = () async {
35+
if (await Posthog().isFeatureEnabled('flag-key')) {
36+
// do something
37+
}
38+
};
39+
await Posthog().setup(config);
40+
```
41+
2942
### Reloading feature flags
3043

3144
Feature flag values are cached. If something has changed with your user and you'd like to refetch their flag values, call:

0 commit comments

Comments
 (0)