xinhuamm_xycloud 1.0.6 copy "xinhuamm_xycloud: ^1.0.6" to clipboard
xinhuamm_xycloud: ^1.0.6 copied to clipboard

outdated

新移云SDK插件

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:xinhuamm_xycloud/xinhuamm_xycloud.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _xinhuammXycloudPlugin = XinhuammXycloud();

  @override
  void initState() {
    super.initState();
    setCloudGlobalConfig();
    setCloudMethodCallHandler();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Expanded(
                child:  Container(
                  // width: 200,
                  // height: 200,
                  child:  UiKitView(
                    viewType: "XYCloudFlutterWebView",
                    creationParams: {"url": "https://yc.market.xinhuamm.net/statics/cloud-application-o2o-user-h5?nory=1"},
                    creationParamsCodec: JSONMessageCodec(),
                    onPlatformViewCreated: (viewId) {
                      print('View 创建完成; ViewId: $viewId');
                    },
                  ),
                ),
              )
              // Text('新移云SDK Flutter原生插件'),
              // Container(
              //   margin: EdgeInsets.all(6.0),
              //   child: ElevatedButton(
              //     onPressed: () {
              //       // 按钮被点击时的操作
              //       openCloudPage();
              //     },
              //     style: ElevatedButton.styleFrom(
              //       primary: Colors.blue, // 按钮的背景颜色
              //       onPrimary: Colors.white, // 文本颜色
              //       padding: EdgeInsets.fromLTRB(16.0, 10, 16, 10), // 内边距
              //       shape: RoundedRectangleBorder(
              //         borderRadius: BorderRadius.circular(8.0), // 圆角
              //       ),
              //     ),
              //     child: Text(
              //       '打开新移云页面', // 按钮文本
              //       style: TextStyle(
              //         fontSize: 18.0, // 字体大小
              //       ),
              //     ),
              //   ),
              // ),
            ],
          ),
        ),
      ),
    );
  }

  void openCloudPage() {
    _xinhuammXycloudPlugin.openCloudPage(
        "https://yc.market.xinhuamm.net/statics/cloud-application-o2o-user-h5?nory=1");
  }

  void setCloudGlobalConfig() {
    _xinhuammXycloudPlugin.setCloudGlobalConfig({
      "weixinSchemeUrl": "微信支付协议",
      "appUrlScheme": "支付宝支付协议",
      "userAgent": "xinhuamm",
      "themeColor": "#f38242",
      "showNavigationBar": false,
      "isDebug": true
    });
  }

  void setCloudMethodCallHandler() {
    _xinhuammXycloudPlugin.setCloudMethodCallHandler((call) {
      if ("login" == call.method) {
        // 打开登录页面
        print("打开登录页");
      } else if ("getLoginParam" == call.method) {
        // 获取免登接口请求参数。返回:json字符串
        /* {
        "userId":"用户标识",
        "userPhone":"用户手机号",
        "otherKey":"value",
        } */
        print("获取免登信息");
        // return Future.value({
        //   "userId": "用户标识",
        //   "userPhone": "用户手机号",
        //   "otherKey": "value",
        // });
      } else if ("share" == call.method) {
        // 调用分享功能,call中带有分享参数:
        /* {
        "title":"分享标题",
        "description":"分享摘要",
        "imageUrl":"分享图片",
        "url":"分享链接",
        } */
        String title = call.arguments['title'];
        String description = call.arguments['description'];
        String imageUrl = call.arguments['imageUrl'];
        String url = call.arguments['url'];
        print("分享");
      } else if ("openMini" == call.method) {
        // 打开微信小程序,call中带有小程序信息:code&path
        String code = call.arguments['code'];
        String path = call.arguments['path'];
        print("打开小程序");
      }
      return Future.value(null);
    });
  }
}
1
likes
0
points
13
downloads

Publisher

unverified uploader

Weekly Downloads

新移云SDK插件

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on xinhuamm_xycloud

Packages that implement xinhuamm_xycloud