瀏覽代碼

added option to disable flexible space

ashilkn 2 年之前
父節點
當前提交
bec4a99548
共有 1 個文件被更改,包括 34 次插入28 次删除
  1. 34 28
      lib/ui/components/title_bar_widget.dart

+ 34 - 28
lib/ui/components/title_bar_widget.dart

@@ -12,6 +12,7 @@ class TitleBarWidget extends StatelessWidget {
   // https://api.flutter.dev/flutter/material/VisualDensity-class.html
   final List<Widget>? actionIcons;
   final bool isTitleH2WithoutLeading;
+  final bool isFlexibleSpaceDisabled;
   const TitleBarWidget({
     this.title,
     this.caption,
@@ -19,6 +20,7 @@ class TitleBarWidget extends StatelessWidget {
     this.flexibleSpaceCaption,
     this.actionIcons,
     this.isTitleH2WithoutLeading = false,
+    this.isFlexibleSpaceDisabled = false,
     super.key,
   });
 
@@ -79,39 +81,43 @@ class TitleBarWidget extends StatelessWidget {
                 icon: const Icon(Icons.arrow_back_outlined),
               ),
             ),
-      flexibleSpace: FlexibleSpaceBar(
-        background: SafeArea(
-          child: Column(
-            crossAxisAlignment: CrossAxisAlignment.start,
-            mainAxisSize: MainAxisSize.min,
-            children: <Widget>[
-              const SizedBox(height: toolbarHeight),
-              Padding(
-                padding:
-                    const EdgeInsets.symmetric(vertical: 4, horizontal: 16),
+      flexibleSpace: isFlexibleSpaceDisabled
+          ? null
+          : FlexibleSpaceBar(
+              background: SafeArea(
                 child: Column(
                   crossAxisAlignment: CrossAxisAlignment.start,
-                  children: [
-                    flexibleSpaceTitle == null
-                        ? const SizedBox.shrink()
-                        : flexibleSpaceTitle!,
-                    flexibleSpaceCaption == null
-                        ? const SizedBox.shrink()
-                        : Text(
-                            flexibleSpaceCaption!,
-                            style: textTheme.small.copyWith(
-                              color: colorTheme.textMuted,
-                            ),
-                            overflow: TextOverflow.ellipsis,
-                            maxLines: 1,
-                          )
+                  mainAxisSize: MainAxisSize.min,
+                  children: <Widget>[
+                    const SizedBox(height: toolbarHeight),
+                    Padding(
+                      padding: const EdgeInsets.symmetric(
+                        vertical: 4,
+                        horizontal: 16,
+                      ),
+                      child: Column(
+                        crossAxisAlignment: CrossAxisAlignment.start,
+                        children: [
+                          flexibleSpaceTitle == null
+                              ? const SizedBox.shrink()
+                              : flexibleSpaceTitle!,
+                          flexibleSpaceCaption == null
+                              ? const SizedBox.shrink()
+                              : Text(
+                                  flexibleSpaceCaption!,
+                                  style: textTheme.small.copyWith(
+                                    color: colorTheme.textMuted,
+                                  ),
+                                  overflow: TextOverflow.ellipsis,
+                                  maxLines: 1,
+                                )
+                        ],
+                      ),
+                    ),
                   ],
                 ),
               ),
-            ],
-          ),
-        ),
-      ),
+            ),
     );
   }