Skip to content

[go_router_builder]: After mirgate to version 2.8.1 , the queryParams with required enum cause error #164354

@CaoGiaHieu-dev

Description

@CaoGiaHieu-dev

Steps to reproduce

  1. using example code and generate

Expected results

enum params can parse

Actual results

enum params can not parse

Code sample

Code sample
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: public_member_api_docs, unreachable_from_main

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

import 'shared/data.dart';

part 'required_enum.g.dart';

void main() => runApp(App());

class App extends StatelessWidget {
  App({super.key});

  @override
  Widget build(BuildContext context) => MaterialApp.router(
        routerConfig: _router,
        title: _appTitle,
      );

  final GoRouter _router = GoRouter(routes: $appRoutes);
}

enum RequiredEnum { foo, bar }

@TypedGoRoute<HomeRoute>(
  path: '/',
  name: 'Home',
)
class HomeRoute extends GoRouteData {
  const HomeRoute({required this.type});
  final RequiredEnum type;
  @override
  Widget build(BuildContext context, GoRouterState state) {
    return HomeScreen(type: type);
  }
}

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key, required this.type});
  final RequiredEnum type;

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(title: const Text(_appTitle)),
        body: Text(type.name),
      );
}

const String _appTitle = 'GoRouter Example: builder';

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
Error: The argument type 'String?' can't be assigned to the parameter type 'String' because 'String?' is nullable and 'String' isn't.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.0, on macOS 14.5 23F79 darwin-arm64, locale vi-VN) [1.518ms]
    • Flutter version 3.29.0 on channel stable at /Users/hieucg/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 35c388afb5 (2 weeks ago), 2025-02-10 12:48:41 -0800
    • Engine revision f73bfc4522
    • Dart version 3.7.0
    • DevTools version 2.42.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3,7s]
    • Android SDK at /Users/hieucg/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /Users/hieucg/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 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0) [2,1s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.16.2

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

[✓] Android Studio (version 2024.1) [10ms]
    • 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 17.0.11+0-17.0.11b1207.24-11852314)

[✓] VS Code (version 1.97.2) [9ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.104.0

[✓] Connected device (5 available) [6,6s]
    • iPhone của Cao Gia Hieu (mobile)    • e3010bcca1500cf8a43f8baba42c0d712114c722 • ios            • iOS 16.7.10 20H350
    • iPhone SE (3rd generation) (mobile) • 7BA87560-AA51-4301-AC70-D31B4D44F6BC     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-0 (simulator)
    • macOS (desktop)                     • macos                                    • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop)     • mac-designed-for-ipad                    • darwin         • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                        • chrome                                   • web-javascript • Google Chrome 133.0.6943.142

[✓] Network resources [583ms]
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: regressionIt was better in the past than it is nowp: go_router_builderThe go_router_builder 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