finpong_plus 0.1.0 finpong_plus: ^0.1.0 copied to clipboard
Finpong Plus Widget
import 'dart:convert';
import 'package:finpong_plus/finpong_plus.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
void main() {
runApp(const MaterialApp(
home: MyApp(),
));
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String sampleToken = 'oVhMyHYutPW1664VrK3kwYlIlvcQ0QFcW/wwsNmpNZOeTedb0xp3evWclII+mS3+FBPtgf8DCXe5Iv4lnrhnfWaVb6nJLnVYxMS7sBahJ/VMvyUUBPfKVVbWcHhS+97ofJam2Lllg1fgv7wdlGPCzDT5OihQ318gfNzYYj4Y5H2XBdn8/khbhGauCyYdN/iwRKU1tbkctb0vpDUm/FPAW0YYvMn35J/+3zr/D6+idGbbo3yZecqXV/sPmVZq8HWrEAISzwmvwnmdAVOsOG9B3EfrVV1u8m+1Prhgn3vt03jWG0gG3Z+8N/sR+ffHvBHZDpVJvV+ds0E3ATBI31BV3qOFSqDtEmw2fLjGNinWn0XIqr3gAsX6+UslLq6R9Hu+r8MHn1cZjL58YqwkzBYqaYHDAdoTvw7xfVLshqUjnqa7VhMrKsVHq+Zy6UzKocoHsz/f8QH1XoxU6N5UzJPCC+slifAPQOpnv76pOJtOtyMtUWght5ObXuUNXafYbtWf39TxO0Okz8ptJDdq2Jfvqw9GBXqvgre6C/ee61cwuBQ=';
String inputToken = 'oVhMyHYutPW1664VrK3kwYlIlvcQ0QFcW/wwsNmpNZOeTedb0xp3evWclII+mS3+FBPtgf8DCXe5Iv4lnrhnfSai3TsiCr3m3aJ99oqNKU/MjJqtSG5augMdZtYNJqj+KdryxXNKLxazP/8m7RVUgAdwlDAy9KlUlvtjtmdwNP9HQ94nLB22gMcuPqiq+MAYs/qutdoRBcxKlQbvpggz0dNVpaRulkWQsBr3Nb5ZAKecO52VHzrtiXzso0zTtvLRULEwbwyiCJY0B01+OentJqtP29PBCmJkMuzwo1JHNWp5Yy/b1Qo/FuGkGQzqSjVudl13U0MW3/6d/s3G65m7KIjGceT9QnmUNjW8I+bmY+OMAIP4qzW+I2lzsu2VTCiqSOVCXvg/G5kD1c7KWFv+HA7nIj4hy6dnNWcpJVb0VLH6b/eOn/0zz/Ij6L/Pvc71IFAK1j1qqu2zqlf8ZE4NKHXGstrACVHt1/zXCO3bLRvVnlEQlF5fUdpyoJWp9zXoa4+knX8r19rVE8j7Mgfd+Pg/njp5XKtHItaNwMVZgtofInc8ErXyDzMBbvk2WseN48hTvwCh6STM751hsK/pOg==';
FinpongPlusController finpongPlusController = FinpongPlusController();
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return SafeArea(
child: Container(
color: Colors.white,
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: const EdgeInsets.only(top: 100),
child: Card(
child: TextField(
onChanged: (text) {
setState(() {
inputToken = text;
});
},
decoration: const InputDecoration(
border: OutlineInputBorder(), labelText: 'token'),
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
child: Text('Dev'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => _finpongPlusWidget(
inputToken, ServerMode.dev)));
},
),
const SizedBox(
width: 10,
),
ElevatedButton(
child: Text('Stg'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => _finpongPlusWidget(
inputToken, ServerMode.staging)));
},
),
const SizedBox(
width: 10,
),
ElevatedButton(
child: Text('Release'),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => _finpongPlusWidget(
inputToken, ServerMode.release)));
},
),
],
),
],
),
),
);
}
Widget _finpongPlusWidget(String token, ServerMode serverMode) {
return SafeArea(
child: FinpongPlusWidget(
finpongPlusController: finpongPlusController,
token: token,
entry: '1',
serverMode: serverMode,
backgorundColor: Colors.white,
onUriScheme: (type, scheme) {
//사설 인증서 호출 (앱스킴 실행)
},
onCustomAction: (pageId, params) {
//사전 정의된 핀퐁플러스의 액션을 앱에서 처리를 위함
if (pageId == 'PA-001') {
var testData = {"data1": 1, "data2": true};
String jsonString = jsonEncode(testData);
finpongPlusController.runJavaScript('fileDataConnect', jsonString);
}
},
onCloseAction: () {
//핀퐁플러스 닫기
Navigator.pop(context);
},
onPageLoadStarted: () {
//핀퐁플러스 페이지 로드 시작
},
onPageLoadFinished: () {
//핀퐁플러스 페이지 로드 종료
},
),
);
}
}