Skip to content
Back to skills

Flutter Notifications

ASecurity

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) ...

  • 584 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 5, 2026
developmentapi

Works with

  • api

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill flutter-notifications --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Flutter Notifications?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Flutter Notifications
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-flutter-notifications-2721e578/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-flutter-notifications-2721e578)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
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.md1.7 KB
  • eval-1.with-skill.md3 KB
  • eval-2.baseline.md1.7 KB
  • eval-2.with-skill.md1.4 KB
  • eval-3.baseline.md732 B
  • eval-3.with-skill.md394 B
  • trigger-1.md148 B
  • trigger-2.md185 B
  • trigger-3.md148 B
  • trigger-4.md183 B
  • trigger-5.md135 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.