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

65 lines
1.9 KiB
Dart
Raw Normal View History

2020-02-27 17:21:45 +08:00
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
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();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
2020-02-27 22:59:31 +08:00
// String platformVersion;
// // Platform messages may fail, so we use a try/catch PlatformException.
// try {
// platformVersion = await Mop.instance.platformVersion;
// print(platformVersion);
// } on PlatformException {
// platformVersion = 'Failed to get platform version.';
// }
2020-02-27 17:21:45 +08:00
final res = await Mop.instance.initialize(
2020-02-27 22:59:31 +08:00
'22LyZEib0gLTQdU3MUauARjmmp6QmYgjGb3uHueys1oA', '98c49f97a031b555',
apiServer: 'https://mp.finogeeks.com', apiPrefix: '/api/v1/');
2020-02-27 17:21:45 +08:00
print(res);
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: FlatButton(
onPressed: () {
// appId: '5e3c147a188211000141e9b1',
// path: "/pages/index/index",
// query: "key1=value1&key2=value2",
// scene: "1001"
Mop.instance.openApplet('5e3c147a188211000141e9b1',
path: '/pages/index/index', query: 'key1=value1&key2=value2');
},
child: Text('打开小程序'),
)),
),
);
}
}