提交 11160bf2 authored 作者: JarvanMo's avatar JarvanMo

lauch mini program demo

上级 abf207a4
import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart' as fluwx;
class LaunchMiniProgramPage extends StatefulWidget {
@override
_LaunchMiniProgramPageState createState() => _LaunchMiniProgramPageState();
}
class _LaunchMiniProgramPageState extends State<LaunchMiniProgramPage> {
String _result = "无";
@override
void initState() {
super.initState();
fluwx.responseFromLaunchMiniProgram.listen((data) {
setState(() {
_result = "${data.extMsg}";
});
});
}
@override
void dispose() {
super.dispose();
_result = null;
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Launch MiniProgrom"),
),
body: Column(
children: <Widget>[
OutlineButton(
onPressed: () {
fluwx.launchMiniProgram(
username: "gh_d43f693ca31f"
).then((data) {
print(data);
});
},
child: const Text("Launch MiniProgrom"),
),
const Text("响应结果;"),
Text(_result)
],
),
);
}
}
......@@ -11,7 +11,7 @@ import 'share_music.dart';
import 'share_text_image.dart';
import 'share_video_page.dart';
import 'share_web_page.dart';
import 'package:fluwx_example/launch_mini_program_page.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
......@@ -43,6 +43,7 @@ class _MyAppState extends State<MyApp> {
"sendAuth": (context) => SendAuthPage(),
"shareMiniProgram": (context) => ShareMiniProgramPage(),
"pay": (context) => PayPage(),
"launchMiniProgram": (context) => LaunchMiniProgramPage()
},
home: new Scaffold(
appBar: new AppBar(
......@@ -123,6 +124,14 @@ class ShareSelectorPage extends StatelessWidget {
},
child: const Text("pay")),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new OutlineButton(
onPressed: () {
Navigator.of(context).pushNamed("launchMiniProgram");
},
child: const Text("Launch MiniProgram")),
),
],
),
);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论