builder static method

TransitionBuilder builder({
  1. bool enabled = kDebugMode,
  2. TransitionBuilder? builder,
  3. Color? backgroundColor,
  4. Color? foregroundColor,
  5. IconData icon = Icons.bug_report_rounded,
  6. double buttonSize = 56,
  7. bool showBadge = true,
  8. Alignment initialAlignment = Alignment.centerLeft,
  9. bool snapToEdge = true,
})

A builder for MaterialApp.builder that shows the draggable debug button.

MaterialApp(builder: DioDebugLogger.builder());

enabled defaults to false in release builds. If the app already has a builder, pass it as builder:

MaterialApp(
  builder: DioDebugLogger.builder(
    builder: (context, child) => MediaQuery(..., child: child!),
  ),
);

Implementation

static TransitionBuilder builder({
  bool enabled = kDebugMode,
  TransitionBuilder? builder,
  Color? backgroundColor,
  Color? foregroundColor,
  IconData icon = Icons.bug_report_rounded,
  double buttonSize = 56,
  bool showBadge = true,
  Alignment initialAlignment = Alignment.centerLeft,
  bool snapToEdge = true,
}) {
  if (enabled) ReleaseGuard.check('The debug button');
  return (BuildContext context, Widget? child) {
    final content = builder != null ? builder(context, child) : child;
    return DebugOverlay(
      enabled: enabled,
      backgroundColor: backgroundColor,
      foregroundColor: foregroundColor,
      icon: icon,
      buttonSize: buttonSize,
      showBadge: showBadge,
      initialAlignment: initialAlignment,
      snapToEdge: snapToEdge,
      child: content ?? const SizedBox.shrink(),
    );
  };
}