registerHelper method
registers a helper function that can be used in templates. All helpers are available across the all template
Implementation
bool registerHelper(String name, Function(List<dynamic>, Function?) helper) {
if (name.isEmpty) {
throw Exception('Helper\'s name should be provided');
} else {
var regExp = RegExp(
r'^[a-zA-Z_]+\w+$',
caseSensitive: false,
multiLine: false,
);
if (!regExp.hasMatch(name)) {
throw Exception('Wrong helper name specified');
}
}
if (!_helpers.containsKey(name)) {
_helpers[name] = helper;
return true;
}
return false;
}