build method
Builds the TosspaymentsWebview widget and initializes the payment process.
Implementation
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: IndexedStack(
children: [
WebView(
initialUrl: Uri.dataFromString(TosspaymentsWebview.html,
mimeType: 'text/html',
encoding: Encoding.getByName('utf-8'))
.toString(),
javascriptMode: JavascriptMode.unrestricted,
javascriptChannels: <JavascriptChannel>{
JavascriptChannel(
name: "TosspaymentsReady",
onMessageReceived: (JavascriptMessage message) {
executeJS(_webViewController);
})
},
onWebViewCreated: (controller) {
_webViewController = controller;
},
navigationDelegate: (request) async {
// 웹뷰 화면 전환 시 실행
//원천사 인증 완료시
if (didSuccess(request.url)) {
return NavigationDecision.prevent;
}
if (didFail(request.url)) {
return NavigationDecision.prevent;
}
if (request.url.startsWith('intent')) {
return tossPaymentsWebview(request.url);
}
tossPaymentsWebview(request.url);
return NavigationDecision.navigate;
},
),
],
),
),
);
}