NitroResult class

Marks a method's return type as a discriminated success/error result.

When a method is annotated with @NitroResult(), the native implementation can signal failure by writing an error tag + message instead of a value. Dart receives a NitroResultValue sealed type — either NitroOk<T> or NitroErr — without throwing an exception.

Wire format: [1B tag: 0=ok, 1=err][payload]

  • tag 0 (ok): record-codec bytes for T
  • tag 1 (err): 4B string length + UTF-8 error message

The method's Dart return type must be Future<NitroResultValue<T>> or NitroResultValue<T> (with @nitroAsync / @NitroNativeAsync as appropriate).

Example:

@NitroResult()
Future<NitroResultValue<String>> login(String user, String password);

Constructors

NitroResult()
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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