import 'dart:async'; extension ObjectExtension on T { /// Run [fn] with this, and return this T apply(void Function(T obj) fn) { fn(this); return this; } /// Run [fn] with this, and return this Future applyFuture(FutureOr Function(T obj) fn) async { await fn(this); return this; } /// Run [fn] with this, and return the results of [fn] U run(U Function(T obj) fn) => fn(this); /// Run [fn] with this, and return the results of [fn] Future runFuture(FutureOr Function(T obj) fn) async { return await fn(this); } }