kill_switch_flutter 1.0.0
kill_switch_flutter: ^1.0.0 copied to clipboard
A Flutter Package That Provides A Kill Switch Functionality For Apps Using Firebase Firestore
example/lib/main.dart
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:kill_switch_example/firebase_options.dart';
import 'package:kill_switch_flutter/kill_switch.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Kill Switch Example',
theme: ThemeData(
brightness: Brightness.dark,
scaffoldBackgroundColor: const Color(0xFF2C2C2E),
colorScheme: const ColorScheme.dark(
primary: Colors.red,
secondary: Colors.white,
surface: Color(0xFF2C2C2E),
),
snackBarTheme: const SnackBarThemeData(
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.red,
contentTextStyle: TextStyle(color: Colors.white),
),
),
home: KillSwitchWrapper(child: MainDemoScreen()),
);
}
}
class MainDemoScreen extends StatelessWidget {
const MainDemoScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFF2C2C2E),
body: Center(
child: Padding(
padding: const EdgeInsets.all(40.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Spacer(),
const Text(
'KILL SWITCH DEMO',
style: TextStyle(
color: Colors.white,
fontSize: 28,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 32),
const Text(
'This Screen Demonstrates The Kill Switch Functionality. When Enabled, A Dialog Will Appear Instantly.',
style: TextStyle(
color: Colors.white70,
fontSize: 16,
height: 1.5,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 32),
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const FlutterKillSwitch(),
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
elevation: 0,
),
child: const Text(
'Admin Panel - Toggle Kill Switch',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
),
),
),
const SizedBox(height: 24),
const Text(
'Try Enabling The Kill Switch In Admin Panel To Instantly See The Dialog',
style: TextStyle(color: Colors.white60, fontSize: 14),
textAlign: TextAlign.center,
),
const Spacer(),
],
),
),
),
);
}
}