ApplicationModel constructor
ApplicationModel(})
Implementation
ApplicationModel(WidgetModel parent, {String? key, required this.url, this.title, this.icon, this.page, this.order, String? jwt}) : super(parent, myId, scope: Scope(id: myId))
{
// parse to url into its parts
Uri? uri = Uri.tryParse(url);
if (uri == null) return;
// set database key
_dbKey = key ?? url;
// no scheme provided
if (!uri.hasScheme) uri = Uri.tryParse("https://${uri.url}");
if (uri == null) return;
_scheme = uri.scheme;
_host = uri.host;
// set the start page
String? fragment = uri.hasFragment ? uri.fragment : null;
if (fragment != null && fragment.toLowerCase().contains(".xml"))
{
var _uri = Uri.tryParse(fragment);
if (_uri != null)
{
_queryParameters = _uri.hasQuery ? _uri.queryParameters : null;
_startPage = _uri.removeQuery().url;
}
}
else _queryParameters = uri.queryParameters;
// base domain
_domain = uri.removeFragment().removeQuery().replace(userInfo: null).removeEmptySegments().url;
// active user
_user = UserModel(this, jwt: jwt);
// load the config
initialized = initialize();
}