[dart] Upgrade to Dart 2.12 and its null-safety features

This commit is contained in:
2021-03-30 18:54:31 +02:00
parent 0e8e894056
commit 291fc9111b
5 changed files with 39 additions and 42 deletions

View File

@@ -35,7 +35,7 @@ final icons = {
};
// Get the current pages title
String getPageTitle() => querySelector('title').text;
String getPageTitle() => querySelector('title')!.text!;
// Create the home button
Future<Element> makeHome() async {
@@ -45,7 +45,7 @@ Future<Element> makeHome() async {
'afterBegin',
Element.a()
..attributes['href'] = '/'
..append(makeIcon(icons['home'])));
..append(makeIcon(icons['home']!)));
}
// Create a clickable icon
@@ -61,7 +61,7 @@ Future<Element> makePages() async {
..append(Element.a()
..attributes['tabindex'] = '-1'
..attributes['href'] = 'javascript:void(0)'
..append(makeIcon(icons['pages'])))
..append(makeIcon(icons['pages']!)))
..classes.addAll(['nav-item', 'has-dropdown'])
..append(Element.ul()
..attributes['id'] = 'drop-page'
@@ -87,23 +87,23 @@ Future<Element> makeShare() async {
..append(Element.a()
..attributes['href'] = 'javascript:void(0)'
..attributes['tabindex'] = '-1'
..append(makeIcon(icons['share'])))
..append(makeIcon(icons['share']!)))
..append(Element.ul()
..classes.add('dropdown')
..attributes['id'] = 'drop-share'
..append(makeShareLink(
makeIcon(icons['twitter']),
makeIcon(icons['twitter']!),
'https://twitter.com/share?text=${getPageTitle()}'
'&url=${window.location.href}'))
..append(makeShareLink(makeIcon(icons['reddit']),
..append(makeShareLink(makeIcon(icons['reddit']!),
'https://www.reddit.com/submit?title=${getPageTitle()}s&url=${window.location.href}'))
..append(makeShareLink(makeIcon(icons['email']),
'mailto:?subject=${getPageTitle}&body=${window.location.href}'))
..append(makeShareLink(makeIcon(icons['email']!),
'mailto:?subject=$getPageTitle&body=${window.location.href}'))
..append(makeShareLink(
makeIcon(icons['linkedin']),
makeIcon(icons['linkedin']!),
'https://www.linkedin.com/shareArticle?mini=true&url=${window.location.href}'
'&title=${getPageTitle()}'))
..append(makeShareLink(makeIcon(icons['facebook']),
..append(makeShareLink(makeIcon(icons['facebook']!),
'https://www.facebook.com/sharer/sharer.php?u=${window.location.href}')));
}
@@ -125,7 +125,7 @@ Future<Element> makeThemeChanger() async {
..attributes['tabindex'] = '-1'
..append(Element.span()
..style.verticalAlign = 'top'
..append(makeIcon(icons['theme']))))
..append(makeIcon(icons['theme']!))))
..append(Element.ul()
..classes.add('dropdown')
..attributes['id'] = 'theme-dropdown'
@@ -144,7 +144,7 @@ Future<Element> makeToc() async {
..append(Element.a()
..attributes['tabindex'] = '-1'
..attributes['href'] = 'javascript:void(0)'
..append(makeIcon(icons['toc'])));
..append(makeIcon(icons['toc']!)));
}
// Add a navbar atop of the HTML body, containing: