mop-flutter-sdk/example/lib/main.dart

125 lines
4.1 KiB
Dart
Raw Normal View History

2020-02-27 17:21:45 +08:00
import 'package:flutter/material.dart';
import 'dart:async';
2020-02-28 12:20:44 +08:00
import 'dart:io';
2020-02-27 17:21:45 +08:00
import 'package:mop/mop.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
2020-02-28 12:20:44 +08:00
init();
2020-02-27 17:21:45 +08:00
}
// Platform messages are asynchronous, so we initialize in an async method.
2020-02-28 12:20:44 +08:00
Future<void> init() async {
if (Platform.isIOS) {
final res = await Mop.instance.initialize(
2020-10-27 16:31:29 +08:00
'22LyZEib0gLTQdU3MUauATaGrbb4xsJ87TEDJExdNRsA', 'c7a85a043973223b',
2020-02-28 12:20:44 +08:00
apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1/mop');
print(res);
} else if (Platform.isAndroid) {
final res = await Mop.instance.initialize(
2020-10-27 16:31:29 +08:00
'22LyZEib0gLTQdU3MUauATaGrbb4xsJ87TEDJExdNRsA', 'c7a85a043973223b',
2020-02-28 12:20:44 +08:00
apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1/mop');
print(res);
}
2020-02-27 17:21:45 +08:00
if (!mounted) return;
}
2020-04-22 21:51:50 +08:00
// 5e637a18cbfae4000170fa7a
2020-02-27 17:21:45 +08:00
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
2020-02-28 12:20:44 +08:00
title: const Text('凡泰极客小程序 Flutter 插件'),
2020-02-27 17:21:45 +08:00
),
body: Center(
2020-02-28 12:20:44 +08:00
child: Container(
padding: EdgeInsets.only(
top: 20,
),
child: Column(
children: <Widget>[
Container(
2020-04-22 21:51:50 +08:00
width: 140,
2020-02-28 12:20:44 +08:00
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
gradient: LinearGradient(
colors: const [Color(0xFF12767e), Color(0xFF0dabb8)],
stops: const [0.0, 1.0],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: FlatButton(
onPressed: () {
2020-04-22 21:51:50 +08:00
Mop.instance.openApplet('5ea03fa563cb900001d73863',
path: 'pages/index/index', query: '');
2020-02-28 12:20:44 +08:00
},
child: Text(
2020-04-22 21:51:50 +08:00
'打开画图小程序',
2020-02-28 12:20:44 +08:00
style: TextStyle(color: Colors.white),
),
),
),
SizedBox(height: 30),
Container(
2020-04-22 21:51:50 +08:00
width: 140,
2020-02-28 12:20:44 +08:00
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
gradient: LinearGradient(
colors: const [Color(0xFF12767e), Color(0xFF0dabb8)],
stops: const [0.0, 1.0],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: FlatButton(
onPressed: () {
2020-04-22 21:51:50 +08:00
Mop.instance.openApplet('5ea0401463cb900001d73865');
2020-02-28 12:20:44 +08:00
},
child: Text(
'打开官方小程序',
style: TextStyle(color: Colors.white),
),
),
),
2020-04-22 21:51:50 +08:00
SizedBox(height: 30),
Container(
width: 140,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
gradient: LinearGradient(
colors: const [Color(0xFF12767e), Color(0xFF0dabb8)],
stops: const [0.0, 1.0],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
),
child: FlatButton(
onPressed: () {
Mop.instance.openApplet('5ea0412663cb900001d73867');
},
child: Text(
'我的对账单',
style: TextStyle(color: Colors.white),
),
),
),
2020-02-28 12:20:44 +08:00
],
),
),
),
2020-02-27 17:21:45 +08:00
),
);
}
}