PhizClip Flutter DEMO
本项目提供在 Flutter 环境中运行小程序的示例 DEMO
👉 https://www.phizclip.com/ 👈
[官方网站](https://www.finclip.com/) | [示例小程序](https://www.finclip.com/#/market) | [开发文档](https://www.finclip.com/mop/document/) | [部署指南](https://www.finclip.com/mop/document/introduce/quickStart/cloud-server-deployment-guide.html) | [SDK 集成指南](https://www.finclip.com/mop/document/introduce/quickStart/intergration-guide.html) | [API 列表](https://www.finclip.com/mop/document/develop/api/overview.html) | [组件列表](https://www.finclip.com/mop/document/develop/component/overview.html) | [隐私承诺](https://www.finclip.com/mop/document/operate/safety.html)
-----
## 🤔 PhizClip 是什么?
有没有**想过**,开发好的微信小程序能放在自己的 APP 里直接运行,只需要开发一次小程序,就能在不同的应用中打开它,是不是很不可思议?
有没有**试过**,在自己的 APP 中引入一个 SDK ,应用中不仅可以打开小程序,还能自定义小程序接口,修改小程序样式,是不是觉得更不可思议?
这就是 PhizClip ,就是有这么多不可思议!
## ⚙️ Flutter 集成
在项目 `pubspec.yaml` 文件中添加依赖
```yaml
mop: latest.version
```
## 🖥 示例
```flutter
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:io';
import 'package:mop/mop.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State {
@override
void initState() {
super.initState();
init();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future init() async {
if (Platform.isiOS) {
//com.PhizClip.mopExample
final res = await Mop.instance.initialize(
'22LyZEib0gLTQdU3MUauARlLry7JL/2fRpscC9kpGZQA', '1c11d7252c53e0b6',
apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop');
print(res);
} else if (Platform.isAndroid) {
//com.PhizClip.mopexample
final res = await Mop.instance.initialize(
'22LyZEib0gLTQdU3MUauARjmmp6QmYgjGb3uHueys1oA', '98c49f97a031b555',
apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop');
print(res);
}
if (!mounted) return;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('PhizClip Flutter 插件'),
),
body: Center(
child: Container(
padding: EdgeInsets.only(
top: 20,
),
child: Column(
children: [
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',sequence: 1);
},
child: Text(
'打开官方小程序',
style: TextStyle(color: Colors.white),
),
),
),
],
),
),
),
),
);
}
}
```
## 📘 目录结构
```
.
├── LICENSE
├── README.md
├── android 安卓工程目录
│ ├── app
│ │ ├── build.gradle 应用构建配置
│ │ └── src
│ │ ├── debug
│ │ │ └── AndroidManifest.xml 应用清单文件
│ │ ├── main 应用源码主目录
│ │ │ ├── AndroidManifest.xml 应用清单文件
│ │ │ ├── java 应用源码目录
│ │ │ │ ├── com
│ │ │ │ │ └── finogeeks
│ │ │ │ │ └── mop_demo
│ │ │ │ │ └── MainActivity.java
│ │ │ │ └── io
│ │ │ │ └── flutter
│ │ │ │ └── plugins
│ │ │ │ └── GeneratedPluginRegistrant.java
│ │ │ └── res 资源文件目录
│ │ │ ├── drawable darwable资源目录
│ │ │ │ └── launch_background.xml
│ │ │ ├── mipmap-hdpi 图片资源目录
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi 图片资源目录
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi 图片资源目录
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi 图片资源目录
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi 图片资源目录
│ │ │ │ └── ic_launcher.png
│ │ │ └── values
│ │ │ └── styles.xml
│ │ └── profile
│ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── gradle gradle版本配置目录,一般情况下无需关注
│ │ └── wrapper
│ │ └── gradle-wrapper.properties
│ ├── gradle.properties
│ ├── local.properties
│ └── settings.gradle
├── build
├── doc
│ └── mop_flutter_demo.gif
├── ios iOS工程目录
│ ├── Flutter Flutter-SDK目录,一般无需关注
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ ├── Flutter.framework
│ │ ├── Flutter.podspec
│ │ ├── Generated.xcconfig
│ │ ├── Release.xcconfig
│ │ └── flutter_export_environment.sh
│ ├── Podfile pod依赖配置文件
│ ├── Runner iOS源码主目录
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets 图片资源
│ │ │ ├── AppIcon.appiconset 图标
│ │ │ └── LaunchImage.imageset 启动图
│ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── FATFlutterViewController.h Flutter页面控制器子类
│ │ ├── FATFlutterViewController.m Flutter页面控制器子类
│ │ ├── GeneratedPluginRegistrant.h
│ │ ├── GeneratedPluginRegistrant.m
│ │ ├── Info.plist iOS工程配置文件
│ │ └── main.m
│ └── Runner.xcodeproj
├── lib Flutter源码主目录
│ ├── main.dart 首页
│ └── wx_pay.dart 微信支付源码
├── pubspec.lock
├── pubspec.yaml Flutter配置文件
└── test
└── widget_test.dart
```
## 📋 接口文档
### 1. 初始化小程序
在使用 SDK 提供的 API 之前必须要初始化 SDK ,初始化 SDK 的接口如下
```
///
/// initialize mop miniprogram engine.
/// 初始化小程序
/// [appkey] is required. it can be getted from api.phizclip.com
/// [secret] is required. it can be getted from api.phizclip.com
/// [apiServer] is optional. the mop server address. default is https://mp.finogeek.com
/// [apiPrefix] is optional. the mop server prefix. default is /api/v1/mop
///
///
Future