Why flutter application does not display a dialog box?

here is the code

void main() {
  // Обернем запуск приложения в try-catch для обработки ошибок
  try {
    _showMessage("Запуск приложения...");

    // Запуск приложения
    runApp(const MyApp());
    
    _showMessage("Приложение успешно запущено.");
  }

I expect that dialog boxes will be displayed, but they are not displayed. I assembled the project for Windows. I also downloaded the dll required by the application from github actions, but the application does not display anything, neither an error nor a dialog box. Why. What is the problem?

Without knowing what is the implementation of _showMessage we won’t be able to help you

2 Likes

This is because you’re trying to show a popup upon main initialization. No material app has been mounted yet, so no context exists to show your dialog yet.

Move your code into init-state and Add a addPostFrameCallback

1 Like