如何解决如何使背景图像定位
当我在下面与您共享的main.dart文件中写入背景图像代码时,我要使用的数据保留在图像下。我怎么解决这个问题?我知道我在错误的位置写了有关Background的部分,但我不知道在哪里写。谢谢您的帮助。
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Weather App',theme: ThemeData(
primarySwatch: Colors.blue,),home: Scaffold(
backgroundColor: Colors.tealAccent,appBar: AppBar(
title: Text('Flutter Weather App'),body: Center(
child: Column(children: <Widget>[
//WEATHER DATA
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),child: weatherData != null
? Weather(weather: weatherData)
: Container(),Padding(
padding: const EdgeInsets.all(8.0),child: isLoading
? CircularProgressIndicator(
strokeWidth: 2.0,valueColor:
new AlwaysStoppedAnimation(Colors.black),)
: IconButton(
icon: new Icon(Icons.refresh),tooltip: 'Refresh',onPressed: () async {
await loadWeather();
},color: Colors.black,],//BACKGROUND IMAGE
Container(
height: 501.7,width: 420.0,decoration: BoxDecoration(
image: DecorationImage(
image: isweatherDataLoaded //this
? HandleError()
: images["clear"],fit: BoxFit.fill,shape: BoxShape.rectangle,//FUTURE FORECAST WEATHER DATA
SafeArea(
child: Padding(
padding: const EdgeInsets.all(8.0),child: Container(
height: 200.0,child: forecastData != null
? ListView.builder(
itemCount: forecastData.list.length,scrollDirection: Axis.horizontal,itemBuilder: (context,index) => WeatherItem(
weather: forecastData.list.elementAt(index)))
: Container(),)
]))),);
}
无论我写什么,它都没有用。我想让你给我看看。如果您愿意,我可以与您分享其余的代码。祝您满意!谢谢。
解决方法
我建议将带有背景图像的容器在层次结构中向上移动,
$default_loc->id
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。