ChuckCore class

Core class that manages HTTP call interception, storage, and UI navigation.

This class provides the main functionality for:

  • Intercepting and storing HTTP requests/responses
  • Handling shake-to-open functionality
  • Memory management with configurable call limits
  • Navigation to the inspector UI

The class uses RxDart's BehaviorSubject for reactive state management, ensuring that UI components automatically update when new HTTP calls are added.

Constructors

ChuckCore(GlobalKey<NavigatorState>? navigatorKey, {required bool showInspectorOnShake, required int maxCallsCount, bool enabled = true, int maxBodySize = 1024 * 1024, Future<ChuckPackageInfo?> packageInfoProvider()?, ChuckShareCallback? onShare})
Creates Chuck core instance

Properties

callsStream → Stream<List<ChuckHttpCall>>
Reactive stream of all intercepted HTTP calls.
no setter
callsSubject → BehaviorSubject<List<ChuckHttpCall>>
Reactive stream containing all intercepted HTTP calls Uses BehaviorSubject to maintain the latest state and allow new subscribers to receive the current value immediately
final
enabled → bool
Whether Chuck interceptor is enabled
final
hashCode → int
The hash code for this object.
no setterinherited
inspectorOpened → ValueNotifier<bool>
Whether the inspector screen is currently on top of the navigation stack. Listenable so UI (e.g. the floating Chuck button) can hide itself while it is open.
final
maxBodySize → int
Maximum size of request/response body in bytes to store in memory (default: 256 KB)
final
maxCallsCount → int
Maximum number of HTTP calls to store in memory When this limit is reached, the oldest calls are removed using FIFO policy
final
getter/setter pair
onShare → ChuckShareCallback?
Shares logs through the host app. Share actions are hidden when null.
final
packageInfoProvider → Future<ChuckPackageInfo?> Function()?
Supplies ChuckPackageInfo for the header of exported logs. Optional: logs omit app details without it.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
showInspectorOnShake → bool
Whether to open the inspector when the device is shaken (physical devices only)
final

Methods

addCall(ChuckHttpCall call) → void
Add Chuck http call to calls subject with optimized memory management
addError(ChuckHttpError error, int requestId) → void
Add error to existing Chuck http call with improved error handling
addHttpCall(ChuckHttpCall chuckHttpCall) → void
Add Chuck http call to calls subject
addResponse(ChuckHttpResponse response, int requestId) → void
Add response to existing Chuck http call with improved error handling
dispose() → void
Dispose subjects and subscriptions
getContext() → BuildContext?
Get context from navigator key. Used to open inspector route.
getPackageInfo() → Future<ChuckPackageInfo?>
Host application info from packageInfoProvider, resolved once and cached. Returns null when no provider is set or it throws.
Opens Http calls inspector. This will navigate user to the new fullscreen page where all listened http calls can be viewed.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeCalls() → void
Remove all calls from calls subject
saveHttpRequests(BuildContext context) → Future<void>
Save all calls to file
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited