getMethodTypes method Null safety
- String? version
getMethodTypes(version);
Each endpoint (and version) has its own distinct methods that can be invoked. This method returns a List of method information.
Implementation
getMethodTypes(String? version) async {
if (_methods.length > 0) {
if (version != null) {
return _methods.firstWhere((method) => method['version'] == version);
} else {
return _methods;
}
}
var versions = await getVersions();
var index = 0;
// local next function
next(List<dynamic>? results) async {
if (results != null) {
Object record = {"version": versions[index - 1], "methods": results};
_methods.add(record);
}
if (index < versions.length) {
final result = await invoke('getMethodTypes',
version: '1.0', params: versions[index++]);
next(result);
} else if (version != null && _methods.length > 0) {
return _methods.firstWhere((method) => method['version'] == version);
} else {
return _methods;
}
}
next(null);
}