如何将 GridView 导航到 Flutter 中的另一个页面?

How to navigate GridView into another page in Flutter?

所以,这是我的 GridView 代码。我已经尝试使用 InkWell,但它没有导航到指定的页面。我不知道是什么问题,因为我是编码世界的新手。我也尝试重组代码,但正如我所说的,我是新手,所以代码总是到处出错。我希望我能得到一些帮助来解决这个问题。谢谢大家

class _DashboardState extends State<Dashboard> {
Material myItems(IconData icon, String heading, int color) {
return Material(
  color: Colors.white,
  elevation: 14.0,
  shadowColor: Color(0x802196F3),
  borderRadius: BorderRadius.circular(20.0),
  child: Center(
    child: Padding(
      padding: const EdgeInsets.all(8.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[

              //text
              Center(
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Text(
                    heading,
                    style: TextStyle(
                      color: new Color(color),
                      fontSize: 20.0,
                    ),
                  ),
                ),
              ),

              //icon
              Material(
                color: new Color(color),
                borderRadius: BorderRadius.circular(24.0),
                child: Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: Icon(
                    icon,
                    color: Colors.white,
                    size: 30.0,
                  ),
                ),
              ),
            ],
          )
        ],
      ),
    ),
  ),
);

}

@override
Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
    title: Text(
      'Dashboard',
      style: TextStyle(
        color: Colors.white,
      ),
    ),
  ),
  body: Container(
    padding: EdgeInsets.all(16.0),
    child: StaggeredGridView.count(
    crossAxisCount: 1,
    mainAxisSpacing: 12.0,
    padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
    children: <Widget>[
      myItems(
        Icons.report, 
        "Report", 
        0x802196F3),
      myItems(
        Icons.insert_chart, 
        "Chart", 
        0x802196F3),
      myItems(
        Icons.format_list_numbered, 
        "Ranking", 
        0x802196F3),
    ],
    staggeredTiles: [
      StaggeredTile.extent(1, 130),
      StaggeredTile.extent(1, 130),
      StaggeredTile.extent(1, 130)
     ],
    ),
   ),
  );
 }
}

我尝试将带有简单打印语句的 Inkwell 添加到您的其中一个图块中并且成功了,单击报告会在控制台中打印出 hello。

children: <Widget>[
    InkWell(
      onTap: () {
        print('hello!');
      },
      child: myItems(Icons.report, "Report", 0x802196F3),
    ),
    myItems(Icons.insert_chart, "Chart", 0x802196F3),
    myItems(Icons.format_list_numbered, "Ranking", 0x802196F3),
  ],
),