consume<T> function

T? consume<T>(
  1. BuildContext context, [
  2. void exec(
    1. T value
    )?
])

Implementation

T? consume<T>(BuildContext context, [void exec(T value)?]) {
  try {
    final t = Provider.of<T>(context, listen: false);
    exec?.call(t);
    return t;
  } on ProviderNotFoundException {
    return null;
  }
}