2
respostas

Não consigo rodar dart run build_runner build

Note: Já rodei flutter clean e flutter pub get

Quando eu rodo tanto o dart run build_runner build ou flutter pub run build_runner build aparece esse erro abaixo:

Failed to build build_runner:build_runner: ../../AppData/Local/Pub/Cache/hosted/pub.dev/watcher-1.0.1/lib/src/constructable_file_system_event.dart:7:57: Error: The class 'FileSystemEvent' can't be extended, implemented, or mixed in outside of its library because it's a s ealed class. abstract class _ConstructableFileSystemEvent implements FileSystemEvent { ^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/file-6.1.2/lib/src/interface/file.dart:15:16: Error: The method 'File.create' has fewer named arguments than those of overridden method 'File.create'. Future create({bool recursive = false}); ^ ../../Flutter/flutter%203.10.6/bin/cache/dart-sdk/lib/io/file.dart:232:16: Context: This is the overridden method ('create'). Future create({bool recursive = false, bool exclusive = false}); ^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/file-6.1.2/lib/src/interface/file.dart:15:16: Error: The method 'File.create' doesn't have the named parameter 'exclusive' of overridden method 'File.create'. Future create({bool recursive = false}); ^ ../../Flutter/flutter%203.10.6/bin/cache/dart-sdk/lib/io/file.dart:232:16: Context: This is the overridden method ('create'). Future create({bool recursive = false, bool exclusive = false}); ^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/file-6.1.2/lib/src/forwarding/forwarding_file.dart:22:8: Error: The method 'ForwardingFile.createSync' has fewer named arguments than those of overridden method 'File.createSync'. void createSync({bool recursive = false}) => ^ ../../Flutter/flutter%203.10.6/bin/cache/dart-sdk/lib/io/file.dart:248:8: Context: This is the overridden method ('createSync'). void createSync({bool recursive = false, bool exclusive = false}); ^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/file-6.1.2/lib/src/forwarding/forwarding_file.dart:22:8: Error: The method 'ForwardingFile.createSync' doesn't have the named parameter 'exclusive' of overridden method 'File.createSy nc'. void createSync({bool recursive = false}) => ^ ../../Flutter/flutter%203.10.6/bin/cache/dart-sdk/lib/io/file.dart:248:8: Context: This is the overridden method ('createSync'). void createSync({bool recursive = false, bool exclusive = false}); ^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/file-6.1.2/lib/src/backends/memory/memory_file.dart:57:8: Error: The method 'MemoryFile.createSync' has fewer named arguments than those of overridden method 'File.createSync'. void createSync({bool recursive = false}) { ^ ../../Flutter/flutter%203.10.6/bin/cache/dart-sdk/lib/io/file.dart:248:8: Context: This is the overridden method ('createSync'). void createSync({bool recursive = false, bool exclusive = false}); ^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/file-6.1.2/lib/src/backends/memory/memory_file.dart:57:8: Error: The method 'MemoryFile.createSync' doesn't have the named parameter 'exclusive' of overridden method 'File.createSync' . void createSync({bool recursive = false}) { ^ ../../Flutter/flutter%203.10.6/bin/cache/dart-sdk/lib/io/file.dart:248:8: Context: This is the overridden method ('createSync'). void createSync({bool recursive = false, bool exclusive = false}); ^ ../../AppData/Local/Pub/Cache/hosted/pub.dev/pub_semver-2.1.1/lib/src/version_constraint.dart:96:13: Error: Method not found: 'FallThroughError'. throw FallThroughError(); ^^^^^^^^^^^^^^^^

2 respostas

Consegui solucionar, mas não tenho certeza oque foi feito e gostaria que explicassem:

Digitei no prompt do projeto: flutter pub upgrade --major-versions flutter pub get

Referência: https://sulthanalihsan.medium.com/failed-to-build-build-runner-method-not-found-fallthrougherror-pub-semver-a21f5dcdb7ad

Olá, Lúcio! Tudo bem com você?

Fico feliz que tenha conseguido resolver o seu problema e que tenha compartilhado a sua solução aqui no fórum. Tenho certeza que ajudará outros alunos que tiverem o mesmo problema que você. Continue assim!

Agora, como funciona a resolução que você usou: o pacote build_runner aparentemente está em uma versão incompatível com a versão do Flutter e/ou do Dart que você estava utilizando.

Então, com o comando flutter pub upgrade --major-versions será feita a atualização das dependências do seu projeto Flutter, sendo o build_runner uma delas. E com o comando flutter pub get é usado para obter (baixar) as dependências especificadas no arquivo "pubspec.yaml".

Espero ter esclarecido a sua dúvida e bons estudos!

Caso este post tenha lhe ajudado, por favor, marcar como solucionado ✓.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software