Development Solutions/Flutter & Dart

[flutter] Solution - Error: Type 'UnmodifiableUint8ListView' not found. final UnmodifiableUint8ListView bytes;

studio ODOC 2024. 8. 31. 18:15
반응형

Flutter Solution - Error: Type 'UnmodifiableUint8ListView' not found.  final UnmodifiableUint8ListView bytes;

 

 

 

윈도우용 플러터 앱 컴파일 중 발생하는 문제에 대한 해결 방법

윈도우용으로 플러터 앱을 빌드하는 과정에서 Type 'UnmodifiableUint8ListView' not found라는 오류를 겪는다면, 이는 비교적 흔한 문제입니다. 이 오류는 여러 플랫폼을 타겟으로 하는 플러터 프로젝트에서 발생할 수 있으며, 안드로이드와 iOS에서는 정상적으로 동작하지만 윈도우에서 컴파일 시 실패할 수 있습니다. 아래는 이 문제를 이해하고 해결하는 방법에 대한 상세 가이드입니다.



오류 메시지 예시

/C:/Users/YourUser/AppData/Local/Pub/Cache/hosted/pub.dev/win32-5.5.0/lib/src/guid.dart(32,9): error G7D2AEF3C: Type 'UnmodifiableUint8ListView' not found. [D:\Projects\MyProject\myproject\build\windows\x64\flutter\flutter_assemble.vcxproj]
/C:/Users/YourUser/AppData/Local/Pub/Cache/hosted/pub.dev/win32-5.5.0/lib/src/guid.dart(32,9): error G94EA939C: 'UnmodifiableUint8ListView' isn't a type. [D:\Projects\MyProject\myproject\build\windows\x64\flutter\flutter_assemble.vcxproj]



이 오류는 Dart 3.5.0에서 UnmodifiableUint8ListView 클래스가 더 이상 지원되지 않기 때문에 발생합니다. 이 클래스에 의존하는 프로젝트의 일부 의존성 때문에 컴파일 오류가 발생하는 것입니다.



해결 방법



1. 의존성 업데이트 확인: 프로젝트의 모든 의존성이 최신 버전인지 확인합니다. 특히 win32 패키지에 의존하는 경우, 이 패키지가 최신 버전인지 확인하는 것이 중요합니다.

2. flutter pub upgrade 명령 실행: 이 명령을 실행하여 프로젝트의 모든 의존성을 최신 버전으로 업그레이드합니다. 특히 win32 패키지가 5.5.1 이상으로 업데이트되었는지 확인해야 합니다.

>> flutter pub upgrade win32



3. 의존성 확인: 업그레이드 후 pubspec.lock 파일을 확인하거나 아래 명령어를 실행하여 의존성 버전을 확인합니다:


>> flutter pub outdated

4. 프로젝트 재빌드: 의존성 업데이트 후, 프로젝트를 깨끗하게 빌드하기 위해 flutter clean 명령어를 실행하고 다시 빌드합니다:

>> flutter clean
>> flutter pub get
>> flutter build windows

 

 

왜 이 오류가 발생하나요



이 문제는 Dart 3.5.0에서 UnmodifiableUint8ListView 클래스가 더 이상 지원되지 않으면서 발생합니다. 프로젝트를 빌드할 때 이 클래스에 여전히 의존하는 패키지가 있을 경우 컴파일 오류가 발생합니다. 특히 윈도우 개발에 많이 사용되는 win32 패키지가 이 문제의 영향을 받았지만, 패키지가 곧바로 업데이트되어 문제가 해결되었습니다.



결론



만약 윈도우용 플러터 앱을 빌드하는 과정에서 Type 'UnmodifiableUint8ListView' not found 오류가 발생한다면, 이는 Dart 3.5.0 업데이트로 인한 의존성 문제일 가능성이 큽니다. 위의 방법을 따라 의존성을 업데이트하고 프로젝트를 재빌드하면 문제를 해결할 수 있습니다.

