given<T> function

FutureOr<T> given<T>(
  1. String description,
  2. FutureOr<T> body(
      )
    )

    Implementation

    FutureOr<T> given<T>(String description, FutureOr<T> Function() body) {
      final givens = Zone.current[givenKey] as List<String>?;
    
      if (givens == null) throw Exception('Use gwt method');
    
      final state = Zone.current[stateKey] as State;
      state.key = givenKey;
      givens.add(description);
    
      final result = body();
    
      if (result is Future) {
        return Future.sync(() async => await result);
      } else {
        return result;
      }
    }