如何在颤振中固定背景图像的大小和位置?


Widget build(BuildContext context){
var height2 = AppBar().preferredSize.height;
return Scaffold(
backgroundColor: Colors.white,
body: Stack(
children: <Widget>[
Image(
image: AssetImage("assets/oral_structure.png"),
fit: BoxFit.fill
),
Padding(
padding: EdgeInsets.only(top:100, left: 100),
child: Container(
height: 60,
width: 60,
child: FlatButton(
child: Text('ㅂ', style: TextStyle(fontSize: 30,fontWeight: FontWeight.bold)),
onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context) => B()),);
},
)
),
),

上面的是我代码的一部分。我正在制作的应用程序是适当的按钮放在背景图像的顶部。然而,如果你做上面的代码,按钮的位置和图像的位置是不同的,这取决于智能手机的屏幕大小。这同样适用于固定高度和宽度。为什么没有办法呢?

@override
Widget build(BuildContext context) {

return Scaffold(
key: v.scaffoldKey,
body: Stack(
children: [
getBackgroundLight(),
],
),
);
} 
Widget getBackgroundLight() {
return Stack(
children: [
Image.asset('assets/background.jpg', width: double.infinity),
Transform.rotate(
angle: -SizeConfig.calculateBlockVertical(180) *
(math.pi / SizeConfig.calculateBlockVertical(180)),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.center,
end: Alignment.bottomCenter,
colors: [
Get.theme.scaffoldBackgroundColor,
Get.theme.scaffoldBackgroundColor.withOpacity(0.5),
],
),
),
),
),
],
);
}

最新更新