我的两页 Flutter 应用需要一个持久的底部应用栏,最多只能显示几行文本,没有导航。此外,此底部不应与任何内容重叠;而是限制它,比如顶部的应用栏。建议表示赞赏。例子超级赞赏。谢谢!
================@chunhunghan================
感谢您的建议。不幸的是,底页隐藏了内容:
您可以在下面复制粘贴运行完整代码
您可以使用并使用setbottomSheet
包装AppBar
Container
kToolbarHeight
bottomSheet: Container(
height: kToolbarHeight,
child: AppBar(
title: Text("bottom sheet"),
),
),
工作演示
完整代码
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: ListView(
children:
List.generate(100, (i) => Text("line" + i.toString()))),
),
],
),
),
bottomSheet: Container(
height: kToolbarHeight,
child: AppBar(
title: Text("bottom sheet"),
),
),
);
}
}
建议继续使用bottomNavigationBar
类似的东西:
Widget build(BuildContext context) {
return new Scaffold(
body: new Center(
child: new ListView(
children: List.generate(100, (i) => Text("this is a line" + i.toString()))
),
),
bottomNavigationBar:Text(
"this is some info"
)
);
}
在此示例中,您可以看到列表中的所有项目都显示在底部应用栏下方,而不是隐藏。