Skip to content

Instantly share code, notes, and snippets.

@cktgh
Last active April 17, 2025 10:16
Show Gist options
  • Save cktgh/af62e416c97e70a0001a623846fbb768 to your computer and use it in GitHub Desktop.
Save cktgh/af62e416c97e70a0001a623846fbb768 to your computer and use it in GitHub Desktop.
DartPad Template
//----------------------------------------------------------------------------//
extension KtScopeFunction<T> on T {
R let<R>(R Function(T it) block) => block(this);
T also(void Function(T it) block) { block(this); return this; }
T? takeIf(bool Function(T it) predicate) => predicate(this) ? this : null;
T? takeUnless(bool Function(T it) predicate) => predicate(this) ? null : this;
}
T run<T>(T Function() block) => block();
// ignore: non_constant_identifier_names
Never TODO([String? message]) =>
throw UnimplementedError(message ?? '`TODO` not implemented.');
extension Tlog<T> on T {
T log([Object Function(T)? transform]) {
print((transform?.call(this) ?? this).toString());
return this;
}
}
//----------------------------------------------------------------------------//
void main() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment