HQ DevTools

pub package Flutter Platform License: MIT

A professional developer error widget and diagnostics tool for Flutter applications, bringing Crashlytics-level on-device error reporting directly to your debug builds.

hq_devtools replaces the standard "Red Screen of Death" with an elegant, detailed, and actionable Bottom Sheet designed to aid developers and QA testers in debugging directly on the device without needing a connected IDE.

Features

  • Beautiful Error UI: Replaces standard Flutter errors with an interactive details screen.
  • Intelligent Stack Trace Parsing: Formats and highlights the most important frames, making it easy to find where the app crashed.
  • Environment Context: Automatically attaches device model, OS version, Flutter version, and app version.
  • Log Integration: Connect your app's logging framework (e.g., logger or custom prints) to display recent logs just before the crash.
  • Export and Share: Instantly copy errors to the clipboard, share them via the OS share sheet, or export them in .txt or .json formats.
  • Localization Ready: Override UI strings via configuration to match your app's language or brand.

Getting Started

Installation

From the command line:

flutter pub add hq_devtools

Or add hq_devtools to your pubspec.yaml dependencies:

dependencies:
  hq_devtools: ^0.0.1

Run flutter pub get to install the package.


Usage

To get the most out of hq_devtools, you should intercept all types of errors in your main.dart before calling runApp.

1. Basic Setup (Catching UI & Platform Errors)

import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:hq_devtools/hq_devtools.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  // 1. Initialize configuration (Enable in Debug/Profile modes only)
  HqDevToolsConfig.init(
    HqDevToolsConfig(
      showDeveloperErrorDetails: true,
      onLogsRequested: (from, to) async {
        return "[INFO] App started successfully\n[WARN] Slow network";
      },
      onNetworkLogsRequested: (from, to) async {
        return "GET /api/users - 200 OK\nPOST /api/login - 401 Unauthorized";
      },
    ),
  );

  // 2. Catch UI Rendering errors (Replaces Red Screen of Death)
  ErrorWidget.builder = (FlutterErrorDetails details) {
    return DeveloperErrorWidget(details: details);
  };

  // 3. Catch general Flutter framework errors
  FlutterError.onError = (FlutterErrorDetails details) {
    FlutterError.presentError(details);
  };

  // 4. Catch asynchronous & platform errors
  PlatformDispatcher.instance.onError = (Object error, StackTrace stackTrace) {
    debugPrint('Platform Error Caught: $error');
    return true;
  };

  runApp(const MyApp());
}

2. Manual Triggering

Sometimes you want to catch an error manually and display the DevTools sheet without crashing the UI. You can do this by using HqDevTools.showErrorSheet:

try {
  throw StateError("Invalid user state detected");
} catch (e, stack) {
  final details = FlutterErrorDetails(
    exception: e,
    stack: stack,
    library: 'Authentication Bloc',
    context: ErrorDescription('Validating user token'),
  );

  // Displays the professional BottomSheet
  HqDevTools.showErrorSheet(context, details: details);
}

Configuration, Theming & Localization

You can fully customize the UI (colors, icons, and text) to match your app's brand by providing your own HqDevToolsTheme and HqDevToolsStrings objects.

HqDevToolsConfig.init(
  HqDevToolsConfig(
    // 1. Customize Colors & Icons
    theme: const HqDevToolsTheme(
      backgroundColor: Colors.black87,
      errorColor: Colors.redAccent,
      primaryColor: Colors.blueAccent,
      copyIcon: Icons.copy_all,
      // ... customize other colors and icons
    ),
    // 2. Customize Text (Localization)
    strings: const HqDevToolsStrings(
      title: 'Oh snap! The app crashed',
      tapForDetails: 'Tap here to see what went wrong',
      copyError: 'Copy Error Log',
      exportJson: 'Export as JSON',
      // ... customize all other strings
    ),
  ),
);

Additional information

  • Contributions: Feel free to submit pull requests or file issues in the repository.
  • Support: This package relies on share_plus, device_info_plus, and package_info_plus to gather hardware details and export logs. Ensure your host application is compatible with these plugins.

Made with love by HighQ Apps.