앞으로도 이러한 문제를 피하려면, 플러터나 Dart의 주요 업데이트 시 의존성 패키지들도 함께 최신 버전으로 유지하는 것이 중요합니다. 업데이트 시 릴리즈 노트를 꼼꼼히 확인하는 습관을 가지는 것이 좋습니다.

 

 

[Eng]

 

 Solution for Compilation Error During Flutter App Build for Windows: Type UnmodifiableUint8ListView Not Found

 

When compiling a Flutter app targeting multiple platforms, including Windows, you might encounter the error Type UnmodifiableUint8ListView not found. This issue commonly arises when the app compiles successfully for Android and iOS but fails during the Windows build. Below is a detailed guide to understanding and resolving this issue.

 

 Error Message Example

 

C/Users/YourUser/AppData/Local/Pub/Cache/hosted/pub.dev/win32-5.5.0/lib/src/guid.dart(32,9): error G7D2AEF3C: Type UnmodifiableUint8ListView not found. D/Projects/MyProject/myproject/build/windows/x64/flutter/flutter_assemble.vcxproj

C/Users/YourUser/AppData/Local/Pub/Cache/hosted/pub.dev/win32-5.5.0/lib/src/guid.dart(32,9): error G94EA939C: UnmodifiableUint8ListView isn't a type. D/Projects/MyProject/myproject/build/windows/x64/flutter/flutter_assemble.vcxproj

 

 

This error occurs because Dart 3.5.0 deprecated the UnmodifiableUint8ListView class, which may still be used by some dependencies in your project.

 

 Steps to Resolve the Issue

 

1. Check Dependency Updates: Ensure that all dependencies in your project, particularly those relying on the win32 package, are up to date.

 

2. Run flutter pub upgrade: Use this command to upgrade all project dependencies to their latest versions. Specifically, make sure that the win32 package is updated to version 5.5.1 or higher.

 

   

   flutter pub upgrade win32

 

 

3. Verify Dependency Versions: After upgrading, check the versions of your dependencies to ensure they are updated correctly. You can verify this by reviewing the pubspec.lock file or by running:

 

   

   flutter pub outdated

   

 

4. Rebuild the Project: After upgrading dependencies, clean and rebuild the project to ensure all updates are applied:

 

   

   flutter clean

   flutter pub get

   flutter build windows

   

 

 Understanding the Cause

 

This issue is triggered by the deprecation of the UnmodifiableUint8ListView class in Dart 3.5.0. If any packages in your project rely on this class, you will encounter compilation errors. The win32 package, widely used in Windows development, was affected by this change but has since been updated to resolve the issue.

 

 Conclusion

If you encounter the Type UnmodifiableUint8ListView not found error when building a Flutter app for Windows, it is likely due to dependency issues caused by the Dart 3.5.0 update. Following the steps outlined above to update your dependencies and rebuild the project should resolve the issue.

 

To avoid similar problems in the future, it's important to keep your dependencies up to date, especially after major updates to Flutter or Dart. Regularly reviewing release notes can also help you anticipate and mitigate potential issues.

 

 

> reference

https://github.com/jonataslaw/get_cli/issues/263

 

build issue in dart 3.5.0 - UnmodifiableUint8ListView · Issue #263 · jonataslaw/get_cli

Building package executables... (5.4s) Failed to build get_cli:get: ../../../.pub-cache/hosted/pub.dev/win32-5.3.0/lib/src/guid.dart:32:9: Error: Type 'UnmodifiableUint8ListView' not found. final U...

github.com

 

https://stackoverflow.com/questions/78669205/error-during-compilation-of-a-flutter-app-for-windows-type-unmodifiableuint8li

 

Error during compilation of a Flutter app for Windows: Type 'UnmodifiableUint8ListView' not found

I created a Flutter project, that targets Android, iOS, macOS, Linux and Windows. It works well on both Android and iOS, but when I try to compile it on Windows 10, I got the following error: /C:/U...

stackoverflow.com

 

반응형