最佳答案
我可能会使用 BoxDecoration
与 DecorationImage
.您可以使用 alignment
和 fit
属性来确定图像的裁剪方式。您可以使用 AspectRatio
如果您不想在 Container
上硬编码高度,则小部件。
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
home: new MyHomePage(),
));
}
class MyHomePage extends StatelessWidget {
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("Image Crop Example"),
),
body: new Center(
child: new AspectRatio(
aspectRatio: 487 / 451,
child: new Container(
decoration: new BoxDecoration(
image: new DecorationImage(
fit: BoxFit.fitWidth,
alignment: FractionalOffset.topCenter,
image: new NetworkImage('/image/lkd0a.png'),
)
),
),
),
),
);
}
}
关于dart - 如何在 Flutter 中裁剪图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44665720/