execute method

  1. @override
Future<String> execute(
  1. NetworkConnectivityArgs args
)
override

Executes the tool with the given arguments.

Returns the result as a string. Implementations should handle validation of args and throw exceptions for invalid inputs.

args should be of type T, which represents the structured arguments for this tool.

Implementation

@override
Future<String> execute(NetworkConnectivityArgs args) async {
  try {
    final connectivityResults = await Connectivity().checkConnectivity();
    final hasInternet = !connectivityResults.contains(
      ConnectivityResult.none,
    );
    return 'Connectivity status: $connectivityResults. Internet available: $hasInternet';
  } catch (e) {
    return 'Error checking connectivity: $e';
  }
}