
플러터의 상태 관리 패키지인 Provider에서 제공하는 ChangeNotifierProvider와 Navgator로 화면 이동한 후에 상태 변화를 확인하기 위해 예제 코드를 만들어 보았다. 다음 이미지처럼 FirstPage에서 SecondPage로 이동하고, SecondPage에서 상태를 변화시켜도 FirstPage에 구독한 상태가 잘 변경되는 것을 확인할 수 있다. FirstPage와 SecondPage가 StatelessWidget인 것을 주목하자. ChangeNotifierProvider로 상태가 공유되기 때문에 상태 변화시 자동으로 위젯이 리빌드 되기 때문에 StatefulWidget처럼 작동하게 된다. import 'package:flutter/material.dart'; import 'pac..

플러터에서 게비게이터(navigator)로 화면을 이동하는 코드를 작성하고 실행하였는데, 아래와 같은 에러가 발생했다. The following assertion was thrown while handling a gesture: Navigator operation requested with a context that does not include a Navigator. The context used to push or pop routes from the Navigator must be that of a widget that is a descendant of a Navigator widget. 에러 내용을 해석하면, '네비게이터에서 이동하려면 사용되는 콘텍스트(context)는 네비게이터 위젯의 하위 위젯..