将使用什么功能来最大化 flutter 中的图像?

what functionality will be used to maximize the image in flutter?

我是 Flutter 的新手所以请放轻松我正在练习网格视图我坚持应该使用什么功能将特定图像从网格项目带到新页面所以我写了关于该图像的描述. 这是我的代码,

GridView.count(
          crossAxisCount: 2,
          children: images
              .map((e) => Container(
                    child: Container(
                      margin: EdgeInsets.all(8),
                      decoration: BoxDecoration(
                          color: Colors.grey[200],
                          borderRadius: BorderRadius.circular(10)),
                      child: Container(
                        decoration: BoxDecoration(
                            color: Colors.grey[900],
                            borderRadius: BorderRadius.circular(10)),
                        margin: EdgeInsets.all(8),
                        padding: EdgeInsets.all(8),
                        child: GestureDetector(
                          onTap: () {
                            
                          },
                          child: Image(
                            image: AssetImage(e),
                            fit: BoxFit.fill,
                          ),
                        ),
                      ),
                    ),
                  ))
              .toList(),
          crossAxisSpacing: 8,
          mainAxisSpacing: 8,
          padding: EdgeInsets.all(8),
        ),

从共享的代码片段中,我得知您想在网格视图中单击项目后在新页面上使用该图像。

因此在下一页小部件的构造函数中声明如下内容

//for stateful
class YourWidgetName extends StatefulWidget{
  final String imagePath;
  YourWidgetName({this.imagePath});
  @override
  _YourWidgetName createState() => _YourWidgetName();
}

class _LoginState extends State<Login> {
  @override
  Widget build(BuildContext context) {
  //you can access imagepath as **widget.imagePath** passed
    return Scafold();
  }
}
 

//for stateless
class YourWidgetName extends StatefulWidget{
  final String imagePath;
  YourWidgetName({this.imagePath});
  @override
  Widget build(BuildContext context) {
  //you can access imagepath as **imagePath** passed
    return Scafold();
  }
}

并在 onTap 函数中执行:

onTap: () => 
  Navigator.of(context).push(
    MaterialPageRoute(
      builder: (context) => 
        YourWidgetName(
          imagePath: e)
    )
  )