Flutter에서 initState와 super.initState는 무엇인가요?
같은 것을 탐구합시다.
Flutter에서 initState와 super.initState는 무엇인가요?
initState()는 위젯 트리에 Stateful Widget이 삽입될 때 한 번 호출되는 메서드입니다. build()와 달리 이 메서드는 한 번만 호출되기 때문에 수신기 등록과 같은 초기화 작업이 필요한 경우 일반적으로 이 메서드를 재정의합니다.
initState() 사용:
initState()는 State 클래스의 메서드이며 Flutter에서 중요한 수명 주기 메서드로 간주됩니다. initState()는 한 번만 호출되며 일회성 초기화에 사용합니다.
예시:
initState()는 한 번만 호출됩니다. 또한 super.initState()를 호출해야 합니다.
이 @override 방법은 다음을 수행하는 가장 좋은 시간입니다.
@override
initState() {
  super.initState();
 // Add listeners to this class
}
예시:
class InitExample extends StatefulWidget {
  const InitExample({Key? key}) : super(key: key);
  @override
  State createState() => _InitExampleState();
}
class _InitExampleState extends State {
  @override
  void initState() {
    super.initState();
    print("initState() called");
  }
  @override
  void dispose() {
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("InitState Example"),
      ),
      body: const Center(
        child: Text("Welcome Flutter"),
      ),
    );
  }
}
산출:
initState() 호출

결론:
읽어 주셔서 감사합니다 !!!
이 기사에서는 Flutter에서 initState() 및 super.initState()가 무엇인지 살펴보았습니다.
계속 배우도록 !!! 계속 설레발!!!
FlutterAgency.com은 Flutter 기술 및 Flutter 개발자 전용 포털 플랫폼입니다. 포털에는 Flutter 위젯 가이드, Flutter 프로젝트, 코드 라이브러리 등과 같은 Flutter의 멋진 리소스가 가득합니다.
Reference
이 문제에 관하여(Flutter에서 initState와 super.initState는 무엇인가요?), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/pankajdas0909/what-is-initstate-and-superinitstate-in-flutter-57ke텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)