diff --git a/lib/widgets/layouts/empty_page.dart b/lib/widgets/layouts/empty_page.dart index fe56dde1..b7265a50 100644 --- a/lib/widgets/layouts/empty_page.dart +++ b/lib/widgets/layouts/empty_page.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'dart:math'; import 'package:flutter/material.dart'; @@ -5,7 +7,7 @@ import 'package:flutter/material.dart'; class EmptyPage extends StatelessWidget { final bool loading; static const double _width = 200; - const EmptyPage({this.loading = false, Key key}) : super(key: key); + const EmptyPage({this.loading = false, Key? key}) : super(key: key); @override Widget build(BuildContext context) { final _width = min(MediaQuery.of(context).size.width, EmptyPage._width); diff --git a/lib/widgets/layouts/loading_view.dart b/lib/widgets/layouts/loading_view.dart index 571b596e..45e55cc5 100644 --- a/lib/widgets/layouts/loading_view.dart +++ b/lib/widgets/layouts/loading_view.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:flutter/material.dart'; import 'package:matrix/matrix.dart'; @@ -7,26 +9,21 @@ import 'package:fluffychat/widgets/layouts/empty_page.dart'; import 'package:fluffychat/widgets/matrix.dart'; class LoadingView extends StatelessWidget { - const LoadingView({Key key}) : super(key: key); + const LoadingView({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - if (Matrix.of(context) - .widget - .clients - .every((client) => client.loginState != null)) { - WidgetsBinding.instance.addPostFrameCallback( - (_) => VRouter.of(context).to( - Matrix.of(context) - .widget - .clients - .any((client) => client.loginState == LoginState.loggedIn) - ? '/rooms' - : '/home', - queryParameters: VRouter.of(context).queryParameters, - ), - ); - } + WidgetsBinding.instance?.addPostFrameCallback( + (_) => VRouter.of(context).to( + Matrix.of(context) + .widget + .clients + .any((client) => client.loginState == LoginState.loggedIn) + ? '/rooms' + : '/home', + queryParameters: VRouter.of(context).queryParameters, + ), + ); return const EmptyPage(loading: true); } } diff --git a/lib/widgets/layouts/max_width_body.dart b/lib/widgets/layouts/max_width_body.dart index b05f5ddc..f6a963e7 100644 --- a/lib/widgets/layouts/max_width_body.dart +++ b/lib/widgets/layouts/max_width_body.dart @@ -1,9 +1,11 @@ +//@dart=2.12 + import 'dart:math'; import 'package:flutter/material.dart'; class MaxWidthBody extends StatelessWidget { - final Widget child; + final Widget? child; final double maxWidth; final bool withScrolling; @@ -11,7 +13,7 @@ class MaxWidthBody extends StatelessWidget { this.child, this.maxWidth = 600, this.withScrolling = false, - Key key, + Key? key, }) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/widgets/layouts/one_page_card.dart b/lib/widgets/layouts/one_page_card.dart index 78ae7104..130c1cb0 100644 --- a/lib/widgets/layouts/one_page_card.dart +++ b/lib/widgets/layouts/one_page_card.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'dart:math'; import 'package:flutter/material.dart'; @@ -8,14 +10,14 @@ import 'package:fluffychat/widgets/matrix.dart'; class OnePageCard extends StatelessWidget { final Widget child; - const OnePageCard({Key key, this.child}) : super(key: key); + const OnePageCard({Key? key, required this.child}) : super(key: key); static const int alpha = 12; static num breakpoint = FluffyThemes.columnWidth * 2; @override Widget build(BuildContext context) { final horizontalPadding = - max((MediaQuery.of(context).size.width - 600) / 2, 24); + max((MediaQuery.of(context).size.width - 600) / 2, 24); return MediaQuery.of(context).size.width <= breakpoint || Matrix.of(context).client.isLogged() ? child diff --git a/lib/widgets/layouts/side_view_layout.dart b/lib/widgets/layouts/side_view_layout.dart index a38ab724..f54db182 100644 --- a/lib/widgets/layouts/side_view_layout.dart +++ b/lib/widgets/layouts/side_view_layout.dart @@ -1,3 +1,5 @@ +//@dart=2.12 + import 'package:flutter/material.dart'; import 'package:vrouter/vrouter.dart'; @@ -6,15 +8,16 @@ import 'package:fluffychat/config/themes.dart'; class SideViewLayout extends StatelessWidget { final Widget mainView; - final Widget sideView; + final Widget? sideView; - const SideViewLayout({Key key, @required this.mainView, this.sideView}) + const SideViewLayout({Key? key, required this.mainView, this.sideView}) : super(key: key); @override Widget build(BuildContext context) { var currentUrl = Uri.decodeFull(VRouter.of(context).url); if (!currentUrl.endsWith('/')) currentUrl += '/'; final hideSideView = currentUrl.split('/').length == 4; + final sideView = this.sideView; return sideView == null ? mainView : MediaQuery.of(context).size.width < FluffyThemes.columnWidth * 3.5 && diff --git a/lib/widgets/layouts/two_column_layout.dart b/lib/widgets/layouts/two_column_layout.dart index 3a25c60d..343399cd 100644 --- a/lib/widgets/layouts/two_column_layout.dart +++ b/lib/widgets/layouts/two_column_layout.dart @@ -1,3 +1,4 @@ +//@dart=2.12 import 'package:flutter/material.dart'; import 'package:fluffychat/config/themes.dart'; @@ -6,9 +7,11 @@ class TwoColumnLayout extends StatelessWidget { final Widget mainView; final Widget sideView; - const TwoColumnLayout( - {Key key, @required this.mainView, @required this.sideView}) - : super(key: key); + const TwoColumnLayout({ + Key? key, + required this.mainView, + required this.sideView, + }) : super(key: key); @override Widget build(BuildContext context) { if (MediaQuery.of(context).size.width <= FluffyThemes.columnWidth * 2) {