반응형
- 예시 코드
import 'package:flutter/material.dart';
class ExamplePage extends StatefulWidget {
const ExamplePage({Key? key}) : super(key: key);
@override
State<ExamplePage> createState() => _ExamplePageState();
}
class _ExamplePageState extends State<ExamplePage> with WidgetsBindingObserver {
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
switch (state) {
case AppLifecycleState.resumed:
print("앱이 표시되고 사용자 입력에 응답합니다");
break;
case AppLifecycleState.inactive:
print("앱이 비활성화 상태이고 사용자의 입력을 받지 않습니다");
break;
case AppLifecycleState.detached:
print("모든 뷰가 제거되고 플러터 엔진만 동작 중이며 앱이 종료되기 직전에 실행됩니다");
break;
case AppLifecycleState.paused:
print("앱이 현재 사용자에게 보이지 않고, 사용자의 입력을 받지 않으며, 백그라운드에서 동작 중입니다");
break;
}
}
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose() {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
}
Widget build(BuildContext context) {
return Scaffold();
}
}
반응형
'개발 > Flutter' 카테고리의 다른 글
Flutter 플러터 URL 주소 열기 간단 구현 url launcher (0) | 2022.12.25 |
---|---|
Flutter 플러터 화면 전환 애니메이션 삭제 간단 사용법 Navigator Animation (0) | 2022.12.25 |
Flutter 플러터 백 버튼 무시하기 WillPopScope (0) | 2022.12.25 |
Flutter 플러터 랜덤 숫자 간단 사용법 Random (0) | 2022.12.24 |
Flutter 플러터 진동 간단 사용법 vibration (0) | 2022.12.24 |
Flutter 플러터 설정 화면 UI 간단 구현 setting ui (0) | 2022.12.24 |
Flutter 플러터 다이얼로그 Dialog 대화 상자 간단 사용법 (0) | 2022.12.24 |
Flutter 플러터 스낵바 SnackBar 간단 사용법 (0) | 2022.12.24 |
댓글