Created
October 4, 2023 04:42
Revisions
-
SamJakob created this gist
Oct 4, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ /// This class extends [SizedBox] whilst implementing [PreferredSizeWidget] /// based on the defined size. This allows the use of [SizedBox] in places /// where [PreferredSizeWidget] is required, such as in [AppBar.preferredSize]. class PreferredSizedBox extends SizedBox implements PreferredSizeWidget { const PreferredSizedBox({super.key}); const PreferredSizedBox.shrink({super.key, super.child}) : super.shrink(); const PreferredSizedBox.expand({super.key, super.child}) : super.expand(); PreferredSizedBox.fromSize({super.key, super.child, super.size}) : super.fromSize(); const PreferredSizedBox.square({super.key, super.child, super.dimension}) : super.square(); @override Size get preferredSize => Size( width ?? double.infinity, height ?? double.infinity, ); }