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) {
|
2020-02-28 12:52:27 +08:00
|
|
|
//com.finogeeks.mopExample
|
2020-02-28 12:20:44 +08:00
|
|
|
final res = await Mop.instance.initialize(
|
|
|
|
'22LyZEib0gLTQdU3MUauARlLry7JL/2fRpscC9kpGZQA', '1c11d7252c53e0b6',
|
|
|
|
apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1/mop');
|
|
|
|
print(res);
|
|
|
|
} else if (Platform.isAndroid) {
|
2020-02-28 12:52:27 +08:00
|
|
|
//com.finogeeks.mopexample
|
2020-02-28 12:20:44 +08:00
|
|
|
final res = await Mop.instance.initialize(
|
|
|
|
'22LyZEib0gLTQdU3MUauARjmmp6QmYgjGb3uHueys1oA', '98c49f97a031b555',
|
|
|
|
apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1/mop');
|
|
|
|
print(res);
|
|
|
|
}
|
2020-02-27 17:21:45 +08:00
|
|
|
if (!mounted) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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(
|
|
|
|
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('5e3c147a188211000141e9b1');
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
'打开示例小程序',
|
|
|
|
style: TextStyle(color: Colors.white),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(height: 30),
|
|
|
|
Container(
|
|
|
|
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('5e4d123647edd60001055df1');
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
'打开官方小程序',
|
|
|
|
style: TextStyle(color: Colors.white),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2020-02-27 17:21:45 +08:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|