Skip to content

[bug]: CustomRoute's customRouteBuilder does not generate the custom route #1164

@Lord-Chris

Description

@Lord-Chris

Describe the bug

Using the customRouteBuilder of CustomRoute ignores the custom route builder and generates the default PageRouteBuilder.

What operating system do you use?

macOS

Information about the installed tooling

[✓] Flutter (Channel stable, 3.29.2, on macOS 15.3.1 24D70 darwin-arm64, locale en-GB) [785ms]
    • Flutter version 3.29.2 on channel stable at /Users/lordchris/MyTools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c236373904 (3 months ago), 2025-03-13 16:17:06 -0400
    • Engine revision 18b71d647a
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [5.4s]
    • Android SDK at /Users/lordchris/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • ANDROID_HOME = /Users/lordchris/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 16.2) [3.2s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    ! CocoaPods 1.15.2 out of date (1.16.2 is recommended).
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods

[✓] Chrome - develop for the web [35ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [34ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-13047016-b750.29)

[✓] IntelliJ IDEA Community Edition (version 2023.3.4) [32ms]
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.101.0) [11ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.112.0

[✓] Connected device (3 available) [11.4s]
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 15.3.1 24D70 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 15.3.1 24D70 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 137.0.7151.120

[✓] Network resources [1,144ms]
    • All expected network resources are available.

Steps to reproduce the issue

Add your custom route to the StackedApp with the customRouteBuilder

CustomRoute(
      page: PageView,
      customRouteBuilder: RouteBuilders.bottomSheetBuilder,
    ),

Here's the bottomSheetBuilder

abstract class RouteBuilders {
  static Route<T> bottomSheetBuilder<T>(
    BuildContext context,
    Widget child,
    CustomPage<T> page,
  ) {
    return ModalBottomSheetRoute<T>(
      builder: page.buildPage,
      settings: page,
      isScrollControlled: false,
      isDismissible: false,
      enableDrag: false,
      useSafeArea: true,
      showDragHandle: false,
      scrollControlDisabledMaxHeightRatio: 0.5,
      constraints: BoxConstraints(
        maxHeight: MediaQuery.of(context).size.height * 0.8,
      ),
      backgroundColor: GigmileColors.background.white,
      modalBarrierColor: GigmileColors.text.primary.withValues(alpha: 0.6),
      elevation: 5,
      shape: const RoundedRectangleBorder(
        borderRadius: BorderRadius.vertical(top: Radius.circular(12)),
      ),
    );
  }
}

Run the build_runner command

The output route

_i4.PageView: (data) {
      return _i87.PageRouteBuilder<dynamic>(
        pageBuilder: (context, animation, secondaryAnimation) =>
            const _i4.PageView(),
        settings: data,
        transitionsBuilder: data.transition ??
            (context, animation, secondaryAnimation, child) {
              return child;
            },
      );
    }

Expected behavior

It should generate with the customRoute builder

Screenshots

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions