gpt4 book ai didi

flutter - 在 flutter 中添加背景图像

转载 作者:IT王子 更新时间:2023-10-29 06:57:23 26 4
gpt4 key购买 nike

我正在尝试在 Flutter 中创建附加屏幕。如何添加背景图片和在特定位置添加文本(忽略白色文本框)。

谢谢你的帮助

enter image description here

最佳答案

要添加背景图片,您必须使用 DecorationImage 类和 BoxDecoration.

 class Home extends StatelessWidget{
@override
Widget build(BuildContext context){
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(image: AssetImage("assets/image1.jpg"), fit: BoxFit.cover),
),
child: Center(child: Text('Welcome To',style: TextStyle(
color: Colors.white,
fontSize: 40.0
),)),
)
);
}
}

enter image description here

关于flutter - 在 flutter 中添加背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55727160/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com