Skip to content
This repository was archived by the owner on Oct 12, 2024. It is now read-only.

Commit b943c06

Browse files
committed
Add tryOrNull extension to Function class
1 parent 7f6a124 commit b943c06

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

lib/src/_all_src.g.dart

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export 'core/src/paths.dart';
4040
export 'core/src/post_destruction_checker.dart';
4141
export 'core/src/rec.dart';
4242
export 'core/src/screen_calculator.dart';
43+
export 'core/src/try_or_null_on_function_extension.dart';
4344
export 'core/src/type_message_mixin.dart';
4445
export 'core/src/value_of_on_enum_extension.dart';
4546
export 'core/src/version.dart';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//.title
2+
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
3+
//
4+
// 🇽🇾🇿 & Dev
5+
//
6+
// Copyright Ⓒ Robert Mollentze, xyzand.dev
7+
//
8+
// Licensing details can be found in the LICENSE file in the root directory.
9+
//
10+
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
11+
//.title~
12+
13+
extension TryOrNullOnFunctionExtension on Function {
14+
T? tryOrNull<T>(
15+
List<dynamic>? positionalArguments, [
16+
Map<Symbol, dynamic>? namedArguments,
17+
]) {
18+
try {
19+
return Function.apply(
20+
this,
21+
positionalArguments ?? [],
22+
namedArguments ?? {},
23+
) as T?;
24+
} catch (_) {
25+
return null;
26+
}
27+
}
28+
}

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
name: xyz_utils
1414
description: This package provides a set of utilities that are commonly used in Dart apps. It is also the foundation for other packages in the XYZ ecosystem.
1515
repository: https://github.com/robmllze/xyz_utils
16-
version: 0.61.0
16+
version: 0.62.0
1717

1818
## -----------------------------------------------------------------------------
1919

0 commit comments

Comments
 (0)