Flutter 颤振文本场高度不增加
我正在尝试增加文本字段的高度,但没有增加。我已经尝试使用容器包装并增加容器的高度,但它只是增加了背景高度,而不是文本字段的高度。 此外,maxLines正在工作,但需要增加高度,以便我可以在容器中添加一些阴影Flutter 颤振文本场高度不增加,flutter,Flutter,我正在尝试增加文本字段的高度,但没有增加。我已经尝试使用容器包装并增加容器的高度,但它只是增加了背景高度,而不是文本字段的高度。 此外,maxLines正在工作,但需要增加高度,以便我可以在容器中添加一些阴影 import 'package:flutter/material.dart'; import 'package:curved_navigation_bar/curved_navigation_bar.dart'; import 'package:mytravel/screens/login
import 'package:flutter/material.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:mytravel/screens/loginPage.dart';
import 'package:mytravel/screens/guidePlacePage.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:async';
import 'dart:io';
class addPostPage extends StatefulWidget {
@override
_addPostPageState createState() => _addPostPageState();
}
class _addPostPageState extends State<addPostPage> {
File _image;
Future getImage() async {
var image = await ImagePicker.pickImage(source: ImageSource.gallery);
setState(() {
_image = image;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFFEDF0F6),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 75, right: 10, left: 10),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(25.0),
),
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(vertical: 10.0),
child: Column(
children: <Widget>[
InkWell(
onTap: () {
getImage();
},
child: Container(
margin: EdgeInsets.all(10.0),
width: double.infinity,
height: 400.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.0),
boxShadow: [
BoxShadow(
color: Colors.black45,
offset: Offset(0, 5),
blurRadius: 8.0,
),
],
image: DecorationImage(
image: _image == null
? AssetImage("assets/images/post0.jpg")
: Image.file(_image),
fit: BoxFit.fitWidth,
),
),
),
),
],
),
),
Container(
height: 200, //here you can see try to increase height
padding: EdgeInsets.only(right: 15, left: 15),
child: TextField(
style: TextStyle(
fontSize: 20,
),
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
borderRadius: BorderRadius.all(Radius.circular(20)),
),
fillColor: Colors.white,
filled: true,
border: InputBorder.none,
hintText: 'Your short story of image',
),
),
)
],
),
),
),
],
),
),
);
}
}
导入“包装:颤振/材料.省道”;
导入“包:弧形导航栏/弧形导航栏.省道”;
导入“package:mytravel/screens/loginPage.dart”;
导入“package:mytravel/screens/guidePlacePage.dart”;
导入“包:image_picker/image_picker.dart”;
导入“dart:async”;
导入“dart:io”;
类addPostPage扩展StatefulWidget{
@凌驾
_addPostPageState createState()=>\u addPostPageState();
}
类_addPostPageState扩展状态{
文件图像;
Future getImage()异步{
var image=wait ImagePicker.pickImage(源:ImageSource.gallery);
设置状态(){
_图像=图像;
});
}
@凌驾
小部件构建(构建上下文){
返回脚手架(
背景颜色:颜色(0xFFEDF0F6),
正文:SingleChildScrollView(
子:列(
儿童:[
填充物(
填充:仅限常量边集(顶部:75,右侧:10,左侧:10),
子:容器(
宽度:double.infinity,
装饰:盒子装饰(
颜色:颜色,白色,
边界半径:边界半径。圆形(25.0),
),
子:列(
儿童:[
填充物(
填充:边缘设置。对称(垂直:10.0),
子:列(
儿童:[
墨水池(
onTap:(){
getImage();
},
子:容器(
保证金:所有边缘套(10.0),
宽度:double.infinity,
高度:400.0,
装饰:盒子装饰(
边界半径:边界半径。圆形(25.0),
boxShadow:[
箱形阴影(
颜色:颜色。黑色45,
偏移量:偏移量(0,5),
半径:8.0,
),
],
图像:装饰图像(
图像:_图像==null
?资产评估(“资产/图像/post0.jpg”)
:Image.file(_Image),
适合:BoxFit.fitWidth,
),
),
),
),
],
),
),
容器(
高度:200,//在这里你可以看到尝试增加高度
填充:仅限边设置(右:15,左:15),
孩子:TextField(
样式:TextStyle(
尺寸:20,
),
装饰:输入装饰(
enabledBorder:OutlineInputBorder(
borderSide:borderSide(颜色:Colors.green),
borderRadius:borderRadius.all(半径圆形(20)),
),
fillColor:Colors.white,
是的,
边框:InputBorder.none,
hintText:“你的形象短篇小说”,
),
),
)
],
),
),
),
],
),
),
);
}
}
contentPadding控制文本字段的高度
如果要增加文本的高度,则需要更改文本样式
中的高度
属性
TextField(
style: TextStyle(height: 4 // controls the height on main text
),
controller: _controller,
decoration: InputDecoration(
contentPadding: // Text Field height
EdgeInsets.symmetric(
vertical: 25.0, horizontal: 10.0),
hintStyle: TextStyle(
height: 4, //Controls the height of the hint text
),
errorStyle:
TextStyle(), // Controls style of error message
counterStyle:
TextStyle(), //Controls style of the counter if you have one
helperStyle:
TextStyle(), //Controls style of the helper message
labelStyle:
TextStyle(), //Controls style of the label message
prefixStyle:
TextStyle() //Controls the style of the prefix
),
),
让我知道这是否有效
内容填充控制文本字段的高度
如果您想增加文本的高度,则可以更改文本样式中的高度
属性
TextField(
style: TextStyle(height: 4 // controls the height on main text
),
controller: _controller,
decoration: InputDecoration(
contentPadding: // Text Field height
EdgeInsets.symmetric(
vertical: 25.0, horizontal: 10.0),
hintStyle: TextStyle(
height: 4, //Controls the height of the hint text
),
errorStyle:
TextStyle(), // Controls style of error message
counterStyle:
TextStyle(), //Controls style of the counter if you have one
helperStyle:
TextStyle(), //Controls style of the helper message
labelStyle:
TextStyle(), //Controls style of the label message
prefixStyle:
TextStyle() //Controls the style of the prefix
),
),
让我知道这是否有效请阅读本页:
如上所述,您需要为文本添加一个高度属性
。因此,您需要在字体大小之后添加此行:
height:2.0;
当height为null或省略时,行高将直接由字体的度量值确定,这可能与fontSize不同。当高度为非空时,文本跨度的行高将是fontSize的倍数,并且正好是fontSize*高度逻辑像素高。请阅读本页:
如上所述,您需要为文本添加一个高度属性
。因此,您需要在字体大小之后添加此行:
height:2.0;
当height为null或省略时,行高将直接由字体的度量值确定,这可能与fontSize不同。当高度为非空时,文本范围的行高度将是fontSize的倍数,并且正好是fontSize*高度逻辑像素的高度。第一个选项:(确保与高度匹配)
第二选项:
TextField(
decoration: const InputDecoration(
contentPadding: const EdgeInsets.symmetric(vertical: 40.0),
)
)
PlusWCS424
answer提供了更多选项,甚至包括成功、错误等提示。第一个选项:(确保与高度匹配)
第二选项:
TextField(
decoration: const InputDecoration(
contentPadding: const EdgeInsets.symmetric(vertical: 40.0),
)
)
PlusWCS424
answer提供了更多选项,甚至包括成功、错误等提示。如果我们在文本样式中添加高度,则hin