Flutter 全身图像显示中的问题
下面是我的代码,我已经截图并显示在这里,但图像显示的是侧边界Flutter 全身图像显示中的问题,flutter,Flutter,下面是我的代码,我已经截图并显示在这里,但图像显示的是侧边界 class ResultImage extends StatelessWidget { final Image image; // File file; ResultImage({Key key, this.image}) : super(key: key); @override Widget build(BuildContext context) { // file=File(image);
class ResultImage extends StatelessWidget {
final Image image;
// File file;
ResultImage({Key key, this.image}) : super(key: key);
@override
Widget build(BuildContext context) {
// file=File(image);
return Scaffold(
appBar: AppBar(
title: Text("View Image"),
actions: <Widget>[
IconButton(
icon: Icon(Icons.share),
tooltip: 'Share',
onPressed: () => {},
),
],
),
body: Container(
child: image,
));
}
}
试试这个
class ResultImage extends StatelessWidget {
final Image image;
// File file;
ResultImage({Key key, this.image}) : super(key: key);
@override
Widget build(BuildContext context) {
// file=File(image);
return Scaffold(
appBar: AppBar(
title: Text("View Image"),
actions: <Widget>[
IconButton(
icon: Icon(Icons.share),
tooltip: 'Share',
onPressed: () => {},
),
],
),
body: Expanded(
child: image,
));
),
),
);
}
}
通过应用高度:double.infinity,宽度:double.infinity解决问题以解决问题
class ResultImage extends StatelessWidget {
final Image image;
// File file;
ResultImage({Key key, this.image}) : super(key: key);
@override
Widget build(BuildContext context) {
// file=File(image);
return Scaffold(
appBar: AppBar(
title: Text("View Image"),
actions: <Widget>[
IconButton(
icon: Icon(Icons.share),
tooltip: 'Share',
onPressed: () => {},
),
],
),
body: Container(
height: double.infinity,
width: double.infinity,
child: image,
));
}
}
应将图像适合度设置为“适合度:BoxFit.fill”,例如-
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('Stack'),
),
body:
GestureDetector(
child: Container(
decoration: new BoxDecoration(
image: new DecorationImage(
image: AssetImage('images/splash.png'),
fit: BoxFit.fill),
),
),
onTap: () {},
),
);
}
试试我的新答案