Ainda não tem acesso? Estude com a gente! Matricule-se
Ainda não tem acesso? Estude com a gente! Matricule-se

Erro ao executar flutter run

Quando executo o flutter run, ocorre o erro abaixo:

Using hardware rendering with device AOSP on IA Emulator. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
lib/main.dart:31:19: Error: The parameter 'key' can't have a value of 'null' because of its type 'Key', but the implicit default value is 'null'.
 - 'Key' is from 'package:flutter/src/foundation/key.dart' ('/C:/Tools/flutter/packages/flutter/lib/src/foundation/key.dart').
Try adding either an explicit non-'null' default value or the 'required' modifier.
  MyHomePage({Key key, this.title}) : super(key: key);
                  ^^^
lib/main.dart:31:29: Error: The parameter 'title' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.
  MyHomePage({Key key, this.title}) : super(key: key);
                            ^^^^^


FAILURE: Build failed with an exception.

* Where:
Script 'C:\Tools\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Tools\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 14s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        15,3s
Exception: Gradle task assembleDebug failed with exit code 1
3 respostas

Olá Viviane, tudo bem?

Viviane, isso provavelmente está acontecendo porque o this.title retorna um valor nula onde espera um chave ou String. Vou te passar dois links: https://stackoverflow.com/questions/64560461/the-parameter-cant-have-a-value-of-null-because-of-its-type-in-dart https://stackoverflow.com/questions/61219993/the-parameter-key-cant-have-a-value-of-null-because-of-its-type-after-enabling

Veja se um desses exemplo é condizente com o seu caso e corrija da maneira que achar melhor.

Também estou tendo erro ao executar o RUN.

FAILURE: Build failed with an exception.

  • What went wrong:A problem occurred configuring root project 'android'.

    Could not resolve all dependencies for configuration ':classpath'.Could not create service of type OutputFilesRepository using ExecutionGradleServices.createOutputFilesRepository(). Timeout waiting to lock Build Output Cleanup Cache (/Volumes/Externo/CURSOS_ALURA/FLUTTER/bytebank/android/.gradle/buildOutputCleanup). It is currently in use by another Gradle instance.

      Owner PID: unknown                                              
      Our PID: 55699                                                  
      Owner Operation: unknown                                        
      Our operation:                                                  
      Lock file: /Volumes/Externo/CURSOS_ALURA/FLUTTER/bytebank/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
  • Try:Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1m 7sRunning Gradle task 'assembleDebug'...Running Gradle task 'assembleDebug'... Done 70,2s Exception: Gradle task assembleDebug failed with exit code 1

Agora o emulador não está rodando, está abrindo o projeto BYTEBANK, porém no chrome, e não no emulador! O erro anterior, me parece que havia uma instancia rodando em background.

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