我想为容器设置高度0的动画。我希望孩子们缩小到它的高度,但是显然它会引发溢出像素错误。而且我不知道如何使孩子们没有错误地收缩。
我曾经尝试搜索一些类似于BoxContraints的小部件,以使其忽略溢出或类似的内容,但我什至不知道该怎么做
_topContainerHeight = _queryFieldHasFocus ? 0 : MediaQuery.of(context).size.height / 1.75;
return StreamBuilder<FirebaseUser>(
stream: _authService.userStream,
builder: (context, snapshot) {
ConnectionState state = snapshot.connectionState;
bool loggedIn = _authService.user != null;
return Scaffold(
appBar: appBar,
body: SingleChildScrollView(
physics: ClampingScrollPhysics(),
child: Column(
children: <Widget>[
AnimatedContainer(
duration: Duration(milliseconds: 500),
curve: Curves.bounceInOut,
height: _topContainerHeight,
width: double.infinity,
color: Colors.deepPurple,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
if (state == ConnectionState.waiting) ...[
CircularProgressIndicator()
] else ...[
if (!loggedIn) ...[
Expanded(
child: RawMaterialButton(
onPressed: _authService.googleSignIn,
padding: EdgeInsets.all(50.0),
child: Text(
'Clique aqui para iniciar uma conta e criar excursões',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white, fontSize: 24.0),
),
),
)
] else ...[
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
color: Colors.deepPurple,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Align(
alignment: FractionalOffset.bottomCenter,
child: FlatButton(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => AddTravelPage()));
},
color: Colors.deepPurple.shade400,
highlightColor:
Colors.deepPurple.shade400,
splashColor: Colors.deepPurple,
padding: EdgeInsets.all(20.0),
child: SizedBox(
width: double.infinity,
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: <Widget>[
Text(
'Criar uma excursão',
textAlign: TextAlign.left,
style: TextStyle(
color: Colors.white,
fontSize: 16.0,
fontWeight:
FontWeight.w600),
),
Icon(Icons.add,
color: Colors.white)
],
))),
),
],
),
),
],
),
),
]
],
],
)),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.all(20.0),
child: TextField(
controller: _queryFieldController,
focusNode: _queryFieldFocus,
onTap: _updateQueryFieldFocus,
style: TextStyle(fontSize: 20.0),
decoration: InputDecoration(
hintText: 'Para qual evento deseja ir?'),
textInputAction: TextInputAction.search,
),
),
],
),
],
),
),
);
});
我要缩小
答案 0 :(得分:0)
您可以使用SizedOverflowBox窗口小部件,其效果类似于溢出:隐藏在CSS中。 https://api.flutter.dev/flutter/widgets/SizedOverflowBox/SizedOverflowBox.html
p.s。欢迎来到stackoverflow