如何将两个不同的对象类型传递到单个页面,以便我可以忽略所需的任何一个:
发件人:
onTap: () {
Navigator.push(
context, PageTransition(
alignment: Alignment.bottomRight,
type: PageTransitionType.fade,
child: CategoryDetail(
topCategories: categories[i])));
}
OR
Navigator.of(context).push(PageTransition(
alignment: Alignment.bottomRight,
type: PageTransitionType.fade,
child: CategoryDetail(category: categories[i])));
收件人:
class CategoryDetail extends StatefulWidget {
CategoryDetail({Key? key, required this.topCategories, required this.category})
: super(key: key);
final Category category;
final TopCategories topCategories;
@override
State<CategoryDetail> createState() => _CategoryDetailState();
}
1条答案
按热度按时间qnakjoqk1#
可以创建一个变量而不定义类型
并在小部件中使用此行检查类别值是否为Category或TopCategories