Skip to content
Back to skills

Flutter Notifications

ASecurity

From scratch, the usual package set is: - `firebase_core` — initialize Firebase first - `firebase_messaging` — FCM token, permission, foreground/background/terminated delivery - `flutter_local_notifications` — show local notifications, especially for foreground messages Typical setup flow: 1. Add the packages and install native Firebase config - Flutter: `firebase_core`, `firebase_messaging`, `flutter_local_notifications` - Android: add `google-services.json` - iOS: add `GoogleService-Info.pl...

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

Works with

  • cli

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-agent-skills-standard/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-flutter-notifications-agent-skills-standard)

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
From scratch, the usual package set is:

- `firebase_core` — initialize Firebase first
- `firebase_messaging` — FCM token, permission, foreground/background/terminated delivery
- `flutter_local_notifications` — show local notifications, especially for foreground messages

Typical setup flow:

1. Add the packages and install native Firebase config
   - Flutter: `firebase_core`, `firebase_messaging`, `flutter_local_notifications`
   - Android: add `google-services.json`
   - iOS: add `GoogleService-Info.plist`

2. Initialize Firebase in `main()`
   - `WidgetsFlutterBinding.ensureInitialized()`
   - `await Firebase.initializeApp()`

3. Initialize local notifications
   - Create a `FlutterLocalNotificationsPlugin`
   - Define Android notification channel(s)
   - Initialize plugin with tap/click handler

4. Request notification permission
   - On iOS (and newer Android flows where relevant), show your own primer first, then call:
   - `FirebaseMessaging.instance.requestPermission(...)`

5. Register message handlers for all app states
   - Foreground: `FirebaseMessaging.onMessage.listen(...)`
     - FCM often won’t display a system banner while app is open, so use `flutter_local_notifications` to display one yourself
   - Background: `FirebaseMessaging.onBackgroundMessage(_handler)`
     - top-level/static handler
   - Terminated/opened from notification:
     - `FirebaseMessaging.instance.getInitialMessage()`
     - `FirebaseMessaging.onMessageOpenedApp.listen(...)`

6. Get and manage the FCM token
   - `await FirebaseMessaging.instance.getToken()`
   - send token to your backend
   - listen for refresh with `onTokenRefresh`

7. Validate payload data before navigation
   - If tapping a notification opens a screen, validate payload keys/IDs first instead of trusting raw data

Minimal initialization shape:

```dart
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  await Firebase.initializeApp();
}

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();

  FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);

  final local = FlutterLocalNotificationsPlugin();
  await local.initialize(
    const InitializationSettings(
      android: AndroidInitializationSettings('@mipmap/ic_launcher'),
      iOS: DarwinInitializationSettings(),
    ),
  );

  await FirebaseMessaging.instance.requestPermission();

  FirebaseMessaging.onMessage.listen((message) {
    // show local notification for foreground message
  });

  FirebaseMessaging.onMessageOpenedApp.listen((message) {
    // validate payload, then navigate
  });

  final initialMessage = await FirebaseMessaging.instance.getInitialMessage();
  if (initialMessage != null) {
    // app opened from terminated state
  }

  runApp(const MyApp());
}
```

In short: use `firebase_core + firebase_messaging + flutter_local_notifications`, initialize Firebase first, request permission thoughtfully, then handle foreground, background, and terminated notification flows explicitly.

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.