agent_gate_riverpod 0.1.0 copy "agent_gate_riverpod: ^0.1.0" to clipboard
agent_gate_riverpod: ^0.1.0 copied to clipboard

Riverpod integration for agent_gate — AI-agnostic behavioural routing middleware for Flutter. Adds gateDecisionProvider, GateNotifier and a GateListener widget.

agent_gate_riverpod #

Riverpod 3 integration for agent_gate — the AI-agnostic behavioural routing middleware for Flutter.

Riverpod has no router, so this package is deliberately small: it maps AgentGate onto providers and a listener widget. Navigation itself goes through whichever AgentGate.adapter you configured (Navigator, GoRouter, GetX…).

dependencies:
  agent_gate: ^0.1.0
  agent_gate_riverpod: ^0.1.0
  flutter_riverpod: ^3.0.0

Declarative — gateDecisionProvider #

Decide when a widget builds and render the chosen candidate inline:

class CheckoutGateScreen extends ConsumerWidget {
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return ref.watch(gateDecisionProvider(checkoutGate)).when(
      loading: () => const AgentLoadingView(),
      error: (e, _) => Text('$e'),   // decisions never error (fallback), but AsyncValue needs it
      data: (d) => checkoutGate.candidate(d.candidateId)!.builder!(context),
    );
  }
}

Need per-navigation context? ref.watch(gateDecisionWithExtraProvider(GateArgs(checkoutGate, {'coupon': code}))).

Imperative — GateNotifier + GateListener #

Decision is state; navigation is a widget-layer side effect:

GateListener(
  onNavigated: (ctx, ref, o) => ref.read(gateNotifierProvider.notifier).reset(),
  child: CartView(),
)

// on "Checkout" tap:
ref.read(gateNotifierProvider.notifier).decide(checkoutGate, extra: {'total': cart.total});

State is AsyncValue<GateOutcome?>: null = idle, loading = deciding, data = decided (GateOutcome.isFallback tells you the AI didn't decide). It never enters the error state from a decision.

Options on GateListener: onDecided (custom navigation), navigateOnFallback, showLoading, provider (your own AsyncNotifierProvider<GateNotifier, …>).

Or navigate directly: ref.read(gateNotifierProvider.notifier).navigate(gate, context: context).

License #

MIT © MSI Shamim / Increments Inc.

0
likes
150
points
103
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Riverpod integration for agent_gate — AI-agnostic behavioural routing middleware for Flutter. Adds gateDecisionProvider, GateNotifier and a GateListener widget.

Homepage
Repository (GitHub)
View/report issues

Topics

#navigation #riverpod #ai #agent

License

MIT (license)

Dependencies

agent_gate, flutter, flutter_riverpod

More

Packages that depend on agent_gate_riverpod