As per SOLID principles, MacOsScaffold's toolBar should be a PreferredSizeWidget.
The longer story.
Hello guys, hope you are well. I was going to write an app for MacOS. I have adopted this amazing library.
However, I have hit a wall with this scenario:
My MainScreen contains a MacOsScaffold, which contains a ToolBar and many children:
My ToolBar has many options, conditions and buttons, so I would like to create a separate Widget to deal with those.
However, the MacosScaffold doesn't accept anything else that is not a ToolBar.
Other frameworks (e.g. Material) accepts a PreferredSizeWidget, which allows me to write
import 'package:macos_ui/macos_ui.dart'; //kToolbarHeight is now publicly available!
class MyToolbar extends StatelessWidget implements PreferredSizeWidget {
@override
Widget build(BuildContext context) {
return ToolBar(
actions: [
...
],
)
}
@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
}
And this solves my problem.
BONUS: this respect's Flutter's phylosophy of composition over inheritance.
Pre-launch Checklist
[x] I have incremented the package version as appropriate and updated CHANGELOG.md with my changes
[x] I have added/updated relevant documentation
[x] I have run "optimize/organize imports" on all changed files
[x] I have addressed all analyzer warnings as best I could
TL;DR
As per SOLID principles,
MacOsScaffold
'stoolBar
should be aPreferredSizeWidget
.The longer story.
Hello guys, hope you are well. I was going to write an app for MacOS. I have adopted this amazing library. However, I have hit a wall with this scenario: My
MainScreen
contains aMacOsScaffold
, which contains aToolBar
and many children:My
ToolBar
has many options, conditions and buttons, so I would like to create a separateWidget
to deal with those. However, theMacosScaffold
doesn't accept anything else that is not aToolBar
.Other frameworks (e.g.
Material
) accepts aPreferredSizeWidget
, which allows me to writeAnd this solves my problem.
BONUS: this respect's Flutter's phylosophy of composition over inheritance.
Pre-launch Checklist
CHANGELOG.md
with my changes