Skip to content

Instantly share code, notes, and snippets.

@doyle-flutter
Created February 25, 2021 06:26
Show Gist options
  • Save doyle-flutter/15f5d3ed7bf21efc1ab66bca2d7de1c1 to your computer and use it in GitHub Desktop.
Save doyle-flutter/15f5d3ed7bf21efc1ab66bca2d7de1c1 to your computer and use it in GitHub Desktop.
FastAPI + Flutter
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart'; // ^1.0.7
void main() => runApp(MaterialApp(home: MyApp(),));
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("카카오 결제")),
body: Center(
child: MaterialButton(
color: Colors.blue,
textColor: Colors.white,
child: Text("카카오 페이 결제"),
onPressed: () async{
const String url = "http://127.0.0.1:8000/kakaopayf";
return await Navigator.of(context).push<void>(
MaterialPageRoute(
builder: (BuildContext context) => Scaffold(
appBar: AppBar(title: Text("카카오 결제 ing")),
body: WebView(
initialUrl: url,
javascriptMode: JavascriptMode.unrestricted,
javascriptChannels: {
JavascriptChannel(
name: "james",
onMessageReceived: (JavascriptMessage jm){
print(jm.message.toString());
if( jm.message.toString() != null){
return Navigator.of(context).pop<void>();
}
}
)
},
),
)
)
);
},
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment