Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter web in profile and realease mode, considere specific variable always null #147482

Open
apps-auth opened this issue Apr 28, 2024 · 1 comment
Labels
in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Comments

@apps-auth
Copy link

apps-auth commented Apr 28, 2024

Steps to reproduce

It has a large flutter system that has worked normally for years, I recently updated flutter to version 3.19.5 and since then I have had several problems only in the web version in profile and release mode, which do not happen anywhere else.

Everyone was able to adapt, but this last one caught my attention, apparently Flutter, when converting the code to js, is assuming that a variable is always null, below are some images:
logs
image

Below is the generated javascript code:

copyWith$9$cavalo$conditions$id$name$optionalSelected$optionalSelectedDefaultId$optionals$optionalsIds$visualizationIsConditioned(cavalo, conditions, id, $name, optionalSelected, optionalSelectedDefaultId, optionals, optionalsIds, visualizationIsConditioned) {
    var t1, t2, t3, t4, t5, t6, t7, t8, t9, _this = this;
    A.print("copyWith(): this.nameForUser: " + A.S(_this.nameForUser));
    A.print("copyWith(): cavalo: " + A.S(cavalo));
    A.print("copyWith(): nameForUser.runtimeType: " + A.S(cavalo) + " = " + B.JSNull_methods.get$runtimeType(cavalo).toString$0(0) + " = true");
    A.print("copyWith(): nameForUser: " + A.S(cavalo));
    A.print("copyWith(): this.name: " + A.S(_this.name));
    A.print("copyWith(): name: " + A.S($name));
    A.print("copyWith(): name.runtimeType: " + J.get$runtimeType$($name).toString$0(0));
    A.print("*****");
    t1 = id == null ? _this.id : id;
    t2 = _this.nameForUser;
    if (optionalsIds == null) {
      t3 = _this.optionalsIds;
      if (t3 == null)
        t3 = [];
      t3 = A.List_List$from(t3, true, type$.String);
    } else
      t3 = optionalsIds;
    t4 = $name == null ? _this.name : $name;
    if (optionals == null) {
      t5 = _this.optionals;
      if (t5 == null)
        t5 = [];
      t5 = A.List_List$from(t5, true, type$.ProductAcessorie);
    } else
      t5 = optionals;
    if (optionalSelected == null) {
      t6 = _this.optionalSelected;
      t6 = t6 == null ? null : t6.copyWith$0();
    } else
      t6 = optionalSelected;
    t7 = optionalSelectedDefaultId == null ? _this.optionalSelectedDefaultId : optionalSelectedDefaultId;
    t8 = visualizationIsConditioned == null ? _this.visualizationIsConditioned : visualizationIsConditioned;
    t9 = _this.conditionIsValid;
    return A.ProductAcessoriesGroup$(t9, conditions == null ? _this.ProductOptionalSelectorGroupBase_conditions : conditions, t1, t4, t2, t6, t7, t5, t3, t8);
  },
    copyWith$1$id(id) {
      var _null = null;
      return this.copyWith$9$cavalo$conditions$id$name$optionalSelected$optionalSelectedDefaultId$optionals$optionalsIds$visualizationIsConditioned(_null, _null, id, _null, _null, _null, _null, _null, _null);
    },
    copyWith$1$cavalo(cavalo) {
      var _null = null;
      return this.copyWith$9$cavalo$conditions$id$name$optionalSelected$optionalSelectedDefaultId$optionals$optionalsIds$visualizationIsConditioned(cavalo, _null, _null, _null, _null, _null, _null, _null, _null);
    },

In the lines A.print("copyWith(): nameForUser.runtimeType: " + A.S(cavalo) + " = " + B.JSNull_methods.get$runtimeType(cavalo).toString$0(0) + " = true"); when print the value calls the function "A.S()" but when print the type calls the function "B.JSNull_methods"

On the line t1 = id == null ? _this.id : id; it checks if the id is different from null, already on the line t2 = _this.nameForUser; it disregards the parameter passed in the function

I've already tried changing the name and position of the variable but nothing works.
I found two similar problems:
https://github.com/dart-lang/sdk/issues/44692
dart-lang/sdk#44692

Expected results

That the code does not automatically consider the variable null

Actual results

When converting to javascript, dart is assuming the variable as always null

Flutter Doctor output

[√] Flutter (Channel stable, 3.19.5, on Microsoft Windows [versÆo 10.0.22631.3447], locale pt-BR)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2019 16.11.32)
[!] Android Studio (version 2021.2)
X Unable to determine bundled Java version.
[√] Android Studio (version 2023.2)
[√] VS Code (version 1.88.1)
[√] Connected device (3 available)
[√] Network resources

@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Apr 29, 2024
@darshankawar
Copy link
Member

Thanks for the report @apps-auth
Is there a way for you to provide us reproducible code that shows this behavior ?

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
None yet
Development

No branches or pull requests

2 participants