Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Flutter build fails on UnmodifiableUint8ListView from a package

ErrorError: 'UnmodifiableUint8ListView' is restricted and can't be extended or implemented.

Short answer

Dart deprecated the UnmodifiableUint8ListView family in 3.3 and removed it in 3.5. The replacement is the asUnmodifiableView() method. If the error points into a package cache path, an old dependency still uses the class, so upgrade it. If it points into lib/, change your own code.

  • Applies to Flutter 3.50 stable, Dart 3.5 and newer
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the file path printed above the error. A path under .pub-cache means a dependency; a path under your own lib/ means your code.

    flutter pub outdated
  2. 2Match what you see, then jump to its fix

    1. 1The path in the error contains .pub-cache/hosted/pub.dev/<package>-<version>A dependency still uses the removed classFix
    2. 2The path in the error starts with lib/Your own code constructs the classFix
    3. 3dart pub upgrade keeps the old version; pub outdated shows a newer Latest than ResolvableConstraints in pubspec.yaml stop the fix from resolvingFix

What does the error look like?

  • Error: 'UnmodifiableUint8ListView' is restricted and can't be extended or implemented.

Cause 1 of 3

A dependency still uses the removed class

1Check

Find which package pulls it in; transitive dependencies are hidden unless you ask for them.

dart pub outdated --transitive
dart pub deps

2Fix

Upgrade the named package, and the package that depends on it if it is only transitive. Upgrade just those packages first to keep other versions locked.

dart pub upgrade <package-name>
dart pub upgrade --unlock-transitive <package-name>

3Verify

The build should compile past the old error.

flutter build apk --debug

Confirmed by dart.dev

Did this fix it?

Cause 2 of 3

Your own code constructs the class

1Check

Search the project for the class and its siblings (the other Unmodifiable...View typed-data classes were removed together).

grep -rn "Unmodifiable.*View(" lib/

2Fix

Replace the constructor call with the asUnmodifiableView() method, which exists since Dart 3.3.

// before
final view = UnmodifiableUint8ListView(bytes);
// after
final view = bytes.asUnmodifiableView();

3Verify

Run the analyzer; the undefined class error should be gone.

dart analyze

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 3 of 3

Constraints in pubspec.yaml stop the fix from resolving

1Check

Resolvable is the newest version that fits every constraint. If it is lower than Latest, an upper bound is blocking the fixed release.

dart pub outdated

2Fix

Preview, then allow the major upgrade. This rewrites constraints in pubspec.yaml, so commit first.

dart pub upgrade --major-versions --dry-run
dart pub upgrade --major-versions

3Verify

Run pub outdated again; Upgradable should now match the version you wanted.

dart pub outdated

Confirmed by dart.dev

Did this fix it?

How do I stop it coming back?

  • Run flutter pub outdated before every Flutter SDK upgrade and update packages in the same change.
  • Commit pubspec.lock so builds use the same versions on every machine.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.