β coffee_required

Because running your app before coffee is a breaking change.
coffee_required is a humorous yet practical Flutter debug-only guard that helps you:
- β Block coding before your brain boots (default: 9 AM).
- π€ Warn about late-night commits (default: 11 PM).
- π§ Enforce healthy breaks during long sessions.
- π Roast you with sarcastic logs and overlays.
β¨ Why coffee_required?
Every developer has done one of these:
- Started debugging at 7:30 AM with zero caffeine.
- Shipped a bug at 1:42 AM because "it worked on my machine".
- Fixed something that wasn't broken.
coffee_required acts as a lightweight development gate that nudges you toward better habitsβwith sarcasm and β.
Important
Safety Guarantee: All logic is strictly guarded by kDebugMode || kProfileMode. In release builds, every method becomes a no-op to ensure zero impact on production apps.
π Features
β° Time-Based Coffee Gate
Block or warn when starting the app too early.
CoffeeRequired.ensure();
β βItβs 07:42. Your brain is still compiling.β
π "Corporate" Mode (New!)
Passive-aggressive messages for the office environment.
CoffeeConfig(roastLevel: CoffeeRoastLevel.corporate);
π βPer company policy, coding before coffee is not optimized for synergy.β
π¬ Custom Team Roasts
Inject your own team's inside jokes.
CoffeeConfig(
customMessages: {
CoffeeSituation.beforeMinHour: ["Dave, go back to sleep."],
},
);
π§ "I Had Coffee" Override
Bypass the gate for a configurable duration. Perfect for when you promise you are awake.
π¦ Installation
Add this to your pubspec.yaml:
dependencies:
coffee_required: ^1.0.0
π§ͺ Usage
Call before runApp():
import 'package:coffee_required/coffee_required.dart';
import 'package:flutter/material.dart';
void main() {
// 1. Initialize
CoffeeRequired.init(
config: const CoffeeConfig(
mode: CoffeeMode.warnOnly, // or blockApp
minHour: 9,
maxHour: 23,
roastLevel: CoffeeRoastLevel.sarcastic, // polite, sarcastic, savage, corporate
),
);
// 2. Enforce the gate
CoffeeRequired.ensure();
// 3. Optional: Start break reminders
CoffeeRequired.remindBreaks();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My App',
// β οΈ IMPORTANT: Add the navigatorKey to see overlays!
navigatorKey: CoffeeRequired.navigatorKey,
home: const Scaffold(body: Center(child: Text("Hello World"))),
);
}
}
βοΈ Configuration
CoffeeConfig allows full customization:
| Property | Type | Default | Description |
|---|---|---|---|
enabled |
bool |
true |
Turn off if you dislike fun. |
mode |
CoffeeMode |
blockApp |
blockApp (throws), warnOnly (overlay). |
minHour |
int |
9 |
Hour before which coding is forbidden. |
roastLevel |
CoffeeRoastLevel |
sarcastic |
Tone of the messages. |
customMessages |
Map |
null |
Your own message overrides. |
allowOverride |
bool |
true |
Allow the "I had coffee" button. |
π‘οΈ License
MIT License. Use it, fork it, roast your team with it.