我在扑朔迷离中制作了一个应用程序。屏幕上有SliverAppBar,LiatView和FloatingActionButton。在下方有FloatingActionButton SliverAppBar。滚动ListView之后,SliverAppBar卷曲并且FloatingActionButton消失,但是向上滚动时应该会出现。 我该怎么办?
我的代码:
class AccountScreen extends StatefulWidget {
@override
AccountScreenState createState() => AccountScreenState();
}
class AccountScreenState extends State<AccountScreen> {
double appBarHeight = 190.0;
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Scaffold(
resizeToAvoidBottomPadding: false,
backgroundColor: Color(0xff424242),
body: DefaultTabController(
length: 2,
child: NestedScrollView(
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
backgroundColor: Colors.grey[900].withOpacity(0.89),
expandedHeight: 200.0,
floating: false,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text("Batmen",
style: TextStyle(color: Color(0xfffafafa))),
const Text("Poland, qwer",
style: TextStyle(
color: Color(0xfffafafa),
fontSize: 10.0)),
],
),
background: Image.asset(
"images/batmen.jpg",
fit: BoxFit.cover,
)),
)
];
},
body: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(),
child: Column(children: <Widget>[
ListTile(
title: Text('Driving information',
style: TextStyle(
color: Color(0xfffafafa),
fontSize: 20.0))),
........
],
)),
])))),
),
),
Positioned(
child: new FloatingActionButton(
child: Icon(
Icons.create,
color: Color(0xfffafafa),
),
backgroundColor: Color(0xff31803f),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => RegisterForm()));
},
),
right: 10.0,
top: appBarHeight - 5.0,
)
],
);
}
}