我想像這樣在應用欄上方顯示文本訊息,

我怎樣才能用顫振實作這一點?
提前致謝!
uj5u.com熱心網友回復:
Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(customSize),
child: Column(
children: [
Text('Connecting...'),
AppBar(
title: Text('Recents'),
)
],
)),
body: content...,
);
您可以添加為父級SafeArea以避免作業系統入侵
uj5u.com熱心網友回復:
您還可以使用填充進行對齊。
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
bool _showConnecting = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// 24 for default icon size
toolbarHeight: _showConnecting ? kToolbarHeight 24 : kToolbarHeight,
centerTitle: false,
leadingWidth: 0,
titleSpacing: 0,
automaticallyImplyLeading: false,
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
if (_showConnecting)
Container(
color: Colors.black,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.network_cell_sharp),
Text("Connecting.."),
],
),
),
Container(
height: kToolbarHeight,
alignment: Alignment(-.8, 0),
color: Theme.of(context).primaryColor,
child: Text("Recent Mentions"),
),
],
),
),
body: SingleChildScrollView(
child: Column(
children: [
...List.generate(
44,
(index) => Container(
height: 100,
color: index.isEven ? Colors.amber : Colors.cyanAccent,
),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
_showConnecting = !_showConnecting;
});
},
),
);
}}

uj5u.com熱心網友回復:
Scaffold -> Body -> Column -> [ ...widgets, AppBar() ]
uj5u.com熱心網友回復:
如果要實作相同的設計,請考慮使用它來實作 appBar 和 statusBar 之間顏色的一致性:
import 'package:flutter/services.dart';
void main() {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.black, // status bar color
));
}
另一方面,appBar title 屬性是一個小部件,您可以隨意修改它!
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/371759.html
上一篇:Mapmarge是如何作業的?
下一篇:Flutter溢位截止
