【发布时间】:2021-12-26 03:10:59
【问题描述】:
这是我遇到问题的 dart 文件:据我所知,白色的额外空间是因为这个。看看最后一段文字。
import 'dart:ffi';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:lint/lint.dart';
import 'package:simple_shadow/simple_shadow.dart';
class WelcomeLettersDart extends StatefulWidget {
@override
_WelcomeLettersDartState createState() => _WelcomeLettersDartState();
}
class _WelcomeLettersDartState extends State<WelcomeLettersDart> {
@override
Widget build(BuildContext context) {
return SizedBox(
width: 340,
child: Center(
child: Stack(
children: [
Center(
child: SimpleShadow(
opacity: 0.7,
color: Colors.amber,
offset: Offset(0.0, 2.0),
sigma: 6.0,
child: Image.asset(
"assets/images/WelcomeLetterD.png",
height: 340,
),
),
),
Center(
child: Positioned(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 32),
child: Text(
"WELCOME",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: Colors.white,
),
textAlign: TextAlign.center,
),
),
),
),
Center(
child: Positioned(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 88,
horizontal: 63,
),
child: Text(
"Greeting from Letters. This is a chat application with an old theme of sending letters.",
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 13,
color: Colors.white,
height: 2.15,
),
),
),
),
),
Center(
child: Positioned(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 200,
horizontal: 63,
),
child: Text(
"Lets look together what we have got :)",
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 13,
color: Colors.white,
height: 2.10,
),
),
),
),
),
看看这里我这里有 280 的垂直填充,我想这会造成所有问题。我还可以使用什么来将文本堆叠在所需位置的图像上?
Positioned(
child: Align(
alignment: Alignment.bottomRight,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 280,
horizontal: 65,
),
child: Text(
"- Nishan",
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 13,
color: Colors.white,
height: 2.15,
),
),
),
),
),
],
),
),
);
}
}
【问题讨论】:
-
格式化您的代码以使其可读,并分享原始图像的外观(以确保它在 png 中没有自己的填充)
-
不要试图通过粘贴代码文本来绕过系统。解释您尝试解决的问题和问题,阅读 Stackoverflow 上的 how-to-ask
-
我做了一些修改以使其可读。
标签: flutter flutter-layout whitespace infinite-scroll flutter-test