Short answer
Wrap the widget in PreferredSize with a height: appBar: PreferredSize(preferredSize: const Size.fromHeight(64), child: MyAppBar()). For a reusable custom app bar, have the class implement PreferredSizeWidget and return its size from preferredSize.
Rather not fix it yourself? App Fix Ticket fixes one reproducible bug at a fixed price, with an optional Diagnosis that is credited toward the fix.
Why Scaffold rejects the widget, and the fix
01
A plain widget passed to appBar
“Parents like Scaffold use PreferredSizeWidget to require that their children implement that interface.” Flutter, PreferredSize class
Wrap it in PreferredSize. The height you give is what Scaffold reserves at the top of the screen. PreferredSize adds no status bar padding, so wrap your bar’s content in SafeArea.
Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(64), child: MyGradientBar(title: title), ), body: body, )02
A reusable custom app bar class
Implement PreferredSizeWidget on the widget itself, so every screen can pass it straight to appBar.
class MyAppBar extends StatelessWidget implements PreferredSizeWidget { const MyAppBar({super.key, required this.title}); final String title; @override Size get preferredSize => const Size.fromHeight(kToolbarHeight); @override Widget build(BuildContext context) => AppBar(title: Text(title)); }03
The same rule in AppBar.bottom
AppBar(bottom: …) also takes a PreferredSizeWidget. A TabBar works as is; anything else, such as a search field, needs PreferredSize too.
AppBar( bottom: PreferredSize( preferredSize: const Size.fromHeight(56), child: Padding( padding: const EdgeInsets.all(8), child: SearchField(onChanged: onSearch), ), ), )
Checked against the vendor’s docs on : Flutter API: Scaffold.appBar; Flutter API: PreferredSize.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug. The Fix costs $1,200. If you need a Diagnosis first, its $450 fee counts toward the Fix.See scope and start
- from $450AI-Built App RescueFor a whole-app review, the $450 Launch Check is credited toward the optional $1,950 Rescue Sprint for up to five critical or high findings.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.See scope and start
“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
Related: Flutter “A RenderFlex overflowed” · Flutter “Invalid constant value” · Flutter “No MediaQuery widget found” · Flutter “The argument type ‘String’ can’t be assigned to the parameter type ‘Uri’”