작성
·
1.6K
답변 2
1
이렇게 하니까 작동하는 것 같습니다!
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:webview_flutter/webview_flutter.dart';
class HomeScreen extends StatelessWidget {
WebViewController? controller;
HomeScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return WillPopScope(
child: SafeArea(
child: Scaffold(
body: WebView(
onWebViewCreated: (WebViewController controller){
this.controller = controller;
},
initialUrl: 'https://127.0.0.1',
javascriptMode: JavascriptMode.unrestricted,
),
),
),
onWillPop: () {
var future = controller!.canGoBack();
future.then((cnaGoBack) {
if (cnaGoBack) {
controller!.goBack();
} else {
SystemNavigator.pop();
}
});
return Future.value(false);
},
);
}
}
0