gpt4 book ai didi

flutter - 如何放置隐藏参数并发送下一页

转载 作者:行者123 更新时间:2023-12-03 03:24:08 25 4
gpt4 key购买 nike

我正在使用GridView。
当按下这些网格时,我想转到下一页。

我想知道每个网格的参数如何隐藏在网格中,并将这些参数发送给下一页。

如何实现?

GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
mainAxisSpacing: 8.0,
crossAxisSpacing: 8.0,
crossAxisCount: 2,
childAspectRatio: 2,
),
padding: const EdgeInsets.all(8.0),
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (context) => Scoresheet()
));
},
child: Container(
decoration: BoxDecoration(
color: Colors.red,
boxShadow: const [ BoxShadow(blurRadius: 2), ]
),
child: Column(
children: <Widget>[
Text('${snapshot.data[index].game_name}', style: TextStyle(color: Colors.white)),
Text('')//IF IT COULD BE HIDDEN.
],
),
),
);
},
);

最佳答案

如何使用导航器传递数据:

Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailScreen(todo: todos[index]),
),
);

如何在新屏幕上接收数据:
class DetailScreen extends StatelessWidget {
// Declare a field that holds the Todo.
final Todo todo;

// In the constructor, require a Todo.
DetailScreen({Key key, @required this.todo}) : super(key: key);

@override
Widget build(BuildContext context) {
// Use the Todo to create the UI.
return Scaffold(
appBar: AppBar(
title: Text(todo.title),
),
body: Padding(
padding: EdgeInsets.all(16.0),
child: Text(todo.description),
),
);
}
}

有关更多详细信息, Click here

关于flutter - 如何放置隐藏参数并发送下一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59597191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com