ff_trycatch

Last updated:

0 purchases

ff_trycatch Image
ff_trycatch Images
Add to Cart

Description:

ff trycatch

TryCatch #


A utility class that provides helper methods for performing error handling and exception handling in synchronous and asynchronous operations.
Features #

Provides both asynchronous and synchronous methods
Upfront handling of common cases from execution to success/failure

Usage #
TryCatch.async() #
Use the async method to wrap a Future operation and handle errors and
exceptions that may occur during the operation's execution. You can set
callbacks to handle different types of outcomes, such as onSuccess for
successful operations, onError for unhandled exceptions, onTimeout for
operations that exceed a given timeout, and others.
TryCatch.async<int?>(
future: Future.value(100),
timeout: const Duration(seconds: 10),
onNull: () => print('Null'),
onTimeout: () => print('Timeout'),
onError: (e, s) => print('Error: $e'),
onWaiting: () => print('Awaitng future'),
onEmpty: () => print('Empty Map or List'),
onSuccess: (d) => print('Data: $d'),
);
copied to clipboard
TryCatch.sync() #
Use the sync method to wrap a synchronous operation and handle errors and
exceptions that may occur during its execution. You can set callbacks to
handle different types of outcomes, such as onSuccess for successful
operations, onError for unhandled exceptions, and others.
TryCatch.sync<int?>(
operation: () => someFunction(),
onNull: () => print('Null'),
onError: (e, s) => print('Error: $e'),
onEmpty: () => print('Empty Map or List'),
onSuccess: (d) => print('Data: $d'),
);
copied to clipboard
❤️ Support Flutter Focus #

🚀 Github Sponsors

Need Mobile, Web or Video marketing services? 📱 🌐 📹 #
Flutter Focus offers bespoke services in multimedia storytelling by mixing Mobile, Web and Video.
Find out more.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.