fetch method
Implementation
Future<Template> fetch(
{required String url,
Map<String, String?>? parameters,
required bool refresh}) async {
// template is a form saved in the database?
if (isUUID(url)) return await _fetchFromDatabase(url, parameters);
// template from embedded .js
if (url == 'js2fml' && parameters != null) {
return await _fetchFromHtml(url, parameters);
}
// parse the passed url
var uri = URI.parse(url);
if (uri == null) {
return fetchErrorTemplate(FetchResult(
code: HttpStatus.badRequest,
message: Phrases().missingOrInvalidURL,
detail: url));
}
url = uri.url;
// get template from file
if (uri.scheme == "file") return _fetchFromFile(url, parameters);
// get template from server (default)
return await _fetchFromServer(url, uri, parameters, refresh);
}