dynamic_call 1.0.17
dynamic_call: ^1.0.17 copied to clipboard

Dart native js
Flutter web

Dynamic Call framework, including API calls integrations (HTTP, RESTful).

example/example.dart

import 'package:dynamic_call/dynamic_call.dart';

class Sys {
  /// Defines a call with input field `query`, output as `STRING` and allows
  /// retries in case of errors.
  ///
  /// NOTE: the execution of this call can be of any type.
  final DynCall<dynamic, String> callSearch = DynCall<dynamic, String>(
      ['query'], DynCallType.STRING,
      allowRetries: true);

  /// Normal method to do the search. Parameter [query] will be
  /// passed to [callSearch] as input field `query`.
  Future<String> doSearch(String query) {
    return callSearch.call({'query': query});
  }
}

void main() async {
  var sys = Sys();

  var httpClient = HttpClient('https://www.google.com/');

  var executorFactory = DynCallHttpExecutorFactory(httpClient);

  // Defines the executor of `sys.callSearch` as a HTTP request with a validator
  // that check fo `<html` tag at response.
  //
  // GET: https://www.google.com/search?q=$query
  executorFactory.call(sys.callSearch).executor(HttpMethod.GET,
      path: 'search',
      parametersMap: {'query': 'q'},
      outputValidator: (r, p, rp) => r != null && r.contains('<html'));

  var response = await sys.doSearch('dart dynamic_call');

  print(response);
}
2
likes
110
pub points
40%
popularity

Dynamic Call framework, including API calls integrations (HTTP, RESTful).

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

gracilianomp@gmail.com

License

BSD (LICENSE)

Dependencies

json_object_mapper, mercury_client, swiss_knife

More

Packages that depend on dynamic_call