Flutter Error: 'UnmodifiableUint8ListView' is restricted and can't be extended or implemented
Asked Answered
G

12

10

I'm building a FLutter code that has the following error for both Android and IOS:

../../development/flutter/.pub-cache/hosted/pub.dartlang.org/uuid_enhanced-3.0.2/lib/uuid.dart:9:7: Error: 'UnmodifiableUint8ListView' is restricted and can't be extended or 

implemented.
class Uuid extends UnmodifiableUint8ListView {
      ^


FAILURE: Build failed with an exception.

Flutter doctor status:

[✓] Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-arm, locale
    en-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.61.0)
[✓] Connected device (2 available)

• No issues found!

The code has no problem on my second MAC.

Any idea how to solve this problem? I also attached the ymal file. The point is that this ymal file has no problem with the second MAC. And even when I am cloning the previous versions from Git, I am receiving the same error.

Gentlefolk answered 13/10, 2021 at 9:39 Comment(1)
Could you add your pubspec.yaml file? You have upgraded one of the libraries and it's causing this issueSuffolk
S
3

It might be related to breaking Dart changes https://github.com/dart-lang/sdk/issues/45115

With your second mac you have upgraded your Flutter and dart. (Also packages)

Simple solution is to downgrade Flutter/Dart. How to downgrade Flutter SDK (Dart 1.x)

Or find which package is causing it and upgrade/remove it.

Suffolk answered 13/10, 2021 at 9:48 Comment(5)
Thank you so much for the response... I tested both upgrading and downgrading but it is not working... The interesting point is other projects on the first mac have no problem with the building.Gentlefolk
Downgrade to same flutter/dart version as u have on ur other computer. Then do flutter doctor and flutter clean ur problem is caused by uuid_enhanced package - it's no longer maintained. Would suggest removing it and simply use uuidSuffolk
Unfortunately, the downgrading does not work... Do you mean to remove the uuid package from the root of the Flutter ask folder?Gentlefolk
I removed the Flutter folder and downloaded and installed the Flutter 2.2.3 and it fixed the problem.Gentlefolk
.. Why downgrading the code?? You can clear the pub cache, it has cache of the old versionCamara
R
13
flutter pub upgrade --major-versions

this fixed my issue, simply went with the flutter cli recommendation

Reparative answered 21/8 at 16:40 Comment(2)
This works for me at 2024, Flutter version 3.24.2Imeldaimelida
Worked for me too, Flutter version 3.24.1 Thanks! My code was built with the older version (3.16.5), but then I upgraded it to the latest version and got this issueCamara
P
9

For me, I just ran this command

flutter pub upgrade win32

And then I ran the following command to clear the cache and everything worked fine

flutter pub cache clean

I found this solution from Github and it worked for me

Paulitapaulk answered 9/8 at 12:12 Comment(1)
For me, it was enough with upgrading win32, no need to clean the cache.Juna
S
3

It might be related to breaking Dart changes https://github.com/dart-lang/sdk/issues/45115

With your second mac you have upgraded your Flutter and dart. (Also packages)

Simple solution is to downgrade Flutter/Dart. How to downgrade Flutter SDK (Dart 1.x)

Or find which package is causing it and upgrade/remove it.

Suffolk answered 13/10, 2021 at 9:48 Comment(5)
Thank you so much for the response... I tested both upgrading and downgrading but it is not working... The interesting point is other projects on the first mac have no problem with the building.Gentlefolk
Downgrade to same flutter/dart version as u have on ur other computer. Then do flutter doctor and flutter clean ur problem is caused by uuid_enhanced package - it's no longer maintained. Would suggest removing it and simply use uuidSuffolk
Unfortunately, the downgrading does not work... Do you mean to remove the uuid package from the root of the Flutter ask folder?Gentlefolk
I removed the Flutter folder and downloaded and installed the Flutter 2.2.3 and it fixed the problem.Gentlefolk
.. Why downgrading the code?? You can clear the pub cache, it has cache of the old versionCamara
L
2

I've solved this issue by following commands

  1. flutter pub upgrade win32

  2. flutter pub cache clean

  3. flutter channel stable

  4. flutter clean && flutter pub get

  5. flutter pub upgrade

it's helped for me

Lukin answered 2/9 at 5:54 Comment(0)
C
1

If you are facing this error while using get_cli and you don't want to downgrade Flutter, or pub upgrade win32 is not working, just run this command:

flutter pub global activate -s git https://github.com/jonataslaw/get_cli

It will automatically upgrade the win32 package:

# flutter pub global activate -s git https://github.com/jonataslaw/get_cli
Downloading packages... (37.5s))
+ _fe_analyzer_shared 73.0.0
+ _macros 0.3.2 from sdk dart
+ analyzer 6.8.0
+ ansicolor 2.0.2
+ archive 3.6.1
+ args 2.5.0
...
+ win32 5.5.3
+ yaml 3.1.2 Building package executables... (9.5s)
Built get_cli:get.
Installed executables get and getx.
Activated get_cli 1.8.4 from Git repository "https://github.com/jonataslaw/get_cli".
Commissariat answered 12/8 at 10:20 Comment(0)
T
1

I have upgraded to Flutter 3.24.0 and I am getting the same issue.

The following solved the issue for mine:

flutter pub upgrade --major-versions
Threatt answered 15/9 at 11:4 Comment(0)
P
0

I can try all possible solutions, but I'm unable to resolve the following issue:

Running Gradle task 'assembleDebug'...
Error: Type 'UnmodifiableUint8ListView' not found in /C:/Users/AppData/Local/Pub/Cache/hosted/pub.dev/win32-5.2.0/lib/src/guid.dart:32:9.

Solution: After several attempts, I added win32: ^5.5.3 to my pubspec.yaml file, and my project ran successfully.

If this doesn’t work, try running the following commands in the Android Studio or VS Code terminal:

  • flutter pub cache clean
  • flutter channel stable
  • flutter pub get

Make sure to remove the package from pubspec.yaml before running these commands, then re-add the package and try running it again.

Parton answered 19/8 at 4:58 Comment(0)
I
0

add this to file pubspec.yaml

dependency_overrides:
      win32: ^5.5.4

and flutter pub get again

Indisposition answered 23/8 at 11:3 Comment(1)
This worked for me. ThanksGamali
E
0

You can try these two ways:

First way:

flutter pub cache clean
flutter pub get
flutter pub upgrade

Second way:

flutter pub cache clean
flutter channel stable
flutter pub get

These two forms solve this problem for me in two differents projects.

Elijah answered 26/8 at 23:28 Comment(0)
S
-1

I've had same issue, and solved it by running the following commands:

flutter pub cache clean
flutter channel stable
flutter pub upgrade win32
flutter pub get
Shore answered 9/8 at 7:37 Comment(0)
H
-1

just add this dependency: win32: ^5.5.3

Hapten answered 9/8 at 16:15 Comment(0)
F
-1

Finally found a solution, incase if you don't want to downgrade the flutter or pub upgrade win32 is not working just run this command:

flutter pub global activate -s git https://github.com/jonataslaw/get_cli

It will automatically upgrade the win32:

Fantail answered 12/8 at 10:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.