Image Local Image Configuration
pubspec.yaml
In the 所有图片资源
added to the configuration file, and distinguish at least 2.0x、3.0x
two kinds of screen resolution material.
- In the project directory
images
, respectively, to create at least 2.0x、3.0x
two file folders.
- All the pictures were placed
images
under the picture layer of directories and 2.0x、3.0x
folders
- Introduced
Image.asset("images/timg.jpg")
after the restart project
Image common attributes
class StudyBodyImage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Container(
child: Image.asset(
"images/timg.jpg",
alignment: Alignment.center,
color: Colors.pink,
colorBlendMode: BlendMode.saturation,
fit: BoxFit.cover,
repeat:ImageRepeat.repeatX,
),
width: 500.0,
height: 800.0,
),
);
}
}
ClipOval cut
class StudyBodyImage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Container(
child: ClipOval(
child: Image.asset(
"images/timg.jpg",
alignment: Alignment.center,
colorBlendMode: BlendMode.saturation,
width: 500,
height: 800,
fit: BoxFit.cover,
),
),
);
}
}