firebase_notification_helper 0.0.1 copy "firebase_notification_helper: ^0.0.1" to clipboard
firebase_notification_helper: ^0.0.1 copied to clipboard

A lightweight helper for Firebase Messaging, local notifications, and sending FCM push notifications via Legacy API. Best for internal tools and testing environments.

πŸ“© firebase_notification_helper #

A lightweight, easy-to-use Flutter helper package for Firebase Cloud Messaging (FCM) and Local Notifications.

This package is designed to make notification integration extremely simple β€” even for beginners.
It includes FCM token fetching, push notification sending, local notification display, and background handler support.

Linear Date Picker Demo


βœ… Summary of Everything Included in This Package #

  • βœ”οΈ Fully designed, production-ready README.md
  • βœ”οΈ Firebase setup (project + app + google-services.json)
  • βœ”οΈ Android Gradle setup (project + app level)
  • βœ”οΈ Initialization + FCM token fetch + send push + local notification
  • βœ”οΈ Background notification handler
  • βœ”οΈ Beautiful full-page Flutter example UI
  • βœ”οΈ Example app run instructions
  • βœ”οΈ Security best practices (server key safety)
  • βœ”οΈ MIT License, Contribution guidelines
  • βœ”οΈ Pub.dev-ready consistent formatting

You can publish instantly β€” everything is already prepared! πŸš€


⭐ Features #

  • πŸ”₯ Fetch FCM Token (Android)
  • πŸ“¨ Send Push Notification via FCM API
  • πŸ”” Show Local Notifications
  • πŸš€ Background Message Handler Support
  • πŸ§ͺ Full Example App Included
  • πŸ›‘ Very clean, beginner-friendly API
  • πŸ“¦ Zero-config local notification support

πŸ“¦ Installation #

Add the package in pubspec.yaml:

dependencies:
  firebase_notification_helper: ^0.0.1


Usage #

Then import

import 'package:dynamic_marker/dynamic_marker.dart';

Then use this code


import 'package:flutter/material.dart';
import 'package:firebase_notification_helper/firebase_notification_helper.dart';

class NotificationSenderPage extends StatefulWidget {
  const NotificationSenderPage({super.key});

  @override
  State<NotificationSenderPage> createState() => _NotificationSenderPageState();
}

class _NotificationSenderPageState extends State<NotificationSenderPage> {
  String token = "";
  String response = "";
  final keyController = TextEditingController();
  final titleController = TextEditingController(text: "Test Notification");
  final bodyController = TextEditingController(
    text: "Hello from firebase_notification_helper!",
  );

  @override
  void initState() {
    super.initState();
    _loadToken();
  }

  Future<void> _loadToken() async {
    final t = await FirebaseNotificationHelper.getToken();
    setState(() => token = t ?? "");
  }

  Future<void> _sendNotification() async {
    if (keyController.text.isEmpty) return;

    final res = await FirebaseNotificationHelper.sendNotification(
      serverKey: keyController.text.trim(),
      targetToken: token,
      title: titleController.text.trim(),
      body: bodyController.text.trim(),
    );

    setState(() => response = res.toString());
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("FCM Sender")),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          FirebaseNotificationHelper.showLocalNotification(
            title: titleController.text.trim(),
            body: bodyController.text.trim(),
          );
        },
        child: const Icon(Icons.notifications),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          children: [
            const Text("Your FCM Token:"),
            SelectableText(token),
            const SizedBox(height: 16),

            TextField(
              controller: keyController,
              decoration: const InputDecoration(
                labelText: "Server Key",
                border: OutlineInputBorder(),
              ),
            ),

            const SizedBox(height: 12),

            TextField(
              controller: titleController,
              decoration: const InputDecoration(
                labelText: "Notification Title",
                border: OutlineInputBorder(),
              ),
            ),

            const SizedBox(height: 12),

            TextField(
              controller: bodyController,
              maxLines: 2,
              decoration: const InputDecoration(
                labelText: "Notification Body",
                border: OutlineInputBorder(),
              ),
            ),

            const SizedBox(height: 12),

            ElevatedButton(
              onPressed: _sendNotification,
              child: const Text("Send Notification"),
            ),

            const SizedBox(height: 16),
            const Text("Response:"),
            Expanded(
              child: SingleChildScrollView(child: Text(response)),
            ),
          ],
        ),
      ),
    );
  }
}





Upgrade this android part in /android/build.gradle.kts #

Then import


buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.google.gms:google-services:4.4.2")
    }
}



Upgrade this android part in /android/app/build.gradle.kts #

Then import


plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("com.google.gms.google-services")   // REQUIRED
    id("dev.flutter.flutter-gradle-plugin")
}


android {
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
        isCoreLibraryDesugaringEnabled = true
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11.toString()
    }
}

dependencies {
    coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
}


Initialization #

Then import

import 'package:flutter/material.dart';
import 'package:firebase_notification_helper/firebase_notification_helper.dart';

Future<void> main() async {
  await FirebaseNotificationHelper.initialize();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: NotificationSenderPage(),
    );
  }
}

Get FCM Token #


final token = await FirebaseNotificationHelper.getToken();
print("πŸ”₯ Token: $token");


Send FCM Push Notification #


await FirebaseNotificationHelper.sendNotification(
serverKey: "YOUR_FCM_SERVER_KEY",
targetToken: token!,
title: "Hello!",
body: "This is sent using firebase_notification_helper",
);



Show Local Notification #


await FirebaseNotificationHelper.showLocalNotification(
title: "Local Test",
body: "This alert is from your device",
);




1
likes
130
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight helper for Firebase Messaging, local notifications, and sending FCM push notifications via Legacy API. Best for internal tools and testing environments.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

firebase_core, firebase_messaging, flutter, flutter_local_notifications, http

More

Packages that depend on firebase_notification_helper