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

A Flutter package for app access control using Firebase Remote Config and FCM.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';

import 'package:app_access_guard/app_access_guard.dart';
import 'package:app_access_guard/src/services/fcm_service.dart';

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

  FirebaseMessaging.onBackgroundMessage(backgroundHandler);

  await FCMService.init();

  runApp(MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: AccessGuard(
        allowedScreen: HomeScreen(),
        blockedScreen: PaymentPendingScreen(),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Home")),
      body: Center(child: Text("App Allowed")),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        width: double.infinity,
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: [Colors.redAccent, Colors.orange],
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
          ),
        ),
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Icon(Icons.warning_amber_rounded, size: 100, color: Colors.white),
              SizedBox(height: 20),
              Text(
                "Payment Pending",
                style: TextStyle(
                  fontSize: 26,
                  fontWeight: FontWeight.bold,
                  color: Colors.white,
                ),
              ),
              SizedBox(height: 10),
              Text(
                "Please complete your payment to continue using the app.",
                textAlign: TextAlign.center,
                style: TextStyle(color: Colors.white70),
              ),
              SizedBox(height: 30),
              ElevatedButton(onPressed: () {}, child: Text("Retry Payment")),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
140
points
38
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter package for app access control using Firebase Remote Config and FCM.

License

MIT (license)

Dependencies

firebase_core, firebase_messaging, firebase_remote_config, flutter, get, shared_preferences

More

Packages that depend on app_access_guard