Skip to content

Unresolved static analysis issues with generated code #203

@M-Ahal

Description

@M-Ahal

My model class

@Rf()
final class LoginFormModel {
  final String domain;
  final String username;
  final String password;
  final bool rememberMe;

  const LoginFormModel({
    @RfControl(validators: [RequiredValidator()]) this.domain = '',
    @RfControl(validators: [RequiredValidator()]) this.username = '',
    @RfControl(validators: [RequiredValidator()]) this.password = '',
    @RfControl<bool>() this.rememberMe = true,
  });
}

The generated code for this has a lot of static analysis issues:

Dart analyze output

error login_form_model.gform.dart:284:43 • A value of type 'Map<String, dynamic>' can't be returned from the function 'domainErrors' because it has a return type of 'Map<String, Object>'. • return_of_invalid_type

error • login_form_model.gform.dart:286:45 • A value of type 'Map<String, dynamic>' can't be returned from the function
'usernameErrors' because it has a return type of 'Map<String, Object>'. • return_of_invalid_type

error • login_form_model.gform.dart:288:45 • A value of type 'Map<String, dynamic>' can't be returned from the function
'passwordErrors' because it has a return type of 'Map<String, Object>'. • return_of_invalid_type

error • login_form_model.gform.dart:290:47 • A value of type 'Map<String, dynamic>' can't be returned from the function 'rememberMeErrors' because it has a return type of 'Map<String, Object>'. • return_of_invalid_type

error • login_form_model.gform.dart:540:19 • The method 'updateInitial' isn't defined for the type 'FormModel'. Try correcting the name to the name of an existing method, or defining a method named 'updateInitial'. • undefined_method

I cannot build my application anymore.

Flutter version

Flutter 3.38.5 • channel stable • https://github.com/flutter/flutter.git Framework • revision f6ff1529fd (4 weeks ago) • 2025-12-11 11:50:07 -0500 Engine • hash c108a94d7a8273e112339e6c6833daa06e723a54 (revision 1527ae0ec5) (24 days ago) • 2025-12-11 15:04:31.000Z Tools • Dart 3.10.4 • DevTools 2.51.1

Package version

reactive_forms_generator: ^8.0.3
reactive_forms_generator:
    dependency: "direct dev"
    description:
      name: reactive_forms_generator
      sha256: "6b6d0325967733339431a39c07d3e9c67517bdfa0648c69ce6193587a476d09e"
      url: "https://pub.dev"
    source: hosted
    version: "8.1.0-beta2"

Note

Using reactive_forms_annotations: ^8.1.0-beta2 removes the undefined_method error atleast. But the type errors stay. I need to manually change the return type to Map<String, dynamic> for all fields

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