flutter - 在颤动中使用堆栈时内容重叠
问题描述
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
void main() => runApp(MaterialApp(
home: Home(),
));`class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('GigoClean',
style: TextStyle(
fontFamily: 'Roboto',
),
),
centerTitle: true,
backgroundColor: Colors.cyanAccent[400],
),`body: Center(
child: Stack(
children: <Widget>[
Container(
decoration: new BoxDecoration(
image: new DecorationImage(image: new AssetImage("assets/bg.png"), fit: BoxFit.cover,),
),
),
Container(
padding: EdgeInsets.fromLTRB(0, 90.0, 0, 0),
child: Image.asset('assets/intro.jpg'),
),
Container(
padding: EdgeInsets.fromLTRB(15, 40, 15, 0),
child: Text('Get ready to make your life easy with single click of app, which makes your cleaning easy.' ,
textAlign: TextAlign.center,),
我只想要一个背景图像,这就是我使用堆栈但它也与其他内容重叠的原因。请帮忙!!
解决方案
您应该将其他两个 Container 放在 Column 或 Row 内以避免重叠。举个例子供大家理解:
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('GigoClean',
style: TextStyle(
fontFamily: 'Roboto',
),
),
centerTitle: true,
backgroundColor: Colors.cyanAccent[400],
),`body: Center(
child: Stack(
children: <Widget>[
Container(
decoration: new BoxDecoration(
image: new DecorationImage(image: new AssetImage("assets/bg.png"), fit: BoxFit.cover,),
),
),
Column(
children: [
Container(
padding: EdgeInsets.fromLTRB(0, 90.0, 0, 0),
child: Image.asset('assets/intro.jpg'),
),
Container(
padding: EdgeInsets.fromLTRB(15, 40, 15, 0),
child: Text('Get ready to make your life easy with single click of app, which makes your cleaning easy.' ,
textAlign: TextAlign.center,),
推荐阅读
- javascript - babel-plugin-lodash webpack 配置没有做任何事情
- c++ - 将 char 设置为 '\0' 会泄漏内存吗?
- python - 获取数据框中的每一行,其列值与列表匹配:Pandas
- javascript - chart.js - 以 xaxis 作为日期的水平条形堆积图
- c++ - 如何将二维数组存储在单个数组中并用 C++ 打印它们?
- r - 旋转数据框并粘贴字符
- jquery - 如何从 C# try catch 块触发 Boostrap 警报
- javascript - 按下或按住按钮时,动作只发生一次
- windows-7 - 如何将 vscode 远程容器与 docker 机器(和 docker 工具箱)一起使用?
- entitymanager - Quarkus:具有多个数据源的 EntityManager 注入