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

Getting an Error with just Importing the Package #2

Closed
SteveBraich opened this issue Jul 12, 2023 · 7 comments
Closed

Getting an Error with just Importing the Package #2

SteveBraich opened this issue Jul 12, 2023 · 7 comments

Comments

@SteveBraich
Copy link

I followed the instructions for installing flutter_reactive_value as described here.

flutter pub add flutter_reactive_value

And I added the import on my main.dart:

import 'package:flutter_reactive_value/flutter_reactive_value.dart';

That's as far as I get.

I am on dart 2.18. I tried it with all versions of this library (1.0.0 - 1.0.3). Also, I downloaded the example (the entire project folder) located here and got the same error listed below. I tried this both as a Flutter web (chrome) and a Flutter Windows app.

Flutter web (Chrome) Error:

Launching lib\main.dart on Chrome in debug mode...
main.dart:1
: Error: The getter 'mounted' isn't defined for the class 'Element'.
reactive_value_notifier.dart:30
- 'Element' is from 'package:flutter/src/widgets/framework.dart' ('../flutter/packages/flutter/lib/src/widgets/framework.dart').
framework.dart:1
Try correcting the name to the name of an existing getter, or defining a getter or field named 'mounted'.
      if (elementRef.target?.mounted ?? false) {
                             ^^^^^^^

Failed to compile application.
Exited (sigterm)

Flutter Windows Error:

Launching lib\main.dart on Windows in debug mode...
../lib/src/reactive_value_notifier.dart(30,30): error G4127D1E8: The getter 'mounted' isn't defined for the class 'Element'. [C:\workspace\flutter_reactive_value\example\build\windows\flutter\flutter_assemble.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(247,5): error MSB8066: Custom build for 'C:\workspace\flutter_reactive_value\example\build\windows\CMakeFiles\6f135da36535027a04cd8738f00853c4\flutter_windows.dll.rule;C:\workspace\flutter_reactive_value\example\build\windows\CMakeFiles\335e6badeb606c6fb4bbef90392b261d\flutter_assemble.rule;C:\workspace\flutter_reactive_value\example\windows\flutter\CMakeLists.txt' exited with code 1. [C:\workspace\flutter_reactive_value\example\build\windows\flutter\flutter_assemble.vcxproj]
Exception: Build process failed.
Exited (sigterm)

Any ideas? I am really hoping to use the simple state management that flutter_reactive_value offers. Thanks!

@radomir9720
Copy link

Hi, @SteveBraich. I answered here

@lukehutch
Copy link
Owner

@radomir9720 Thanks for pinpointing that, and for your very detailed StackOverflow breakdown. Widget used to have the getter mounted, going back 8+ years -- it must have been moved to Element in 3.7.0.

I'll add info to the README.md pointing people to ValueListenableBuilder as an alternative.

@SteveBraich I updated the Dart and Flutter minimum version constraints based on this information. Your code should work now, assuming it works on Dart >=2.19.0 and Flutter >=3.7.0.

@lukehutch
Copy link
Owner

@SteveBraich I published the minimum version fixes as flutter_reactive_value v1.0.4. Thanks for the report!

@SteveBraich
Copy link
Author

flutter_reactive_value

Thanks Radomir! I commented on your answer to my stackoverflow post. Downgrading to the 1.0.1 or 1.0.0 version of the package results in the same error.

Hi, @SteveBraich. I answered here

@radomir9720
Copy link

@SteveBraich Answered to your comment on StackOverflow. Take a look at it to see the detailed answer.

In short, specify package version without caret:
flutter_reactive_value package: 1.0.1
Instead of
flutter_reactive_value package: ^1.0.1

@lukehutch
Copy link
Owner

@SteveBraich Answered to your comment on StackOverflow. Take a look at it to see the detailed answer.

In short, specify package version without caret: flutter_reactive_value package: 1.0.1 Instead of flutter_reactive_value package: ^1.0.1

Correct, but a better solution is to depend upon 1.0.4.

@radomir9720
Copy link

@SteveBraich Answered to your comment on StackOverflow. Take a look at it to see the detailed answer.
In short, specify package version without caret: flutter_reactive_value package: 1.0.1 Instead of flutter_reactive_value package: ^1.0.1

Correct, but a better solution is to depend upon 1.0.4.

He has flutter version below 3.7.0, so 1.0.4 is incompatible with his flutter version. If he will update flutter, then, of course, better to target 1.0.4, or, even, 1.0.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants