Flutter: add Appwin to your app
Learn how to add Appwin to your Flutter app with the pub.dev packages.
Before you start
- An app created in the dashboard
- Your App ID
- Dart SDK 3.9.2+, Flutter 3.3+
Build your integration
Pick the products you want. The dependency list and the initialisation code follow your choice.
Build your integration
AppwinCore is always in - it carries the identity, the session and the network client. Pick what you add on top.
Use a prompt
Dependencies
flutter pub add appwin_core appwin_community
cd ios && pod install
Initialisation
import 'package:appwin_core/appwin_core.dart';
import 'package:appwin_community/appwin_community.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await AppwinCore.instance.configure(
appId: const String.fromEnvironment('APPWIN_APP_ID'),
);
await AppwinCore.instance.bootstrapSession();
final community = await AppwinCommunity.instance.initialize();
runApp(const MyApp());
}
- Each initialize() answers rather than throwing. Gate your own entry point on the result - the SDK does not own your navigation, so it cannot hide your tab for you.
- The parameter is appId on Flutter, where the native SDKs call it projectAppId. Same value, and it is the one naming divergence across the four platforms.
Pass the App ID at build time:
flutter run --dart-define=APPWIN_APP_ID=624486b8-79c1-44ce-b3cf-454ef61da11d
Put it on screen
initialize() says whether a product may open. Where it goes is yours - the
SDK does not own your navigation.
| Package | What you place |
|---|---|
appwin_community | AppwinCommunityView() |
appwin_support | AppwinSupportMessengerView() |
appwin_notifications | No UI - registerPushToken(...) at launch |
if (!ready) return const SizedBox.shrink();
return const AppwinCommunityView();
A refused product logs loudly in a debug build, quietly in release, and falls back to a neutral view if you present it anyway. It never crashes, and it never silently does nothing.
Attach your user
Optional, and it is what makes a person the same in Community and in Support,
and across their devices. The externalId is yours - the one from your
database.
await AppwinCore.instance.identify(externalId: user.id);
await AppwinCore.instance.bootstrapSession(externalId: user.id);
await AppwinCore.instance.signOut(); // on sign-out
identify alone is not enough: replaying the bootstrap is what mints a token
carrying the new identity. Without it, the calls that follow stay on the
anonymous session until the next launch.