Flutter Notifications
ASecurityUse `FirebaseMessaging.instance.getInitialMessage()` during app startup. That is the API that tells you whether the app was cold-started from a notification tap while terminated. Example: ```dart final navigatorKey = GlobalKey<NavigatorState>(); Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(MyApp(navigatorKey: navigatorKey)); final initialMessage = await FirebaseMessaging.instance.getInitialMessage(); if (initialMessage != null) ...
- 584 stars
- 0 votes
- 0 copies
- 4 views
- Added September 5, 2026
Works with
Security analysis
100/100Pro scans all 12 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill flutter-notifications --agent claude-codeAre you the author of Flutter Notifications?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-flutter-notifications-2721e578)Use `FirebaseMessaging.instance.getInitialMessage()` during app startup. That is the API that tells you whether the app was cold-started from a notification tap while terminated.
Example:
```dart
final navigatorKey = GlobalKey<NavigatorState>();
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp(navigatorKey: navigatorKey));
final initialMessage = await FirebaseMessaging.instance.getInitialMessage();
if (initialMessage != null) {
_handleNotificationNavigation(initialMessage.data);
}
}
void _handleNotificationNavigation(Map<String, dynamic> data) {
final orderId = data['orderId'];
if (orderId is! String || orderId.isEmpty) return;
navigatorKey.currentState?.pushNamed(
'/order-details',
arguments: orderId,
);
}
```
You should also handle the other app states:
```dart
FirebaseMessaging.onMessageOpenedApp.listen((message) {
_handleNotificationNavigation(message.data);
});
```
Key points:
- Use `getInitialMessage()` for the terminated state.
- Validate the payload before navigating, for example make sure `orderId` exists and is valid.
- Register your route/navigation setup before trying to push.
- If you support foreground notifications too, use `flutter_local_notifications` for display, but terminated-launch navigation still comes from `getInitialMessage()`.
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- trigger-1.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
- trigger-5.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.