PhizClip Flutter DEMO

๐Ÿ‘‰ https://www.phizclip.com/ ๐Ÿ‘ˆ

[Home Page](https://www.finclip.com/) | [Example Mini-App](https://www.finclip.com/#/market) | [Documentation](https://www.finclip.com/mop/document/) | [Deployment Guide](https://www.finclip.com/mop/document/introduce/quickStart/cloud-server-deployment-guide.html)
[SDK Integration Guide](https://www.finclip.com/mop/document/introduce/quickStart/intergration-guide.html) | [API List](https://www.finclip.com/mop/document/develop/api/overview.html) | [Component List](https://www.finclip.com/mop/document/develop/component/overview.html) | [Privacy Commitment](https://www.finclip.com/mop/document/operate/safety.html)
----- ## ๐Ÿค” What is PhizClip? Have you ever **thought** that the developed WeChat Mini-App can be put in your own APP to run directly, and you only need to develop the Mini-App once, and then you can open it in different applications, isn't it incredible? Have you ever **tried** to introduce an SDK in your own APP, and you can not only open the Mini-App in the app, but also customize the Mini-App interface and modify the Mini-App style, don't you think it is more incredible? **This is PhizClip, with much INCREDIBLE !** ## โš™๏ธ Flutter integration In the project `pubspec.yaml` add a dependency to the file ```yaml mop: latest.version ``` ## ๐Ÿ–ฅ Example ```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 plug-in'), ), 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( 'Open the sample applet', 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( 'Open the official applet', style: TextStyle(color: Colors.white), ), ), ), ], ), ), ), ), ); } } ``` ## ๐Ÿ“˜ Directory structure ``` . โ”œโ”€โ”€ LICENSE โ”œโ”€โ”€ README.md โ”œโ”€โ”€ android Android project directory โ”‚ย ย  โ”œโ”€โ”€ app โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ build.gradle Application build configuration โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ src โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ debug โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ AndroidManifest.xml Application manifest file โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ main Application source directory โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ AndroidManifest.xml Application manifest file โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ java Application source directory โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ com โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ finogeeks โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ mop_demo โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ MainActivity.java โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ io โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ flutter โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ plugins โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ GeneratedPluginRegistrant.java โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ res Resource file directory โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ drawable darwable Resource directory โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ launch_background.xml โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ mipmap-hdpi Picture resource directory โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ic_launcher.png โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ mipmap-mdpi Picture resource directory โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ic_launcher.png โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ mipmap-xhdpi Picture resource directory โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ic_launcher.png โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ mipmap-xxhdpi Picture resource directory โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ic_launcher.png โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ mipmap-xxxhdpi Picture resource directory โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ic_launcher.png โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ values โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ styles.xml โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ profile โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ AndroidManifest.xml โ”‚ย ย  โ”œโ”€โ”€ build.gradle โ”‚ย ย  โ”œโ”€โ”€ gradle gradle version configuration directory, which is generally not required โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ wrapper โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ gradle-wrapper.properties โ”‚ย ย  โ”œโ”€โ”€ gradle.properties โ”‚ย ย  โ”œโ”€โ”€ local.properties โ”‚ย ย  โ””โ”€โ”€ settings.gradle โ”œโ”€โ”€ build โ”œโ”€โ”€ doc โ”‚ย ย  โ””โ”€โ”€ mop_flutter_demo.gif โ”œโ”€โ”€ ios iOS Project Directory โ”‚ย ย  โ”œโ”€โ”€ Flutter Flutter-SDK directory, generally no concern โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ AppFrameworkInfo.plist โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Debug.xcconfig โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Flutter.framework โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Flutter.podspec โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Generated.xcconfig โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Release.xcconfig โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ flutter_export_environment.sh โ”‚ย ย  โ”œโ”€โ”€ Podfile pod dependency configuration file โ”‚ย ย  โ”œโ”€โ”€ Runner iOS source home directory โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ AppDelegate.h โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ AppDelegate.m โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Assets.xcassets Picture resource โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ AppIcon.appiconset Icon โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ LaunchImage.imageset Start-up diagram โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Base.lproj โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ LaunchScreen.storyboard โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ Main.storyboard โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ FATFlutterViewController.h Flutter page controller subclass โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ FATFlutterViewController.m Flutter page controller subclass โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ GeneratedPluginRegistrant.h โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ GeneratedPluginRegistrant.m โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Info.plist iOS project profile โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ main.m โ”‚ย ย  โ””โ”€โ”€ Runner.xcodeproj โ”œโ”€โ”€ lib Flutter source directory โ”‚ย ย  โ”œโ”€โ”€ main.dart Home page โ”‚ย ย  โ””โ”€โ”€ wx_pay.dart Wechat Pay source code โ”œโ”€โ”€ pubspec.lock โ”œโ”€โ”€ pubspec.yaml Flutter profile โ””โ”€โ”€ test โ””โ”€โ”€ widget_test.dart ``` ## ๐Ÿ“‹ Interface document ### 1. Initialize the applet The SDK must be initialized before using the apis provided by the SDK. The interfaces for initializing the SDK are as follows ``` /// /// initialize mop miniprogram engine. /// Initialize the applet /// [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 initialize(String appkey, String secret, {String apiServer, String apiPrefix}) ``` Example of use: ``` final res = await Mop.instance.initialize( '22LyZEib0gLTQdU3MUauARlLry7JL/2fRpscC9kpGZQA', '1c11d7252c53e0b6', apiServer: 'https://api.finclip.com', apiPrefix: '/api/v1/mop'); ``` ### 2. Open applet ``` /// /// open the miniprogram [appId] from the mop server. /// Open applet /// [appId] is required. /// [path] is miniprogram open path. example /pages/index/index /// [query] is miniprogram query parameters. example key1=value1&key2=value2 /// /// Future openApplet(final String appId, {final String path, final String query, final int sequence}) ``` ### 3. Gets information about the applet currently in use The current applet information includes fields such as `appId`, `name`, `icon`, `description`, `version`, `thumbnail` ``` /// /// get current using applet /// Gets information about the applet currently in use /// {appId,name,icon,description,version,thumbnail} /// /// Future> currentApplet() ``` ### 4. Close all currently open applets ``` /// /// close all running applets /// Close all currently open applets /// Future closeAllApplets() ``` ### 5. A small program to clear the cache The small program that clears the cache will be downloaded again when it is opened again ``` /// /// clear applets cache /// A small program to clear the cache /// Future clearApplets() ``` ### 6. Register applet event handlers When a specified event is triggered within the applet, the user is notified, such as the applet is forwarded, the applet needs to obtain user information and register the processor to make a corresponding response ``` /// /// register handler to provide custom info or behaviour /// Register applet event handlers /// void registerAppletHandler(AppletHandler handler) ``` Processor architecture ``` abstract class AppletHandler { /// /// Forwarding applet /// /// /// void forwardApplet(Map appletInfo); /// /// Get user information /// "userId" /// "nickName" /// "avatarUrl" /// "jwt" /// "accessToken" /// Future> getUserInfo(); /// Get the custom menu Future> getCustomMenus(String appId); /// Custom menu click Processing Future onCustomMenuClick(String appId, int menuId); } ``` ### 7. Register extension API If our small program SDK API does not meet your needs, you can register a custom small program API, and then you can call your own defined API within the small program. ``` /// /// register extension api /// Register extension api /// void registerExtensionApi(String name, ExtensionApiHandler handler) ``` iOS needs to create the `FinChatConf.js` file in the root directory of the applet. The configuration example is as follows ``` module.exports = { extApi:[ { //Common interaction API name: 'onCustomEvent', // Extension api name This api must be implemented by the Native party params: { // Extend the parameter format of the api to include only the required attributes url: '' } } ] } ``` ## ๐Ÿ“˜ Directory structure ``` . โ”œโ”€.github โ”‚ โ”œโ”€.vscode โ”‚ โ”œโ”€android Project Android source code โ”‚ โ”œโ”€ios Engineering iOS source code โ”‚ โ”œโ”€lib Project Flutter source code โ”‚ โ”‚ โ”‚ โ”œโ”€ main.dart Program entry, and each initialization, call examples โ”‚ โ”‚ โ”‚ โ””โ”€ wx_pay.dart Wechat Payment class example โ”‚ โ”œโ”€test Test directory, no concern โ”‚ โ””โ”€pubspec.yaml Flutter project configuration items ``` ## ๐Ÿ”— Links The following is information on common questions and guidelines for your development and experience with PhizClip - [Home Page](https://www.finclip.com/#/home) - [Example Mini-App](https://www.finclip.com/#/market) - [Documentation](https://www.finclip.com/mop/document/) - [SDK Integration Guide](https://www.finclip.com/mop/document/introduce/quickStart/intergration-guide.html) - [Structure of PhizClip](https://www.finclip.com/mop/document/develop/guide/structure.html) - [Integration Guidelines(iOS)](https://www.finclip.com/mop/document/runtime-sdk/ios/ios-integrate.html) - [Integration Guidelines(Android)](https://www.finclip.com/mop/document/runtime-sdk/android/android-integrate.html) - [Integration Guidelines(Flutter)](https://www.finclip.com/mop/document/runtime-sdk/flutter/flutter-integrate.html) ## โ˜Ž๏ธ Contact Scan the QR code below with WeChat and follow the official public number **Finogeeks** for more exciting content.
Scan the QR code below with WeChat and invite into the official WeChat exchange group (add friend note: **finclip consulting**) to get more exciting content.
## Stargazers [![Stargazers repo roster for @finogeeks/finclip-flutter-demo](https://reporoster.com/stars/finogeeks/finclip-flutter-demo)](https://github.com/finogeeks/finclip-flutter-demo/stargazers) ## Forkers [![Forkers repo roster for @finogeeks/finclip-flutter-demo](https://reporoster.com/forks/finogeeks/finclip-flutter-demo)](https://github.com/finogeeks/finclip-flutter-demo/network/members) ## ๐ŸŒ Languages - [็ฎ€ไฝ“ไธญๆ–‡](./README.md) - [English](./readme_en.md) - [Portuguรชs](./readme_pt.md)