final
This commit is contained in:
@@ -18,8 +18,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||||
import 'MobileBottomNav.dart';
|
||||
|
||||
class MobileOrders extends StatefulWidget {
|
||||
final Key key;
|
||||
const MobileOrders({this.key});
|
||||
const MobileOrders({Key? key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -31,7 +30,7 @@ class MobileOrders extends StatefulWidget {
|
||||
class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderStateMixin {
|
||||
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
List<Order> orders = [];
|
||||
List<Order>? orders = [];
|
||||
|
||||
int _page = 1;
|
||||
int _pageCount = 1;
|
||||
@@ -44,7 +43,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
void _onRefresh() {
|
||||
_page = 1;
|
||||
if (orders != null) {
|
||||
orders.clear();
|
||||
orders?.clear();
|
||||
} else {
|
||||
orders = [];
|
||||
}
|
||||
@@ -79,7 +78,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
enablePullUp: true,
|
||||
header: WaterDropHeader(),
|
||||
footer: CustomFooter(
|
||||
builder: (BuildContext context, LoadStatus mode){
|
||||
builder: (BuildContext context, LoadStatus? mode){
|
||||
Widget footer;
|
||||
if(mode == LoadStatus.idle) {
|
||||
footer = Text(S.of(context).pull_up_to_load_more);
|
||||
@@ -127,11 +126,11 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
Widget _buildBody() {
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: orders != null && orders.length > 0 ? orders.length : 1,
|
||||
itemCount: orders != null && orders!.length > 0 ? orders!.length : 1,
|
||||
itemBuilder: (BuildContext context, int position) {
|
||||
Order order;
|
||||
if (orders != null && orders.length > 0) {
|
||||
order = orders[position];
|
||||
Order? order;
|
||||
if (orders != null && orders!.length > 0) {
|
||||
order = orders![position];
|
||||
}
|
||||
if (order == null) {
|
||||
return Container(
|
||||
@@ -152,7 +151,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
row.children.add(Expanded(
|
||||
child: Container(
|
||||
child: Text(
|
||||
order.cartInfo.productList[0].name,
|
||||
'${order.cartInfo?.productList?[0].name}',
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
),
|
||||
@@ -161,10 +160,10 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
),
|
||||
),
|
||||
));
|
||||
if (order.cartInfo.productList.length > 1) {
|
||||
if (order.cartInfo!.productList!.length > 1) {
|
||||
row.children.add(Container(
|
||||
child: Text(
|
||||
S.of(context).and_more_item_token(Utils.getProductLineInOrder(order.cartInfo)),
|
||||
S.of(context).and_more_item_token(Utils.getProductLineInOrder(order.cartInfo!)),
|
||||
style: TextStyle(
|
||||
fontSize: 12.0,
|
||||
color: Colors.black26,
|
||||
@@ -193,7 +192,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (BuildContext context) => OrderDetail(order.id, fromOrders: true,),
|
||||
builder: (BuildContext context) => OrderDetail(order!.id, fromOrders: true,),
|
||||
));
|
||||
},
|
||||
),
|
||||
@@ -208,7 +207,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
S.of(context).comment,
|
||||
),
|
||||
onPressed: () {
|
||||
Routes.router.navigateTo(context, '/new-comment/${order.id}');
|
||||
Routes.router.navigateTo(context, '/new-comment/${order!.id}');
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -234,10 +233,10 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Colors.redAccent,
|
||||
backgroundColor: Colors.redAccent,
|
||||
),
|
||||
onPressed: () {
|
||||
Routes.router.navigateTo(context, '/paynow/${order.id}');
|
||||
Routes.router.navigateTo(context, '/paynow/${order!.id}');
|
||||
},
|
||||
));
|
||||
} else {
|
||||
@@ -249,10 +248,10 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Theme.of(context).primaryColor,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
Utils.orderAgain(context, order.cartInfo);
|
||||
Utils.orderAgain(context, order!.cartInfo!);
|
||||
},
|
||||
));
|
||||
}
|
||||
@@ -266,10 +265,10 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: Theme.of(context).primaryColor,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
onPressed: () {
|
||||
Utils.orderAgain(context, order.cartInfo);
|
||||
Utils.orderAgain(context, order!.cartInfo!);
|
||||
},
|
||||
));
|
||||
}
|
||||
@@ -291,7 +290,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: Util.showImage('${order.cartInfo.businessInfo.picUrl}',
|
||||
child: Util.showImage('${order.cartInfo!.businessInfo?.picUrl}',
|
||||
width: 32.0,
|
||||
height: 32.0,
|
||||
fit: BoxFit.fill,
|
||||
@@ -307,7 +306,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
children: <Widget>[
|
||||
Container(
|
||||
child: Text(
|
||||
'${order.cartInfo.businessInfo.name}',
|
||||
'${order.cartInfo!.businessInfo?.name}',
|
||||
style: TextStyle(
|
||||
fontSize: 20.0,
|
||||
),
|
||||
@@ -329,7 +328,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (BuildContext context) => OrderDetail(order.id, fromOrders: true,),
|
||||
builder: (BuildContext context) => OrderDetail(order!.id, fromOrders: true,),
|
||||
));
|
||||
},
|
||||
),
|
||||
@@ -375,7 +374,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (BuildContext context) => OrderDetail(order.id, fromOrders: true,),
|
||||
builder: (BuildContext context) => OrderDetail(order!.id, fromOrders: true,),
|
||||
));
|
||||
},
|
||||
),
|
||||
@@ -438,7 +437,7 @@ class MobileOrdersState extends State<MobileOrders> with SingleTickerProviderSta
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
orders.addAll((data['items'] as List).map((e) => Order.fromJson(e)).toList());
|
||||
orders!.addAll((data['items'] as List).map((e) => Order.fromJson(e)).toList());
|
||||
});
|
||||
}
|
||||
}).catchError((error) {
|
||||
|
||||
Reference in New Issue
Block a user