phase3(critical-path): home page chain null-safe
home.dart + desktop/mobile navigation, carousels, index content widgets, customers_logo, appbar_menu, navigation_drawer, MobileBottomNav, double_back. Fixes: Key? params, nullable State fields, Scrollbar thumbVisibility, ModalRoute.of()?, badges hide Badge, cartInfos local promotion.
This commit is contained in:
@@ -7,7 +7,7 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dar
|
||||
class DesktopIndexCarousel extends StatefulWidget {
|
||||
final List<Gallery> galleries;
|
||||
|
||||
const DesktopIndexCarousel(this.galleries, {Key key}) : super(key: key);
|
||||
const DesktopIndexCarousel(this.galleries, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -53,8 +53,8 @@ class DesktopIndexCarouselState extends State<DesktopIndexCarousel> {
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
if (i.linkUrl != null && i.linkUrl.isNotEmpty) {
|
||||
Util.openWebUrl(context, i.linkUrl);
|
||||
if (i.linkUrl?.isNotEmpty == true) {
|
||||
Util.openWebUrl(context, i.linkUrl!);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@@ -12,12 +12,12 @@ import '../../widgets/general/navigationbar_logo.dart';
|
||||
import '../../widgets/general/text_link.dart';
|
||||
|
||||
class DesktopAppBarMenu extends StatelessWidget {
|
||||
User _user;
|
||||
User? _user;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_user = store.state.user;
|
||||
String currentRoute = ModalRoute.of(context).settings.name;
|
||||
String currentRoute = ModalRoute.of(context)?.settings.name ?? '';
|
||||
Widget menuBar = Container(
|
||||
height: 56.0,
|
||||
padding: EdgeInsets.only(left: 10.0, right: 10.0, top: 5.0, bottom: 5.0),
|
||||
|
||||
@@ -10,7 +10,7 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dar
|
||||
|
||||
class CustomersLogo extends StatefulWidget {
|
||||
|
||||
const CustomersLogo({Key key}) : super(key: key);
|
||||
const CustomersLogo({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => CustomersLogoState();
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter_wisetronic/generated/l10n.dart';
|
||||
|
||||
class DesktopIndexMainContent1 extends StatefulWidget {
|
||||
final String message;
|
||||
const DesktopIndexMainContent1(this.message, {Key key}) : super(key: key);
|
||||
const DesktopIndexMainContent1(this.message, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
|
||||
@@ -6,7 +6,7 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dar
|
||||
|
||||
class DesktopIndexMainContent2 extends StatefulWidget {
|
||||
final Map<String, dynamic> content;
|
||||
const DesktopIndexMainContent2(this.content, {Key key}) : super(key: key);
|
||||
const DesktopIndexMainContent2(this.content, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
|
||||
@@ -7,7 +7,7 @@ import '../../constants.dart';
|
||||
|
||||
class DesktopIndexMainContent3 extends StatefulWidget {
|
||||
final Map<String, dynamic> content;
|
||||
const DesktopIndexMainContent3(this.content, {Key key}) : super(key: key);
|
||||
const DesktopIndexMainContent3(this.content, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
|
||||
@@ -14,12 +14,12 @@ import '../../widgets/general/breadcrumbs.dart';
|
||||
import '../../widgets/general/navigationbar.dart';
|
||||
|
||||
class DesktopNavigationBar extends StatefulWidget {
|
||||
final bool hasBack;
|
||||
final List<BreadCrumb> breadCrumbs;
|
||||
final Widget shoppingCart;
|
||||
final OnBackPress onBackPress;
|
||||
final bool? hasBack;
|
||||
final List<BreadCrumb>? breadCrumbs;
|
||||
final Widget? shoppingCart;
|
||||
final OnBackPress? onBackPress;
|
||||
|
||||
const DesktopNavigationBar({Key key, this.hasBack, this.breadCrumbs,
|
||||
const DesktopNavigationBar({Key? key, this.hasBack, this.breadCrumbs,
|
||||
this.shoppingCart, this.onBackPress}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -30,16 +30,16 @@ class DesktopNavigationBar extends StatefulWidget {
|
||||
}
|
||||
|
||||
class DesktopNavigationBarState extends State<DesktopNavigationBar> {
|
||||
User _user;
|
||||
User? _user;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget sc = SizedBox.shrink();
|
||||
if (widget.shoppingCart != null) {
|
||||
sc = widget.shoppingCart;
|
||||
sc = widget.shoppingCart!;
|
||||
}
|
||||
Widget breadCrumbBar = SizedBox.shrink();
|
||||
if (widget.breadCrumbs != null && widget.breadCrumbs.length > 0) {
|
||||
if (widget.breadCrumbs != null && widget.breadCrumbs!.length > 0) {
|
||||
breadCrumbBar = Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: Constants.BREADCRUMB_HEIGHT,
|
||||
|
||||
@@ -6,7 +6,7 @@ import '../../utils/double_back_to_close_app.dart';
|
||||
class DoubleBackToCloseAppWrapper extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const DoubleBackToCloseAppWrapper({Key key, this.child}) : super(key: key);
|
||||
const DoubleBackToCloseAppWrapper({Key? key, required this.child}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
import 'package:badges/badges.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/material.dart' hide Badge;
|
||||
import '../../constants.dart';
|
||||
import '../../generated/l10n.dart';
|
||||
import '../../routes.dart';
|
||||
@@ -15,10 +15,11 @@ class MobileBottomNav extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (store.state.cartInfos != null && store.state.cartInfos.length > 0) {
|
||||
final cartInfos = store.state.cartInfos;
|
||||
if (cartInfos != null && cartInfos.length > 0) {
|
||||
count = 0;
|
||||
for (var i = 0; i < store.state.cartInfos.length; i++) {
|
||||
if (store.state.cartInfos[i].productList != null && store.state.cartInfos[i].productList.length > 0) {
|
||||
for (var i = 0; i < cartInfos.length; i++) {
|
||||
if (cartInfos[i].productList != null && cartInfos[i].productList!.length > 0) {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dar
|
||||
class MobileIndexCarousel extends StatefulWidget {
|
||||
final List<Gallery> galleries;
|
||||
|
||||
const MobileIndexCarousel(this.galleries, {Key key}) : super(key: key);
|
||||
const MobileIndexCarousel(this.galleries, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -39,8 +39,8 @@ class MobileIndexCarouselState extends State<MobileIndexCarousel> {
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
if (i.linkUrl != null && i.linkUrl.isNotEmpty) {
|
||||
Util.openWebUrl(context, i.linkUrl);
|
||||
if (i.linkUrl?.isNotEmpty == true) {
|
||||
Util.openWebUrl(context, i.linkUrl!);
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:flutter_wisetronic/generated/l10n.dart';
|
||||
class MobileIndexMainContent1 extends StatefulWidget {
|
||||
final String message;
|
||||
|
||||
const MobileIndexMainContent1(this.message, {Key key}) : super(key: key);
|
||||
const MobileIndexMainContent1(this.message, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
|
||||
@@ -7,7 +7,7 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dar
|
||||
class MobileIndexMainContent2 extends StatefulWidget {
|
||||
final Map<String, dynamic> content;
|
||||
|
||||
const MobileIndexMainContent2(this.content, {Key key}) : super(key: key);
|
||||
const MobileIndexMainContent2(this.content, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
|
||||
@@ -7,7 +7,7 @@ import '../../utils/util_web.dart' if (dart.library.io) '../../utils/util_io.dar
|
||||
class MobileIndexMainContent3 extends StatefulWidget {
|
||||
final Map<String, dynamic> content;
|
||||
|
||||
const MobileIndexMainContent3(this.content, {Key key}) : super(key: key);
|
||||
const MobileIndexMainContent3(this.content, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
|
||||
@@ -13,7 +13,7 @@ import '../../widgets/mobile/mobile_navigation_drawer_header.dart';
|
||||
import '../../constants.dart';
|
||||
|
||||
class MobileNavigationDrawer extends StatefulWidget {
|
||||
const MobileNavigationDrawer({Key key}) : super(key: key);
|
||||
const MobileNavigationDrawer({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -23,11 +23,11 @@ class MobileNavigationDrawer extends StatefulWidget {
|
||||
}
|
||||
|
||||
class MobileNavigationDrawerState extends State<MobileNavigationDrawer> {
|
||||
User _user;
|
||||
User? _user;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String currentRoute = ModalRoute.of(context).settings.name;
|
||||
String currentRoute = ModalRoute.of(context)?.settings.name ?? '';
|
||||
|
||||
return Container(
|
||||
width: 200.0,
|
||||
|
||||
@@ -10,11 +10,12 @@ import '../../widgets/general/navigationbar_logo.dart';
|
||||
import '../../routes.dart';
|
||||
|
||||
class MobileNavigationBar extends StatefulWidget {
|
||||
final String title;
|
||||
final bool back;
|
||||
final bool toHome;
|
||||
final bool showMe;
|
||||
const MobileNavigationBar({Key key, this.title, this.back, this.toHome, this.showMe}) : super(key: key);
|
||||
final String? title;
|
||||
final bool? back;
|
||||
final bool? toHome;
|
||||
final bool? showMe;
|
||||
|
||||
const MobileNavigationBar({Key? key, this.title, this.back, this.toHome, this.showMe}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -24,19 +25,19 @@ class MobileNavigationBar extends StatefulWidget {
|
||||
}
|
||||
|
||||
class MobileNavigationBarState extends State<MobileNavigationBar> {
|
||||
User _user;
|
||||
User? _user;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
leading: widget.back ?
|
||||
leading: widget.back == true ?
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
Icons.arrow_back_ios,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () {
|
||||
if (widget.toHome) {
|
||||
if (widget.toHome == true) {
|
||||
Routes.router.navigateTo(context, '/', clearStack: true);
|
||||
} else {
|
||||
Routes.router.pop(context);
|
||||
@@ -53,7 +54,7 @@ class MobileNavigationBarState extends State<MobileNavigationBar> {
|
||||
},
|
||||
),
|
||||
title: Container(
|
||||
child: widget.title.isNotEmpty ?
|
||||
child: widget.title?.isNotEmpty == true ?
|
||||
Container(
|
||||
child: Text(
|
||||
'${widget.title}',
|
||||
|
||||
Reference in New Issue
Block a user