我试图将我的头围绕在Flutter的ui位置.所以我现在有一些看起来像这样的东西

我想添加一点空格黑白搜索Textfield和按钮.这就是我的代码的控制部分.我试图设计我的样式,textFieldSearchBox所以它右边有一点边距,我试图增加Edge插件,但它似乎增加了TextField的大小我不知道为什么?我知道我可以在TextField之后添加一个填充元素,但我想知道我的其他选项是什么.为什么在textFieldSearchBox的装饰中增加EdgeInsets会增加文本框的大小?我理想的情况是在此文本框(LTRB)的所有边界周围添加边距.有什么建议?
TextField textFieldSearchBox = new TextField(
keyboardType: TextInputType.text,
controller: filterController,
autofocus: false,
decoration: new InputDecoration(
contentPadding: new EdgeInsets.fromLTRB(20.0, 10.0, 100.0, 10.0),
border:
new OutlineInputBorder(borderRadius: BorderRadius.only()),
),
);
var optionRow = new Row(
children: <Widget>[
new Expanded(child:textFieldSearchBox),
searchButton,
new IconButton(
icon: new Icon(Icons.filter),
onPressed: (){print("Called....");},
),
],
);
return new Scaffold(
appBar: new AppBar(
title: new Text("Title goes here.."),
backgroundColor: Colors.lightBlueAccent,
),
body: new Container(
child:new Column(
children: <Widget>[
optionRow,
],
),
),
);
Run Code Online (Sandbox Code Playgroud) 我正在使用 TextFormField 来接受密码。我已将后缀图标设置为让 IconButton 子项检测单击事件并切换 TextFormField 的模糊文本属性。iconButton 的回调函数被调用,但 TextFormField 不会被重新绘制。关于如何解决这个问题的任何想法?
static Widget buildTextFormField(String id,
FormFieldValidator<String> validateField,
FormFieldSetter<String> saveField,
InputDecoration decoration,
EdgeInsetsGeometry paddingInfo,
EdgeInsetsGeometry marginInfo,
TextInputType keyboardType,
{bool obscureField:false, double width:328.0,
TextEditingController controller}
){
return Container(
padding: paddingInfo,
margin: marginInfo,
width: width,
child: TextFormField(
key: Key(id),
obscureText: obscureField,
validator: validateField,
onSaved: saveField,
keyboardType: keyboardType,
decoration: decoration,
controller: controller,
),
);
Run Code Online (Sandbox Code Playgroud)
}
InputDecoration passwordDecoration = InputDecoration(
hintText: 'Password',
labelText: 'Enter your password',
suffixIcon:
IconButton(
icon: Icon(
_passwordVisible ? Icons.visibility : Icons.visibility_off,
semanticLabel: …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 SingleChildScrollView 使堆栈布局可滚动,但它不滚动。这里应该使用 SingleChildScrollView 吗?
我想我已经给出了足够的描述,让任何人都能理解我的问题。此处提供更多文本以满足 StackOverflow 提出问题的要求。为此事道歉。
这是示例代码。
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
child: Center(
child: LayoutBuilder(
builder:
(BuildContext context, BoxConstraints viewportConstraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: viewportConstraints.maxHeight,
),
child: IntrinsicHeight(
child: Column(
children: <Widget>[
Container(
// A fixed-height child.
color: Colors.white,
height: 120.0,
),
Expanded(
// A flexible child that will grow to fit the viewport but
// still be at least as big as necessary to fit its …Run Code Online (Sandbox Code Playgroud) 我有一个连续的图像和该图像旁边的文本。我希望该行完全展开,图像作为其大小,然后保持完整区域应由 Container 使用。
这是我的代码片段:
Row(
children: <Widget>[
Container(
margin: EdgeInsets.fromLTRB(10, 50, 10, 8),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Color.fromARGB(100, 0, 0, 0),
blurRadius: 5,
),
],
),
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Column(children: <Widget>[
Image.asset(
'assets/card.png',
height: 62,
width: 62,
fit: BoxFit.cover,
)
]),
Container(
child: Text("Hello world"),
)
],
),
),
],
),
Run Code Online (Sandbox Code Playgroud)
我想要这样: Flutter UI
我有一个凸起按钮列表,我希望所选按钮的背景颜色在其 onPressed() 中更改
我尝试更改 setState 中的颜色,但它没有做任何事情。
这是生成按钮列表的函数
List<Widget> _makeZoneList(List<Zone> zones) {
List<Widget>Buttons = new List();
for (int i = 0; i < zones.length; i++) {
Buttons.add(RaisedButton(
color: zones[i].isSelected ? AppColors.primaryColor : AppColors.white,
onPressed: () {
setState(() {
if (zones[i].isSelected){
zones[i].isSelected = false;
}
else{
zones[i].isSelected = true;
}
print(zones[i].isSelected.toString());
});
},
child: Text(zones.elementAt(i).text)
));
}
return Buttons;
}
Run Code Online (Sandbox Code Playgroud)
这是我调用函数的地方
Widget _zoneBody() {
return Padding(
padding: EdgeInsets.all(32),
child: StreamBuilder<List<Zone>>(
stream: GetterBloc.zonesStream,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return …Run Code Online (Sandbox Code Playgroud) 问题:使用 PageController * 加载网页浏览后无法滚动到 POSITION
像 ViewPager 滚动到 Android 中的特定页面
Widget _buildCarousel(BuildContext context, int selectedIndex) {
PageController controller = PageController(viewportFraction: 1, keepPage: true);
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
// you may want to use an aspect ratio here for tablet support
height: 400.0,
width: 240,
child: PageView.builder(
itemCount: assetImageList.length,
controller: controller,
itemBuilder: (BuildContext context, int itemIndex) {
return _buildCarouselItem(context, selectedIndex, itemIndex);
},
),
)
],
);
}
Run Code Online (Sandbox Code Playgroud) 我想将borderRadius设置为底部导航应用程序栏,如图所示。我试图将底部导航应用栏放到ClipRRect borderRadius和Container装饰中,但没有奏效。那么如何将 topLeft 和 topRight 边框半径应用于底部导航栏。请帮助让我知道我该怎么做?
main.dart
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Food Ordering',
theme: ThemeData(primarySwatch: Colors.blue, primaryColor: Colors.white),
home: MyStatefulWidget(),
routes: <String, WidgetBuilder>{
'/detail-page': (BuildContext context) => MyDetailPage(),
},
);
}
}
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
@override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
int _selectedIndex = 0;
static const …Run Code Online (Sandbox Code Playgroud) 使用以下代码时收到警告,但我的应用程序运行良好:
???????? Exception caught by rendering library ?????????????????????????????????????????????????????
The following assertion was thrown during paint():
A borderRadius can only be given for uniform borders.
'package:flutter/src/painting/box_border.dart':
Failed assertion: line 510 pos 12: 'borderRadius == null'
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
Container(
height: screenSize.height*.13,
width: AppSize.medium,
decoration: BoxDecoration(
color: Colors.red,
border: Border(
right: BorderSide(
width: 1.0,
color: Colors.blue
),
),
borderRadius: BorderRadius.only(
topRight: Radius.circular(AppSize.small),
bottomRight: Radius.circular(AppSize.small),
)
),
)
Run Code Online (Sandbox Code Playgroud) 因此,在我的 flutter 应用程序中,我创建 TextFormField 用作输入,如下所示(并将其返回到脚手架中):
final password = TextFormField(
controller: passController,
autofocus: false,
obscureText: true,
decoration: InputDecoration(hintText: 'Password'),
style: new TextStyle(color: Colors.orange),
);
Run Code Online (Sandbox Code Playgroud)
我想更改stylea 内的属性themeData,但找不到要指定的属性。
我能找到的最接近的一个是textTheme: new TextTheme(body1: new TextStyle(color: Colors.orange)),但是这个对我的 TextFormField 没有任何作用。
如何设置 TextFormField 样式?请帮忙,我对 Dart 和编程都很陌生。我现在 13 岁,没有人能帮我解决这些事情。
PS:如果需要,完整的代码位于 GitHub 上: https: //github.com/Legolaszstudio/novynotifier
我希望在我的 CheckboxListTiles 行周围删除此填充,但没有找到有关如何在不制作我自己的复选框版本的情况下执行此操作的任何信息。
有没有办法(使用CheckboxListTile):