fix theme updating desktop appbar children

This commit is contained in:
julian 2022-12-05 16:41:46 -06:00
parent 4593f7a0dc
commit 820efa4d8b

View file

@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
const double kDesktopAppBarHeight = 96.0;
const double kDesktopAppBarHeightCompact = 82.0;
class DesktopAppBar extends StatefulWidget {
class DesktopAppBar extends StatelessWidget {
const DesktopAppBar({
Key? key,
this.leading,
@ -22,46 +22,33 @@ class DesktopAppBar extends StatefulWidget {
final bool useSpacers;
@override
State<DesktopAppBar> createState() => _DesktopAppBarState();
}
class _DesktopAppBarState extends State<DesktopAppBar> {
late final List<Widget> items;
@override
void initState() {
items = [];
if (widget.leading != null) {
items.add(widget.leading!);
Widget build(BuildContext context) {
final List<Widget> items = [];
if (leading != null) {
items.add(leading!);
}
if (widget.useSpacers) {
if (useSpacers) {
items.add(const Spacer());
}
if (widget.center != null) {
items.add(widget.center!);
if (widget.useSpacers) {
if (center != null) {
items.add(center!);
if (useSpacers) {
items.add(const Spacer());
}
}
if (widget.trailing != null) {
items.add(widget.trailing!);
if (trailing != null) {
items.add(trailing!);
}
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: widget.background,
color: background,
),
height: widget.isCompactHeight
? kDesktopAppBarHeightCompact
: kDesktopAppBarHeight,
height:
isCompactHeight ? kDesktopAppBarHeightCompact : kDesktopAppBarHeight,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,