Flutter 收音机列表磁贴填充在颤振中不工作
我正在尝试构建一个使用单选按钮的颤振应用程序。但是,收音机列表平铺有很多填充物,它们并没有得到完美的显示 我尝试将每个MainAxisAlignment提供给row小部件,但没有一个有效。我希望他们在一行,而不管屏幕的宽度 这就是它的显示方式: 以下是我的代码:Flutter 收音机列表磁贴填充在颤振中不工作,flutter,dart,Flutter,Dart,我正在尝试构建一个使用单选按钮的颤振应用程序。但是,收音机列表平铺有很多填充物,它们并没有得到完美的显示 我尝试将每个MainAxisAlignment提供给row小部件,但没有一个有效。我希望他们在一行,而不管屏幕的宽度 这就是它的显示方式: 以下是我的代码: import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'LoginValidate.dart'; import '
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'LoginValidate.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:http/http.dart' as http;
class LoginScreen extends StatefulWidget {
@override
_LoginScreenState createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
int _groupValue = 0;
@override
Widget build(BuildContext context) {
SystemChrome.setEnabledSystemUIOverlays([]);
return Scaffold(
body: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Login',
style: TextStyle(
color: Colors.lightBlue[900],
fontFamily: 'OpenSans',
fontSize: 30.0,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 30.0),
buildoptionsforsignin(),
],
),
)
);
}
buildoptionsforsignin() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
flex: 1,
child: RadioListTile(
value: 0,
groupValue: _groupValue,
title: Text("Email"),
onChanged: (newValue) =>
setState(() => _groupValue = newValue),
activeColor: Colors.lightBlue[900],
selected: true,
),
),
Expanded(
flex: 1,
child: RadioListTile(
value: 1,
groupValue: _groupValue,
title: Text("Phone"),
onChanged: (newValue) =>
setState(() => _groupValue = newValue),
activeColor: Colors.lightBlue[900],
selected: false,
),
),
Expanded(
flex: 1,
child: RadioListTile(
value: 2,
groupValue: _groupValue,
title: Text("Username"),
onChanged: (newValue) =>
setState(() => _groupValue = newValue),
activeColor: Colors.lightBlue[900],
selected: false,
),
),
],
);
}
}
导入“包装:颤振/材料.省道”;
导入“包:flifter/services.dart”;
导入“LoginValidate.dart”;
导入“package:url_launcher/url_launcher.dart”;
将“package:http/http.dart”导入为http;
类LoginScreen扩展StatefulWidget{
@凌驾
_LoginsScreenState createState()=>\u LoginsScreenState();
}
类_LoginScreenState扩展状态{
int _groupValue=0;
@凌驾
小部件构建(构建上下文){
SystemChrome.SetEnabledSystemEmioVerlays([]);
返回脚手架(
正文:SingleChildScrollView(
滚动方向:轴垂直,
子:列(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
正文(
“登录”,
样式:TextStyle(
颜色:颜色。浅蓝色[900],
fontFamily:“OpenSans”,
字体大小:30.0,
fontWeight:fontWeight.bold,
),
),
尺寸箱(高度:30.0),
buildoptionsforsignin(),
],
),
)
);
}
buildoptionsforsignin(){
返回行(
mainAxisAlignment:mainAxisAlignment.spaceAround,
儿童:[
扩大(
弹性:1,
孩子:放射科医生(
值:0,
groupValue:_groupValue,
标题:文本(“电子邮件”),
onChanged:(newValue)=>
设置状态(()=>_groupValue=newValue),
activeColor:Colors.lightBlue[900],
选择:正确,
),
),
扩大(
弹性:1,
孩子:放射科医生(
价值:1,
groupValue:_groupValue,
标题:文本(“电话”),
onChanged:(newValue)=>
设置状态(()=>_groupValue=newValue),
activeColor:Colors.lightBlue[900],
选择:false,
),
),
扩大(
弹性:1,
孩子:放射科医生(
价值:2,
groupValue:_groupValue,
标题:文本(“用户名”),
onChanged:(newValue)=>
设置状态(()=>_groupValue=newValue),
activeColor:Colors.lightBlue[900],
选择:false,
),
),
],
);
}
}
有人能帮我吗?问题是
ListTile
和Radio
都是具有内部填充的材质小部件。通过设置contentPadding
和dense
参数,您可以在某种程度上覆盖这一点:
RadioListTile(
contentPadding: EdgeInsets.all(0),
dense: true,
...
),
您还可以通过更改text
Overflow
参数来更改文本换行行为:
RadioListTile(
title: Text(
"Username",
overflow: TextOverflow.ellipsis,
),
),
如果这还不够,您最好使用
InkWell
,行
,…谢谢@casvl.创建自己的ListTile小部件。。inkwell选项对我有效