Skip to content

Commit 677ae65

Browse files
committed
Update the Flutter SDK initialization snippet
1 parent ea4ff04 commit 677ae65

2 files changed

Lines changed: 30 additions & 9 deletions

File tree

versioned_docs/version-3.0/ios-present-onboardings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ AdaptyOnboardingView(
121121
## Customize how links open in onboardings
122122

123123
:::important
124-
Customizing how links open in onboardings is supported starting from Adapty SDK v. 3.15.1.
124+
Customizing how links open in onboardings is supported starting from Adapty SDK v.3.15.1.
125125
:::
126126

127127
By default, links in onboardings open in an in-app browser. This provides a seamless user experience by displaying web pages within your application, allowing users to view them without switching apps.

versioned_docs/version-3.0/sdk-installation-flutter.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,37 @@ The Adapty SDK only needs to be activated once in your app.
6464
```dart showLineNumbers title="main.dart"
6565
import 'package:adapty_flutter/adapty_flutter.dart';
6666
67-
void main() async {
68-
WidgetsFlutterBinding.ensureInitialized();
69-
70-
// Configure and activate Adapty SDK
71-
await Adapty().activate(
72-
configuration: AdaptyConfiguration(apiKey: 'YOUR_PUBLIC_SDK_KEY')
73-
);
74-
67+
void main() {
7568
runApp(MyApp());
7669
}
70+
71+
class MyApp extends StatefulWidget {
72+
@override
73+
_MyAppState createState() => _MyAppState();
74+
}
75+
76+
class _MyAppState extends State<MyApp> {
77+
@override
78+
void initState() {
79+
_initializeAdapty();
80+
81+
super.initState();
82+
}
83+
84+
Future<void> _initializeAdapty() async {
85+
try {
86+
await Adapty().activate(
87+
configuration: AdaptyConfiguration(apiKey: 'YOUR_PUBLIC_SDK_KEY'),
88+
);
89+
} catch (e) {
90+
// handle the error
91+
}
92+
}
93+
94+
Widget build(BuildContext context) {
95+
return Text("Hello");
96+
}
97+
}
7798
```
7899

79100
<GetKey />

0 commit comments

Comments
 (0)