(Flutter) 특정 기간 동안 새 페이지 푸시(마운트 사용)

//push
Navigator.of(context).push(
    MaterialPageRoute(
      builder: (context) {
        return Scaffold(
          backgroundColor: Theme.of(context).backgroundColor,
          body: const Center(
            child: Text(
              'Break Time!',
              ),
            ),
          ),
        );
      },
    ),
  );
  
  //duration
  await Future.delayed(const Duration(seconds: 3));
  
  // pop!!
  if (mounted) Navigator.of(context).pop();

탑재현재 트리에 상태 객체가 있는지 여부를 부울 값으로 나타냅니다. async-await에 컨텍스트를 사용하고 지연을 적용하면 비동기 특성으로 인해 dispose가 발생할 수 있으며 상태 객체가 컨텍스트(트리)에 더 이상 남아 있지 않을 수 있기 때문입니다. 또한 async 이후에 context를 사용하는 것은 피해야 한다고 합니다.

마운트를 사용하지 않을 때 비동기 간격에서 빌드 컨텍스트를 사용하지 마십시오. 오류가 발생했습니다.

(참조)

https://stackoverflow.com/questions/68871880/do-not-use-buildcontexts-across-async-gaps

https://stackoverflow.com/questions/65234864/flutter-dart-what-is-mounted-for