티스토리 뷰
어이없는 문제로 몇시간을 날렸는지 모르겠다.
InAppWebview에서 onCreateWindow 를 이용해
또 다른 웹 팝업창을 여는 작업중
팝업 윈도우를 닫을때마다
바깥쪽 InAppWebview 에서
리다이렉션 현상이 일어나
로그인 등에서 문제를 겪었다.
기존의 코드를 보면
onCreateWindow: (controller, action) {
debugPrint("onCreateWindow");
return showDialog(
context: context,
barrierDismissible: true,
builder: (context) {
return Padding(
padding: const EdgeInsets.only(top: 30.0),
child: FractionallySizedBox(
heightFactor: 0.9,
child: InAppWebView(
windowId: action.windowId,
initialSettings: InAppWebViewSettings(
userAgent: 'random',
),
onCloseWindow: (controller) {
Navigator.pop(context);
},
),
),
);
},
);
},
Dialog 를 리턴하는 형식이었다.
onCreateWindow 를 타고 들어가보면
Future<bool?> Function(InAppWebViewController controller,
CreateWindowAction createWindowAction)?
onCreateWindow,
Future<bool?> 을 받는데
bool? 옵셔널한 값이고
수많은 예제들에서
웹뷰/인앱웹뷰 팝업을 열때
다이얼로그를 리턴하길래 되는줄 알았다.
실제로 팝업은 열리고
안드로이드에선 새로고침 현상이 발생하지 않는다.
iOS 에서만 팝업창 닫을때 바깥쪽 웹뷰에 새로고침 현상이 생긴다.
제대로 Future<bool> 타입을 리턴하면
iOS 에서도 새로고침 현상이 발생하지 않는다.
onCreateWindow: (controller, action) {
debugPrint("onCreateWindow");
showDialog(
context: context,
barrierDismissible: true,
builder: (context) {
return Padding(
padding: const EdgeInsets.only(top: 30.0),
child: FractionallySizedBox(
heightFactor: 0.9,
child: InAppWebView(
windowId: action.windowId,
initialSettings: InAppWebViewSettings(
userAgent: 'random',
),
onCloseWindow: (controller) {
Navigator.pop(context);
},
),
),
);
},
);
return Future.value(true);
}
Future.value(false) 로 바꾸면
기존의 기이한 현상이 벌어지는걸 보면
디폴트가 false 인것같다..
'Flutter' 카테고리의 다른 글
flutter 플러터 - 카카오톡으로 로그인 (1) | 2025.01.03 |
---|---|
플러터 StateNotifierProvider 개념 정리와 응용 (0) | 2024.08.08 |
Flutter 플러터 - willPopScope 대신 popScope 적용해보기 (1) | 2023.11.25 |