Skip to content

[flutter_adaptive_scaffold] - Display an AppBar on bigger screen than mobile #130117

@wer-mathurin

Description

@wer-mathurin

Is there an existing issue for this?

Use case

This can be common to display on Desktop and table an AppBar to show widget (eg. Search field) like in Gmail.

Today this is impossible because the logic prevent that in the AdaptiveScaffold

appBar: widget.drawerBreakpoint.isActive(context) && widget.useDrawer
        ? widget.appBar ?? AppBar()
        : null,

Proposal

This can be fixed by adding a new property to the Widget => Breakpoint? appBarBreakpoint
This way we are not breaking the API and can display an AppBar is needed on defined breakpoints. It also not relying on the useDrawer flag!

 appBar: widget.drawerBreakpoint.isActive(context) && widget.useDrawer ||
              (widget.appBarBreakpoint?.isActive(context) ?? false)
          ? widget.appBar ?? AppBar()
          : null,

This way we can use the AdaptiveScaffold

   final double leadingWidth =
            Breakpoints.large.isActive(context) ? 192 : 72;

        return Theme(
          data: Theme.of(context).copyWith(
              appBarTheme: AppBarTheme.of(context).copyWith(
                  backgroundColor: Colors.grey.shade200,
                  iconTheme:
                      IconTheme.of(context).copyWith(color: Colors.grey))),
          child: AdaptiveScaffold(
            appBar: MyCustomAppBar(leadingWidth: leadingWidth),
            appBarBreakpoint: Breakpoints.smallAndUp,
...

With this setup we can achieve this in
mobile
image

tablet
image

desktop
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: flutter_adaptive_scaffoldThe flutter_adaptive_scaffold packagepackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions