Skip to content

[flutter_adaptive_scaffold] Leading and Trailing widgets are not visible on NavigationRail #114684

Description

@sabin26

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Resize window

Expected results:
On Extended Navigation Rail:
nav_rail_extended

On Unextended Navigation Rail: (Since there is no trailingUnextendedNavRail property)
nav_rail_unextended

Actual results:
On Extended Navigation Rail:
nav_rail_extended_issue

On Unextended Navigation Rail:
nav_rail_unextended_issue

Code sample
import 'package:flutter/material.dart';
import 'package:flutter_adaptive_scaffold/flutter_adaptive_scaffold.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorSchemeSeed: const Color(0xFFE4935D),
        useMaterial3: true,
        brightness: Brightness.light,
      ),
      // darkTheme: ThemeData(
      //   colorSchemeSeed: const Color(0xFFE4935D),
      //   useMaterial3: true,
      //   brightness: Brightness.dark,
      // ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return AdaptiveScaffold(
      appBar: AppBar(
        elevation: 4,
        title: const Text('Demo App'),
      ),
      useDrawer: false,
      trailingNavRail: OutlinedButton.icon(
        icon: const Icon(Icons.exit_to_app),
        onPressed: () {},
        label: const Text('Exit'),
      ),
      leadingExtendedNavRail: OutlinedButton.icon(
        icon: const Icon(Icons.add),
        onPressed: () {},
        label: const Text('New'),
      ),
      leadingUnextendedNavRail: IconButton(
        icon: const Icon(Icons.add),
        onPressed: () {},
      ),
      destinations: const <NavigationDestination>[
        NavigationDestination(
          icon: Icon(Icons.home),
          label: 'Home',
        ),
        NavigationDestination(
          icon: Icon(Icons.add_box),
          label: 'Counter',
        ),
      ],
      body: (final _) {
        return const SizedBox.shrink();
      },
      onSelectedIndexChange: (final index) {},
    );
  }
}

This issue is caused because the leading and trailing widgets are not passed into AdaptiveScaffold.standardNavigationRail() function from AdaptiveScaffold widget in adaptive_scaffold.dart.

The solution:

After providing leading and trailing widgets to AdaptiveScaffold.standardNavigationRail() from AdaptiveScaffold widget, it works as expected.

class _AdaptiveScaffoldState extends State<AdaptiveScaffold> {
  @override
  Widget build(BuildContext context) {
    return Directionality(
      ...
        body: AdaptiveLayout(
          bodyOrientation: widget.bodyOrientation,
          bodyRatio: widget.bodyRatio,
          internalAnimations: widget.internalAnimations,
          primaryNavigation: SlotLayout(
            config: <Breakpoint, SlotLayoutConfig>{
              widget.mediumBreakpoint: SlotLayout.from(
                key: const Key('primaryNavigation'),
                builder: (_) => AdaptiveScaffold.standardNavigationRail(
                  width: widget.navigationRailWidth,
                  selectedIndex: widget.selectedIndex,
                  leading: widget.leadingUnextendedNavRail, // add this line
                  destinations: widget.destinations
                      .map((_) => AdaptiveScaffold.toRailDestination(_))
                      .toList(),
                  onDestinationSelected: widget.onSelectedIndexChange,
                ),
              ),
              widget.largeBreakpoint: SlotLayout.from(
                key: const Key('primaryNavigation1'),
                builder: (_) => AdaptiveScaffold.standardNavigationRail(
                  width: widget.extendedNavigationRailWidth,
                  extended: true,
                  leading: widget.leadingExtendedNavRail, // add this line
                  trailing: widget.trailingNavRail, // add this line
                  selectedIndex: widget.selectedIndex,
                  destinations: widget.destinations
                      .map((_) => AdaptiveScaffold.toRailDestination(_))
                      .toList(),
                  onDestinationSelected: widget.onSelectedIndexChange,
                ),
              ),
            },
          ),
          ...
    );
  }
}

Activity

  1. darshankawar commented on Nov 7, 2022

    @darshankawar
    Member

    Thanks for the detailed report and code sample. Using it, I see same behavior.

    stable, master flutter doctor -v
    [✓] Flutter (Channel stable, 3.3.7, on macOS 12.2.1 21D62 darwin-x64, locale
        en-GB)
        • Flutter version 3.3.7 on channel stable at
          /Users/dhs/documents/fluttersdk/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision e99c9c7cd9 (2 days ago), 2022-11-01 16:59:00 -0700
        • Engine revision 857bd6b74c
        • Dart version 2.18.4
        • DevTools version 2.15.0
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    [!] Flutter (Channel master, 3.5.0-12.0.pre.141, on macOS 12.2.1 21D62
        darwin-x64, locale en-GB)
        • Flutter version 3.5.0-12.0.pre.141 on channel master at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 19c5fc50d9 (45 minutes ago), 2022-11-06 23:09:10 -0500
        • Engine revision 0cbdf464c0
        • Dart version 2.19.0 (build 2.19.0-374.0.dev)
        • DevTools version 2.19.0
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
        
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    
    
    
  2. added
    packageflutter/packages repository. See also p: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Nov 7, 2022
  3. added
    P2Important issues not at the top of the work list
    on Nov 15, 2022
  4. added a commit that references this issue on Jan 24, 2023
    12d189e
  5. added a commit that references this issue on Jan 24, 2023
    dbd24ef
  6. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jan 25, 2023
  7. github-actions commented on Mar 4, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Mar 4, 2023
  9. added a commit that references this issue on Jun 10, 2026
    f63a48c
  10. added a commit that references this issue on Jun 19, 2026
    ea54f96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.3Found to occur in 3.3found in release: 3.5Found to occur in 3.5has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: flutter_adaptive_scaffoldThe flutter_adaptive_scaffold packagepackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions