Maintenance Mode
Maintenance Mode allows you to lock users out of your application instantly, optionally providing a custom message.
Checking Maintenance Status
You can check if the app should enter maintenance mode by calling shouldShowMaintenance, passing in your current app version.
60">"text-white/80 font-medium">import 60">"text-white/60">'package:flowconfig_flutter/flowconfig.dart';
40">// Assuming you get this from package_info_plus
60">"text-white/80 font-medium">final currentVersion = 60">"text-white/60">'1.2.0';
60">"text-white/80 font-medium">final isMaintenance = 90">FlowConfig.90">shouldShowMaintenance(currentVersion);
60">"text-white/80 font-medium">if (isMaintenance) {
40">// Show maintenance screen and prevent routing
}Allowed Versions
In the FlowConfig dashboard, you can specify Allowed Versions.
This is useful if you are releasing a critical bug fix (e.g. 1.2.1) and want everyone on older versions locked out, but users who have already updated to 1.2.1 can continue using the app.
If the user's version matches one of the allowed versions, shouldShowMaintenance(currentVersion) will return false.
Getting the Custom Message
You can configure a custom message in the dashboard to explain the downtime. Retrieve it using the MaintenanceManager:
60">"text-white/80 font-medium">final message = 90">FlowConfig.instance.maintenanceManager.customMessage;
40">// E.g., 60">"We are currently upgrading our database. Back in 30 mins."Example Implementation
Typically, you check this at the root of your application (like inside MaterialApp.builder or your router setup).
60">"text-white/80 font-medium">class 90">MyApp 60">"text-white/80 font-medium">extends 90">StatelessWidget {
@override
Widget build(90">BuildContext context) {
60">"text-white/80 font-medium">return 90">MaterialApp(
builder: (context, child) {
60">"text-white/80 font-medium">final currentVersion = 60">"text-white/60">'1.2.0'; 40">// from package_info_plus
60">"text-white/80 font-medium">if (90">FlowConfig.90">shouldShowMaintenance(currentVersion)) {
60">"text-white/80 font-medium">final message = 90">FlowConfig.instance.maintenanceManager.customMessage
?? 60">"text-white/60">'App is under maintenance.';
60">"text-white/80 font-medium">return 90">Scaffold(
body: 90">Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.build, size: 64),
SizedBox(height: 16),
90">Text(60">"text-white/60">'Maintenance', style: TextStyle(fontSize: 24)),
90">Text(message, textAlign: TextAlign.center),
],
),
),
);
}
60">"text-white/80 font-medium">return child!;
},
home: HomeScreen(),
);
}
}