onechuan_plugin 0.2.9 onechuan_plugin: ^0.2.9 copied to clipboard
A new Flutter plugin.
import 'dart:convert';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:onechuan_plugin/onechuan_plugin.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
@override
void initState() {
super.initState();
// initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// 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;
setState(() {
_platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child:
GestureDetector(
onTap: () async{
try {
Map<String,String> map = Map();
map["title"]="会员权益";
// map ["url"] ="http://oagent.onechuan.com/#/page/membership?token=3ad0556a-7ba8-4cc7-a2ed-bdbce9cb10e5";
map ["url"] ="http://oagent.onechuan.com/#/page/membership?token=acebc124-e794-434d-9cbc-82aa6556497d";
print("url===>${map ["url"] }");
// map ["url"] ="http://www.baidu.com";
await OnechuanPlugin.openWebView(jsonEncode(map));
} on Exception {
print("出错了......");
}
},
behavior: HitTestBehavior.opaque,
child: Container(width: 100,height: 100,
color: Colors.red,
child: Text("点击触发"),
),
)
),
),
);
}
}