diff --git a/lib/appIntroPage.dart b/lib/appIntroPage.dart index 70f6b35..90ba41d 100644 --- a/lib/appIntroPage.dart +++ b/lib/appIntroPage.dart @@ -11,7 +11,7 @@ class AppIntroItem { final String title; final String subTitle; - AppIntroItem({this.icon, this.title, this.subTitle = ''}); + AppIntroItem({required this.icon, required this.title, this.subTitle = ''}); // 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec vitae eros. Nunc sit amet neque. Ut id dui. Integer viverra feugiat sem. Morbi aliquam turpis rhoncus sapien volutpat condimentum.'}); } @@ -23,83 +23,86 @@ abstract class AppIntroPage extends StatelessWidget { final ListItems items; final OnIntroFinish onIntroFinish; - const AppIntroPage({Key key, this.items, this.onIntroFinish}) + const AppIntroPage( + {Key? key, required this.items, required this.onIntroFinish}) : super(key: key); @override Widget build(BuildContext context) { - return new Scaffold( - // appBar: new AppBar(), - body: new DefaultTabController( + return Scaffold( + // appBar: AppBar(), + body: DefaultTabController( length: items(context).length, - child: new _AppIntroPageSelector(items: items, onFinish: onIntroFinish), + child: _AppIntroPageSelector(items: items, onFinish: onIntroFinish), ), ); } } class _AppIntroPageSelector extends StatelessWidget { - const _AppIntroPageSelector({this.items, this.onFinish}); + const _AppIntroPageSelector({required this.items, required this.onFinish}); final ListItems items; final OnIntroFinish onFinish; void _handleArrowButtonPress(BuildContext context, int delta) { - final TabController controller = DefaultTabController.of(context); + final TabController controller = DefaultTabController.of(context)!; if (!controller.indexIsChanging) - controller - .animateTo((controller.index + delta).clamp(0, items(context).length - 1)); + controller.animateTo( + (controller.index + delta).clamp(0, items(context).length - 1)); } @override Widget build(BuildContext context) { - final TabController controller = DefaultTabController.of(context); + final TabController controller = DefaultTabController.of(context)!; final ThemeData theme = Theme.of(context); - final Color color = theme.accentColor; + final Color color = theme.colorScheme.secondary; final TextStyle titleStyle = - theme.textTheme.headline.copyWith(color: color); + (theme.textTheme.headlineSmall ?? const TextStyle()) + .copyWith(color: color); final TextStyle subTitleStyle = - theme.textTheme.subhead; //.copyWith(color: color); + theme.textTheme.titleMedium ?? const TextStyle(); // final TextStyle descriptionStyle = theme.textTheme.subhead; - return new SafeArea( + return SafeArea( top: true, bottom: false, - child: new Column( + child: Column( children: [ - new Row(mainAxisAlignment: MainAxisAlignment.end, children: [ - new IconButton( + Row(mainAxisAlignment: MainAxisAlignment.end, children: [ + IconButton( onPressed: () { onFinish(context); }, - icon: new Icon(Icons.close, size: 30.0, color: Colors.black38)), + icon: + const Icon(Icons.close, size: 30.0, color: Colors.black38)), ]), - new Expanded( - child: new OrientationBuilder(builder: (context, orientation) { - return new IconTheme( - data: new IconThemeData( + Expanded(child: OrientationBuilder(builder: (context, orientation) { + return IconTheme( + data: IconThemeData( size: orientation == Orientation.portrait ? 200.0 : 100.0, color: color, ), - child: new TabBarView( + child: TabBarView( children: items(context).map((AppIntroItem item) { - return new Container( + return Container( padding: const EdgeInsets.all(12.0), - child: new Center( - child: new CenteredSpaceEvenlyColumn(children: [ + child: Center( + child: CenteredSpaceEvenlyColumn(children: [ Icon( item.icon, semanticLabel: item.title, ), - new Padding( - padding: new EdgeInsets.only(left: 16.0, right: 16.0), - child: new CenteredColumn(children: [ - new Text( + Padding( + padding: + const EdgeInsets.only(left: 16.0, right: 16.0), + child: CenteredColumn(children: [ + Text( item.title, style: titleStyle, textAlign: TextAlign.center, ), - new SizedBox(height: 20.0), - new Text( + const SizedBox(height: 20.0), + Text( item.subTitle, style: subTitleStyle, textAlign: TextAlign.center, @@ -111,19 +114,19 @@ class _AppIntroPageSelector extends StatelessWidget { }).toList()), ); })), - new Container( + Container( margin: const EdgeInsets.only(top: 16.0), - child: new Row( + child: Row( children: listWithoutNulls([ - new IconButton( + IconButton( icon: const Icon(Icons.chevron_left), color: color, onPressed: () { _handleArrowButtonPress(context, -1); }, tooltip: 'Page back'), - new TabPageSelector(controller: controller), - new IconButton( + TabPageSelector(controller: controller), + IconButton( icon: const Icon(Icons.chevron_right), color: color, onPressed: () { diff --git a/lib/layout/abstractCenteredColumn.dart b/lib/layout/abstractCenteredColumn.dart index 3dddb9b..4a3c55d 100644 --- a/lib/layout/abstractCenteredColumn.dart +++ b/lib/layout/abstractCenteredColumn.dart @@ -2,15 +2,15 @@ import 'package:flutter/material.dart'; abstract class AbstractCenteredColumn extends Column { AbstractCenteredColumn({ - Key key, - MainAxisAlignment mainAxisAlignment, - TextDirection textDirection, - TextBaseline textBaseline, - List children: const [], + Key? key, + MainAxisAlignment? mainAxisAlignment, + TextDirection? textDirection, + TextBaseline? textBaseline, + List children = const [], }) : super( children: children, key: key, - mainAxisAlignment: mainAxisAlignment, + mainAxisAlignment: mainAxisAlignment ?? MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, textDirection: textDirection, diff --git a/lib/layout/abstractCenteredRow.dart b/lib/layout/abstractCenteredRow.dart index 96f6aec..858c62a 100644 --- a/lib/layout/abstractCenteredRow.dart +++ b/lib/layout/abstractCenteredRow.dart @@ -2,15 +2,15 @@ import 'package:flutter/material.dart'; abstract class AbstractCenteredRow extends Row { AbstractCenteredRow({ - Key key, - TextDirection textDirection, - TextBaseline textBaseline, + Key? key, + TextDirection? textDirection, + TextBaseline? textBaseline, mainAxisAlignment, - List children: const [], + List children = const [], }) : super( children: children, key: key, - mainAxisAlignment: mainAxisAlignment, + mainAxisAlignment: mainAxisAlignment ?? MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, textDirection: textDirection, diff --git a/lib/layout/centeredColumn.dart b/lib/layout/centeredColumn.dart index 7f2e3c2..44fa5f2 100644 --- a/lib/layout/centeredColumn.dart +++ b/lib/layout/centeredColumn.dart @@ -3,10 +3,10 @@ import 'abstractCenteredColumn.dart'; class CenteredColumn extends AbstractCenteredColumn { CenteredColumn({ - Key key, - TextDirection textDirection, - TextBaseline textBaseline, - List children: const [], + Key? key, + TextDirection? textDirection, + TextBaseline? textBaseline, + List children = const [], }) : super( children: children, key: key, diff --git a/lib/layout/centeredMaxWidget.dart b/lib/layout/centeredMaxWidget.dart index 70e42e8..b1bc68b 100644 --- a/lib/layout/centeredMaxWidget.dart +++ b/lib/layout/centeredMaxWidget.dart @@ -4,10 +4,10 @@ import 'centeredRow.dart'; class CenteredMaxWidget extends CenteredColumn { CenteredMaxWidget({ - Key key, - TextDirection textDirection, - TextBaseline textBaseline, - List children: const [], + Key? key, + TextDirection? textDirection, + TextBaseline? textBaseline, + List children = const [], }) : super( children: [new CenteredRow(children: children)], key: key, diff --git a/lib/layout/centeredRow.dart b/lib/layout/centeredRow.dart index 8b5242b..41cbfb0 100644 --- a/lib/layout/centeredRow.dart +++ b/lib/layout/centeredRow.dart @@ -3,10 +3,10 @@ import 'abstractCenteredRow.dart'; class CenteredRow extends AbstractCenteredRow { CenteredRow({ - Key key, - TextDirection textDirection, - TextBaseline textBaseline, - List children: const [], + Key? key, + TextDirection? textDirection, + TextBaseline? textBaseline, + List children = const [], }) : super( children: children, key: key, diff --git a/lib/layout/centeredSpaceAroundColumn.dart b/lib/layout/centeredSpaceAroundColumn.dart index 704cfeb..038d12c 100644 --- a/lib/layout/centeredSpaceAroundColumn.dart +++ b/lib/layout/centeredSpaceAroundColumn.dart @@ -3,10 +3,10 @@ import 'abstractCenteredColumn.dart'; class CenteredSpaceAroundColumn extends AbstractCenteredColumn { CenteredSpaceAroundColumn({ - Key key, - TextDirection textDirection, - TextBaseline textBaseline, - List children: const [], + Key? key, + TextDirection? textDirection, + TextBaseline? textBaseline, + List children = const [], }) : super( children: children, key: key, diff --git a/lib/layout/centeredSpaceAroundRow.dart b/lib/layout/centeredSpaceAroundRow.dart index dadd9e0..8ec2e88 100644 --- a/lib/layout/centeredSpaceAroundRow.dart +++ b/lib/layout/centeredSpaceAroundRow.dart @@ -3,10 +3,10 @@ import 'abstractCenteredRow.dart'; class CenteredSpacedAroundRow extends AbstractCenteredRow { CenteredSpacedAroundRow({ - Key key, - TextDirection textDirection, - TextBaseline textBaseline, - List children: const [], + Key? key, + TextDirection? textDirection, + TextBaseline? textBaseline, + List children = const [], }) : super( children: children, key: key, diff --git a/lib/layout/centeredSpaceBetweenColumn.dart b/lib/layout/centeredSpaceBetweenColumn.dart index dac8062..5c11347 100644 --- a/lib/layout/centeredSpaceBetweenColumn.dart +++ b/lib/layout/centeredSpaceBetweenColumn.dart @@ -3,10 +3,10 @@ import 'abstractCenteredColumn.dart'; class CenteredSpaceBetweenColumn extends AbstractCenteredColumn { CenteredSpaceBetweenColumn({ - Key key, - TextDirection textDirection, - TextBaseline textBaseline, - List children: const [], + Key? key, + TextDirection? textDirection, + TextBaseline? textBaseline, + List children = const [], }) : super( children: children, key: key, diff --git a/lib/layout/centeredSpaceBetweenRow.dart b/lib/layout/centeredSpaceBetweenRow.dart index a6a26d3..cbd7a9d 100644 --- a/lib/layout/centeredSpaceBetweenRow.dart +++ b/lib/layout/centeredSpaceBetweenRow.dart @@ -3,10 +3,10 @@ import 'abstractCenteredRow.dart'; class CenteredSpacedBetweenRow extends AbstractCenteredRow { CenteredSpacedBetweenRow({ - Key key, - TextDirection textDirection, - TextBaseline textBaseline, - List children: const [], + Key? key, + TextDirection? textDirection, + TextBaseline? textBaseline, + List children = const [], }) : super( children: children, key: key, diff --git a/lib/layout/centeredSpaceEvenlyColumn.dart b/lib/layout/centeredSpaceEvenlyColumn.dart index acac79f..5f9bad1 100644 --- a/lib/layout/centeredSpaceEvenlyColumn.dart +++ b/lib/layout/centeredSpaceEvenlyColumn.dart @@ -3,10 +3,10 @@ import 'abstractCenteredColumn.dart'; class CenteredSpaceEvenlyColumn extends AbstractCenteredColumn { CenteredSpaceEvenlyColumn({ - Key key, - TextDirection textDirection, - TextBaseline textBaseline, - List children: const [], + Key? key, + TextDirection? textDirection, + TextBaseline? textBaseline, + List children = const [], }) : super( children: children, key: key, diff --git a/lib/layout/centeredSpaceEvenlyRow.dart b/lib/layout/centeredSpaceEvenlyRow.dart index d505fec..45ea330 100644 --- a/lib/layout/centeredSpaceEvenlyRow.dart +++ b/lib/layout/centeredSpaceEvenlyRow.dart @@ -3,10 +3,10 @@ import 'abstractCenteredRow.dart'; class CenteredSpacedEvenlyRow extends AbstractCenteredRow { CenteredSpacedEvenlyRow({ - Key key, - TextDirection textDirection, - TextBaseline textBaseline, - List children: const [], + Key? key, + TextDirection? textDirection, + TextBaseline? textBaseline, + List children = const [], }) : super( children: children, key: key, diff --git a/lib/utils/secretLoader.dart b/lib/utils/secretLoader.dart index 4270707..e640656 100644 --- a/lib/utils/secretLoader.dart +++ b/lib/utils/secretLoader.dart @@ -5,13 +5,13 @@ import 'package:flutter/services.dart' show rootBundle; class SecretLoader { final String secretPath; - SecretLoader({this.secretPath}); + SecretLoader({required this.secretPath}); Future> load() { rootBundle.loadString(secretPath, cache: false); - return rootBundle.loadStructuredData>(this.secretPath, + return rootBundle.loadStructuredData>(secretPath, (jsonStr) async { return json.decode(jsonStr); }); } -} \ No newline at end of file +} diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 08277ba..180e5eb 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -8,4 +8,4 @@ bool notNull(Object o) => o != null; List listWithoutNulls(List children) => children.where(notNull).toList(); -ellipse(String s,[ int end = 4]) => s != null ? s.substring(0, end) + '...' : null; +ellipse(String s,[ int end = 4]) => s.substring(0, end) + '...'; diff --git a/lib/widgets/roundedButton.dart b/lib/widgets/roundedButton.dart index aa75a4e..d3d31bf 100644 --- a/lib/widgets/roundedButton.dart +++ b/lib/widgets/roundedButton.dart @@ -1,56 +1,68 @@ import 'package:flutter/material.dart'; class RoundedBtn extends StatelessWidget { - final btnRadius = new Radius.circular(90.0); + static const btnRadius = Radius.circular(90.0); final IconData icon; final String text; final Color backColor; final Color fontColor; final TextStyle textStyle; - VoidCallback onPressed; + final VoidCallback onPressed; - RoundedBtn( - {@required this.icon, - @required this.text, - @required this.onPressed, - @required this.backColor, - this.textStyle = const TextStyle(fontSize: 20.0, color: Colors.white), - this.fontColor = Colors.white}); + const RoundedBtn({ + required this.icon, + required this.text, + required this.onPressed, + required this.backColor, + this.textStyle = const TextStyle(fontSize: 20.0, color: Colors.white), + this.fontColor = Colors.white, + }); - RoundedBtn.nav( - {@required this.icon, - @required this.text, - @required BuildContext context, - @required route, - @required this.backColor, - this.textStyle = const TextStyle(fontSize: 20.0, color: Colors.white), - this.fontColor = Colors.white}) { - this.onPressed = () { - Navigator.pushNamed(context, route); - }; + factory RoundedBtn.nav({ + required IconData icon, + required String text, + required BuildContext context, + required String route, + required Color backColor, + TextStyle textStyle = const TextStyle(fontSize: 20.0, color: Colors.white), + Color fontColor = Colors.white, + }) { + return RoundedBtn( + icon: icon, + text: text, + onPressed: () { + Navigator.pushNamed(context, route); + }, + backColor: backColor, + textStyle: textStyle, + fontColor: fontColor, + ); } @override Widget build(BuildContext context) { - return new SizedBox( - child: new RaisedButton( - elevation: 1.0, - color: backColor, - child: new Padding( - padding: const EdgeInsets.all(10.0), - child: new Row( - mainAxisSize: MainAxisSize.min, - children: [ - new Icon(icon, size: 32.0, color: fontColor), - new SizedBox(width: 10.0), - new Text(text, style: textStyle), - ], - ), + return SizedBox( + child: ElevatedButton( + onPressed: onPressed, + style: ElevatedButton.styleFrom( + backgroundColor: backColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(btnRadius), ), - onPressed: onPressed, - shape: new RoundedRectangleBorder( - borderRadius: BorderRadius.all(btnRadius))), + ), + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(icon, size: 32.0, color: fontColor), + const SizedBox(width: 10.0), + Text(text, style: textStyle), + ], + ), + ), + ), ); } }