Fluxy DevTools
Unlocking powerful debugging and stability features with Fluxy.
Fluxy DevTools
Fluxy DevTools provides a suite of tools for Stability Management, guarding against categories of crashes that standard Flutter apps often succumb to.
1. The Stability Kernel
Fluxy proactively scans your widget tree for violations. You control its aggression level using Fluxy.setStrictMode(bool).
Strict vs. Relaxed Mode
-
Relaxed Mode (Default): Designed for Production.
- Behavior: When a crash-inducing error is detected, Fluxy auto-repairs it, logs a silent warning, and keeps the app running.
- Goal: Ensure 99.99% uptime. Users should never see a "Grey Screen of Death".
- Trade-off: May introduce minor performance hits (e.g., auto-applied
shrinkWrap) to save the crash.
-
Strict Mode: Designed for Development.
- Behavior: Intentionally throws a
FluxyLayoutViolationExceptionimmediately upon detection. - Goal: Force you to fix the root cause instead of relying on Fluxy's safety net.
- Behavior: Intentionally throws a
Recommendation: Always enable Strict Mode in debug builds to catch "lazy" layout practices that Fluxy is secretly fixing for you.
void main() async {
await Fluxy.init();
// Enable strict mode locally to catch bugs early
if (kDebugMode) {
Fluxy.setStrictMode(true);
}
runApp(MyApp());
}2. Crash Prevention Categories
Fluxy automatically wraps common primitives (like Fx.scaffold, Fx.col, Fx.scroll) in its internal guards (FluxyViewportGuard, FxSafeExpansion), making manual SafeArea or constraint checks often redundant.
Type A: Layout Crashes (The "Red Screen")
Fluxy translates cryptic RenderFlex errors into readable alerts.
| Crash Scenario | Fluxy Detection | Relaxed Mode Auto-Fix |
|---|---|---|
| Infinite Scroll (List inside Column) | "Unbounded Height" violation. | Forces shrinkWrap: true and disables inner scrolling. |
| The "Stretch" Crash | CrossAxisAlignment.stretch in scrollable direction. | Swaps alignment to .center instantly. |
| Unbounded Expansion | Expanded inside a ScrollView. | Removes the Expanded wrapper via FxSafeExpansion. |
Type B: Render & Paint Crashes
These occur deeper in the pipeline, often freezing the UI thread.
- Dual Infinity:
- Crash: A widget requests
double.infinityfor both width and height without a parent boundary. - Fix: Fluxy clamps the size to the window dimensions.
- Crash: A widget requests
- NaN Geometry:
- Crash: Calculating a size of
NaNorInfinity(e.g., dividing by zero in a custom painter). - Fix:
RenderStabilityGuarddetects invalid geometry and falls back to0x0.
- Crash: Calculating a size of
- Painting Exceptions:
- Crash: An error thrown during
paint(). - Fix:
FluxyRenderGuardcatches the exception and draws a red placeholder box instead of crashing the entire route.
- Crash: An error thrown during
Type C: Async & Lifecycle Crashes
- "SetState() after dispose()":
- Crash: An async API call returns after the user navigates away, trying to update a disposed widget.
- Fix:
FluxyAsyncGuardcheckscontext.mountedbefore every reactive update and silently drops the frame if unmounted.
3. Visual Layout Inspector
Wrap your app root to enable the visual inspector overlay.
void main() {
runApp(
Fluxy.debug(
child: MyApp(),
),
);
}- Toggle Inspector: Shake device or press the on-screen generic button.
- Highlight Overflows: Draws red boxes around widgets that are clipping or overflowing.
- Repaint Rainbow: visualized to debug excessive rebuilds.
4. Stability Metrics
Fluxy tracks every intercepted crash and auto-repair. You can view this summary to audit your app's health.
Interpreting the Report
- Prevented Crashes: Critical errors that would have stopped the app (e.g., Paint exceptions).
- Layout Repairs: "Lazy" code fixes (e.g., Infinite Scroll) that you should fix in Strict Mode.
- Viewport Saves: Number of times
FluxyViewportGuardprevented content from being clipped or hidden.
Example: Log on Crash
Hook into your global error handler to print the stability report whenever an exception occurs.
void main() {
Fluxy.onError((error, stack) {
debugPrint("Fluxy Global Error: $error");
// Check if the system was already unstable
Fluxy.printStabilitySummary();
});
runApp(MyApp());
}Sample Output:
[Fluxy Stability] Session Report:
- Prevented Crashes: 3
- Layout Repairs: 12
- Infinite Scroll Fixed: 8
- Safe Expansion Triggered: 4
- Viewport Saves: 5By understanding these metrics, you can audit your codebase for "silent failures" that Fluxy is handling for you.