fetchErrorTemplate method
Implementation
Future<Template> fetchErrorTemplate(FetchResult result) async {
var color1 = toStr(toColor(System.theme.onBackground));
var color2 = toStr(toColor(System.theme.primary));
String back = '''
<BUTTON onclick="back()" type="outlined" pas="8" color="$color1">
<ICON icon="arrow_back" size="40" color="$color1"/>
</BUTTON>''';
// default error template
String fml = '''
<ERROR ${Template.errorPageAttribute}="true" linkable="true" layout="column" padding="20" center="true">
<BOX center="true" expand="false">
<ICON icon="${result.icon}" size="200" color="$color2" margin="20"/>
<TEXT id="e1" halign="center" size="={SYSTEM.screenwidth} > 700 ? '32' : '24'" bold="true">
<value><![CDATA[${result.message}]]></value>
</TEXT>
<BOX height="20"/>
$back
<BOX height="20"/>
<TEXT id="e2" selectable="true" halign="center" size="={SYSTEM.screenwidth} > 700 ? '24' : '16'" visible="=!noe({e2})">
<value><![CDATA[${result.detail}]]></value>
</TEXT>
</BOX>
</ERROR>''';
// fetch custom error template from the server?
if (!isNullOrEmpty(System.currentApp?.errorPage)) {
fml = await _fetchErrorPageFromServer(result, back) ?? fml;
}
return Template.fromFml(fml: fml);
}