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:
2026-07-24 13:42:03 +08:00
parent ae4c4046c3
commit 88dd90ed7c
16 changed files with 60 additions and 58 deletions

View File

@@ -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;
}
}

View File

@@ -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!);
}
},
),

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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,

View File

@@ -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}',