我如何根据类别导航不同的屏幕并 return 返回主屏幕
how could i navigate the different screens based on their categories and return back to home screen
//这是水平列表视图页面,点击类别然后需要转到他们自己的页面。单击一个类别时,它会在登陆主屏幕之前显示所有类别的所有页面。我怎样才能阻止这种情况发生。
import 'package:flutter/material.dart';
class HorizontalList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 100.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
// containers for categories
Category(
image_location: 'lib/images/supreme_airmax_white.jpg',
image_caption: 'shoes',
),
Category(
image_location: 'lib/images/cats/offwhite_belt_blackandyellow_accessories.jpg',
image_caption: 'accessories',
),
],
),
);
}
}
class Category extends StatelessWidget {
final String image_location;
final String image_caption;
Category({this.image_location, this.image_caption});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(2.0),
child: InkWell(
onTap: (){
//pages for categories
Category();Navigator.of(context).pushNamed('/screen5');
Category();Navigator.of(context).pushNamed('/screen6');
},
为了让它工作。该页面必须命名为 image_caption。在定义路由的主文件中。页面名称应声明为“/shoes”:(Context) => ShoesPage(); .在 onTap 方法中 Navigator.of(context).pushNamed("/" + image_caption);然后就可以工作了。
//这是水平列表视图页面,点击类别然后需要转到他们自己的页面。单击一个类别时,它会在登陆主屏幕之前显示所有类别的所有页面。我怎样才能阻止这种情况发生。
import 'package:flutter/material.dart';
class HorizontalList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
height: 100.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
// containers for categories
Category(
image_location: 'lib/images/supreme_airmax_white.jpg',
image_caption: 'shoes',
),
Category(
image_location: 'lib/images/cats/offwhite_belt_blackandyellow_accessories.jpg',
image_caption: 'accessories',
),
],
),
);
}
}
class Category extends StatelessWidget {
final String image_location;
final String image_caption;
Category({this.image_location, this.image_caption});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(2.0),
child: InkWell(
onTap: (){
//pages for categories
Category();Navigator.of(context).pushNamed('/screen5');
Category();Navigator.of(context).pushNamed('/screen6');
},
为了让它工作。该页面必须命名为 image_caption。在定义路由的主文件中。页面名称应声明为“/shoes”:(Context) => ShoesPage(); .在 onTap 方法中 Navigator.of(context).pushNamed("/" + image_caption);然后就可以工作了。