Skip to main content

corextra 1.2.11 copy "corextra: ^1.2.11" to clipboard
corextra: ^1.2.11 copied to clipboard

Handy Dart extensions and utility functions for easier coding.

corextra #

Handy Dart extensions and utilities for Flutter — plus form validators, responsive helpers, logging, and an in-app DevTools panel.

pub package

Works on Android, iOS, Web (including WASM), macOS, Windows, and Linux.


Getting Started #

Add the dependency:

dependencies:
  corextra: ^1.2.11

Import it:

import 'package:corextra/corextra.dart';

Features #

Extensions #

  • Null-safe checks: .isNullOrEmpty on String? and List?
  • Safe conversions: .toTryInt(), .toTryDouble(), .toTryBool()
  • String helpers: .capitalize(), .toPascalCase(), .toCamelCase()
  • DateTime parsing and formatting
  • safeSetState — calls setState() only if the widget is still mounted

Form Validators #

  • required, email, phone, otp, password, confirmPassword
  • minLength, maxLength, numeric, url, pattern
  • FormValidators.compose([...]) — run several validators, return the first error
  • FormValidators.optional(validator) — skip validation when a non-required field is empty
  • Every validator accepts a custom message:
  • Optional translations via easy_localization

Responsive #

  • ResponsiveBreakpoints — sm / md / lg / xl / xxl on BuildContext or BoxConstraints
  • deviceType, isMobile, isTablet, isDesktop
  • responsive<T>(base: ..., md: ..., lg: ...) — pick a value per screen size, no LayoutBuilder needed
  • screenWidth, screenHeight, isPortrait, isLandscape on BuildContext

Error Handling #

  • CorextraException, CorextraCustomException, CorextraNetworkException
  • DioErrorHandler — turns Dio errors into clear, typed exceptions

Logging #

  • debugLog — simple logger with levels (info / warning / error). Prints in debug builds and shows in the DevTools Logs tab
  • AppLogger — structured logs for app events and Dio requests
  • AppLoggerInterceptor — pretty, color-coded Dio logs (turn off with enabled: false)
  • CorextraSocketLogger — logs socket messages to the console and DevTools. See Socket Logging

Animation #

  • FadeSlideTransition — fade + slide in from top, bottom, left, right, or a custom offset

DevTools Panel #

An in-app inspector, like Flutter DevTools but inside your app. No extra setup or connection needed.

MaterialApp(
  builder: (context, child) =>
      CorextraDevToolsOverlay(child: child ?? const SizedBox.shrink()),
  home: const HomeScreen(),
)

dio.interceptors.add(const CorextraDevToolsInterceptor());

Tap the floating bubble to open the panel.

Tab What it shows
Network Every HTTP request and socket message. Filter by method or status.
Logs Every debugLog / AppLogger call. Filter by level.
Info App version and device details (the browser, on web).

Find anything — the search box at the top works like a browser's find:

  • Searches every tab at once: URLs, headers, request and response bodies, logs, and app info
  • Every match is highlighted; the current one in orange
  • Press Enter (or the arrows) to jump to the next match — DevTools opens the right tab, request, and section for you
  • Each tab shows how many matches it holds
  • Shift+Enter goes back, Esc clears, Cmd/Ctrl+F focuses the box

In the Network tab:

  • Headers, query params, and body each get their own tab
  • JSON shows as a collapsible, color-coded tree
  • Large bodies scroll inside their own box
  • Copy, Share, and Fullscreen buttons stay in view while you scroll
  • Auth headers (Authorization, Cookie, …) get a TOKEN badge. Hide their values on screen with hiddenHeaders — Copy still gives the real value

Good to know:

  • Tap Minimize to shrink the panel into a small floating window
  • Long lists and large bodies have easy-to-grab scrollbars — drag along the right edge, or tap it to jump
  • Android's back button closes the panel step by step, without affecting your app
  • On web, Share opens the browser's share sheet, or copies to the clipboard if the browser doesn't have one
  • On in debug builds, off in release. Change it anytime with CorextraDevTools.instance.enabled = true
  • Built to stay out of your way, even with constant API traffic: console logs are formatted between frames instead of inside your requests, the panel refreshes a few times a second at most, and huge responses open instantly

Coming later: widget inspector, memory snapshots, storage viewer, and route inspector.


Socket Logging #

CorextraSocketLogger logs every socket message in two places:

  • Console — a color-coded block per message (debug builds only)
  • DevTools — a row in the Network tab (filter by Socket)

It works with any socket library (Socket.IO, WebSocket, etc.). Call it wherever you send or receive:

final logger = CorextraSocketLogger(url: socketUrl);

// Messages from the server
socket.onAny((event, [data]) => logger.receive(event, data));
socket.onConnectError((error) => logger.receive('connect_error', error, isError: true));

// Messages you send
logger.emit('chat:open', payload);
socket.emit('chat:open', payload);

// Messages you send and wait for a reply (ack)
final ack = await logger.emitWithAck(
  'chat:latest_messages',
  payload,
  () => socket.timeout(15000).emitWithAckAsync('chat:latest_messages', payload),
);

Each row in DevTools shows the event name, EMIT (sent) or ON (received), and its status: OK, ERR, or pending while waiting for an ack.

Option Default What it does
consoleEnabled true Turn console logs on or off
devToolsEnabled follows CorextraDevTools.instance.enabled Turn DevTools capture on or off
captureBody true Save message data in DevTools
maxBodyLength 100000 Trims text messages longer than this

Example #

A runnable demo app, including the DevTools panel, lives in example/:

cd example
flutter pub get
flutter run
8
likes
0
points
1.02k
downloads

Publisher

unverified uploader

Weekly Downloads

Handy Dart extensions and utility functions for easier coding.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

device_info_plus, dio, flutter, intl, lucide_icons_flutter, package_info_plus, share_plus, web

More

Packages that depend on corextra