首页 文章

如何在flutter中实现自定义对话框?

提问于
浏览
0

我是一个新的人,需要创建一个图库应用程序,它需要一个自定义对话框来显示所选图像,如何实现?

1 回答

  • 0

    一般将军

    showDialog(context: context,builder: (context) => _onTapImage(context)); // Call the Dialog.
    
    _onTapImage(BuildContext context) {
        return Stack(
          alignment: Alignment.center,
          children: <Widget>[
            Image.network('https://via.placeholder.com/150',fit: BoxFit.contain,), // Show your Image
            Align(
              alignment: Alignment.topRight,
              child: RaisedButton.icon(
                  color: Theme.of(context).accentColor,
                  textColor: Colors.white,
                  onPressed: () => Navigator.pop(context),
                  icon: Icon(
                    Icons.close,
                    color: Colors.white,
                  ),
                  label: Text('Close')),
            ),
          ],
        );
      }
    

相关问题