当我执行 Get.to (product ()) 时,该消息开始出现,我不明白为什么会这样。 流程是产品主页 -> 产品详细信息 -> 购买历史。 然后,在购买历史记录中,我想使用 Get.to (product ()) 将产品重定向到视图,但在那里我收到了该消息。 我是扑的新手
这是我的代码。 这是 Screen Products 的正文:
class Body extends StatelessWidget {
const Body({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
ProductsController _productsController = Get.put(ProductsController());
return Query(
options: QueryOptions(document: getAllProductsQuery),
builder: (result, {fetchMore, refetch}) {
if (result.isLoading && result.data == null) {
return Center(
child: CircularProgressIndicator(),
);
}
final List<dynamic> listProducts = result.data['productos'];
_productsController.listProducts.value = listProducts;
return Column(
children: [
SearchBox(),
CategoryList(),
SizedBox(height: kDefaultPadding / 2),
Expanded(
child: Stack(
children: [
Container(
margin: EdgeInsets.only(top: 70),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(40),
topRight: Radius.circular(40),
),
),
),
Obx(() => _productsController.listProducts.value.length <= 0
? Container(
child: Center(
child: Text('No found'),
),
)
: RefreshIndicator(
onRefresh: () {
_productsController.itemSelected.value = 0;
return refetch();
},
child: ListView.builder(
itemCount:
_productsController.listProducts.value.length,
itemBuilder: (context, index) => ProductCard(
itemIndex: index,
product:
_productsController.listProducts.value[index],
press: () {
print(_productsController
.listProducts.value[index]['id']);
Get.to(() => DetailsScreen(), arguments: [
_productsController.listProducts.value[index]
['id'],
_productsController.listProducts.value[index]
['price']
]);
},
),
),
))
],
),
)
],
);
},
);
}
}
这是屏幕历史:
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:probardispositivofisico/dashboard/screens/product/components/products_controller.dart';
import 'package:probardispositivofisico/dashboard/screens/product/products_screen.dart';
import 'package:probardispositivofisico/history/body.dart';
class HistoryScreen extends StatelessWidget {
const HistoryScreen({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('History'),
actions: [
IconButton(
icon: Icon(Icons.home),
onPressed: () {
Get.to(() => ProductsScreen());
})
],
),
body: Body());
}
}