kill_switch_flutter 0.0.1
kill_switch_flutter: ^0.0.1 copied to clipboard
A Flutter Package That Provides A Kill Switch Functionality For Apps Using Firebase Firestore
Kill Switch #
A Flutter package that provides a kill switch functionality for your app using Firebase Firestore. This package allows app owners to remotely disable their app for users with a sleek, professional interface.
β¨ Features #
- ποΈ Professional Kill Switch UI - Dark themed interface with large Cupertino-style switch
- π Secure Confirmation System - Custom keyboard with "IWANNAENABLE" confirmation
- π₯ Firebase Integration - Real-time monitoring using Cloud Firestore
- π« Non-Dismissible App Blocking - Complete app blocking when kill switch is active
- π± Cross-Platform Support - Works on both iOS and Android
- β‘ Real-time Updates - Instant kill switch activation across all user devices
π Prerequisites #
Before using this package, ensure you have:
1. Firebase Setup #
Your Flutter app must have Firebase configured and initialized:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
2. Firestore Database #
- Cloud Firestore must be enabled in your Firebase project
- Set up appropriate Firestore security rules
3. Required Dependencies #
Add these to your app's pubspec.yaml
:
dependencies:
firebase_core: ^2.17.0
cloud_firestore: ^4.13.0
flutter_kill_switch: ^1.0.0
π Installation #
Add this to your package's pubspec.yaml
file:
flutter pub add kill_switch
Or manually add to your pubspec.yaml
:
dependencies:
kill_switch: ^1.0.0
Then run:
flutter pub get
π Usage #
Step 1: Import the Package #
import 'package:kill_switch/kill_switch.dart';
Step 2: Wrap Your Main App #
Wrap your main app widget with KillSwitchWrapper
to enable monitoring:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My App',
home: KillSwitchWrapper(
child: YourMainScreen(), // Your app's main screen
),
);
}
}
Step 3: Navigate to Kill Switch Screen #
Replace your admin/settings navigation with:
// Instead of navigating to your custom admin screen
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => FlutterKillSwitch(), // Use the package screen
),
);
Complete Example #
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:kill_switch/kill_switch.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My App',
home: KillSwitchWrapper(
child: MainScreen(),
),
);
}
}
class MainScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('My App')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Welcome to My App', style: TextStyle(fontSize: 24)),
SizedBox(height: 40),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => FlutterKillSwitch(),
),
);
},
child: Text('Admin Panel'),
),
],
),
),
);
}
}
π§ How It Works #
Kill Switch Activation Process #
- Admin navigates to kill switch screen
- Toggle switch to enable kill switch
- Confirmation dialog appears with custom keyboard
- Type "IWANNAENABLE" to confirm action
- Kill switch activates and updates Firebase
- All user devices receive the update instantly
- App blocking dialog appears for all users
- Users must close the app
Firebase Firestore Structure #
The package creates this structure in your Firestore database:
π IAmNothing/
π NothingInsideMe/
π WhyAreYouFollowingThisCollection/
π here/
β
FlutterKillSwitch: boolean
π
lastUpdated: timestamp
Don't worry about the funny collection names - they're intentionally obscure for security! π
π¨ Screenshots #
Kill Switch Screen #
- Dark themed interface matching modern design standards
- Large, responsive Cupertino switch
- Clear warning messages
Confirmation Dialog #
- Custom keyboard with capital letters only
- Real-time text validation with color feedback
- Secure confirmation process
App Blocking Dialog #
- Professional blocking interface
- Non-dismissible dialog (back button disabled)
- Clean "Close App" functionality
π Security Features #
- Custom Collection Path: Uses obscure Firestore paths
- Confirmation Required: Must type specific text to enable
- Real-time Monitoring: Instant activation across devices
- Non-Dismissible: Users cannot bypass the kill switch
- Automatic Closure: Forces app termination when active
β οΈ Important Notes #
- Firebase Required: This package requires active Firebase/Firestore setup
- Internet Connection: Kill switch requires internet to function
- Admin Access: Only admins should have access to the kill switch screen
- Testing: Test thoroughly in development before production use
- Backup Plan: Have alternative communication channels with users
π Troubleshooting #
Common Issues #
Firebase not initialized:
// Ensure Firebase is initialized before runApp()
await Firebase.initializeApp();
Firestore permissions:
// Update Firestore rules to allow read/write
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true; // Adjust as needed
}
}
}
Kill switch not activating:
- Check internet connection
- Verify Firestore setup
- Ensure KillSwitchWrapper is properly implemented
π€ Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
π License #
This project is licensed under the MIT License - see the LICENSE file for details.
π€ Author #
Muzamil Ghafoor
- GitHub: @muzamilghafoor
- Email: deadbase763@gmail.com
π Acknowledgments #
- Flutter team for the amazing framework
- Firebase team for the backend services
- Open source community for inspiration
π Changelog #
[1.0.0] - 2025-01-XX #
- Initial release
- Kill switch functionality
- Firebase integration
- Custom confirmation system
- App blocking feature
Made with β€οΈ by Muzamil Ghafoor