嗨,Flutter 社区:)
开发 flutter 应用程序并寻求 UI 小部件的帮助。
我不知道如何根据父母的身高设置孩子的身高。
需要创建一个垂直分隔线(或具有自定义高度的容器)并将其高度设置为其父级的最大值,因为父级高度(在我的例子中是一列)将根据内部小部件而变化。
我找到了创建垂直分隔线但高度固定的方法。尝试使用 BoxFit、BoxConstraints、FittedBox 和其他几种方法,但未能设置父级的高度。
分隔线放置在容器>行>列->容器内,分隔线的高度应该是列的高度。
如下图所示:
https://i.stack.imgur.com/uUWjF.png
ps 所有小部件都放置在 ListView 内
Column(
children: <Widget>[
Container(
color: Colors.blue,
width: 5.0,
//height: -> setting to maximum of its parent
),
],
),
Run Code Online (Sandbox Code Playgroud) 这是我的复选框的代码:
Checkbox(
value: _isChecked,
onChanged: (bool value) {
setState(() {
_isChecked = value;
});
},
checkColor: Colors.pinkAccent,
activeColor: Colors.transparent,
),
Text("Remember me")
Run Code Online (Sandbox Code Playgroud) 边框半径不适用于子级内部Container。尝试了SizedBox&Stack小部件。我需要容器内的边框视图。
Scaffold(
appBar: AppBar(
title: new Text("ListView"),
),
body: Center(
child: Padding(
padding: EdgeInsets.all(15.0),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0),
border: Border.all(
color: Colors.green,
width: 2.0
)
),
child: Container(
color: Colors.red,
)
),
)
)
)
Run Code Online (Sandbox Code Playgroud)
在SF 中的此链接中,@ martinseal1987向我们展示了如何使用带有Android片段的分离的小部件链接。
我在项目上实现了此解决方案,并且在运行项目后,我没有任何问题可以将第一个小部件显示为Fragment,但是当我按下“后退”按钮时,我的屏幕变为黑色,并且无法返回到以前的小部件
我认为应该是这样的:
navigateBack,customPop方法可以按下按钮来附加片段import 'package:flutter/material.dart';
void main()
{
runApp(MaterialApp(
title: 'AndroidMonks',
home: Scaffold(
appBar: AppBar(
title: Text('Androidmonks'),
backgroundColor: Colors.orangeAccent,
),
body: Home(),
),
));
}
class Home extends StatefulWidget {
Home({
Key key,
}) : super(key: key);
@override
State<Home> createState()=>_Home();
}
class _Home extends State<Home> {
String title = "Title";
int _currentIndex = 0;
final List<int> _backstack = [0];
@override
Widget build(BuildContext context) {
navigateTo(_currentIndex);
//each …Run Code Online (Sandbox Code Playgroud) 我正在尝试将圆角边框设置为我的圆角边框MaterialButton,要设置RoundedRectangleBorder形状属性的MaterialButton,问题是它没有效果。
码:
Widget _showNeedHelpButton() {
return new Padding(
padding: EdgeInsets.fromLTRB(0.0, 5.0, 0.0, 0.0),
child: new MaterialButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20.0))),
elevation: 5.0,
minWidth: 200.0,
height: 35,
color: Color(0xFF801E48),
child: new Text('Preciso de ajuda',
style: new TextStyle(fontSize: 16.0, color: Colors.white)),
onPressed: () {
setState(() {
_isNeedHelp = true;
});
},
),
);
}
Run Code Online (Sandbox Code Playgroud)
结果: