wxx_plugin 0.0.2 wxx_plugin: ^0.0.2 copied to clipboard
A new Flutter plugin.
import 'dart:io';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
//import 'package:wxx_plugin/wxx_plugin.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
var bytes = [];
var _platformVersion = 'Unknown';
var data = ByteData(0);
Image myImgV = Image.file(new File("/Users/wzswang/Library/Developer/CoreSimulator/Devices/AD43C312-1098-4939-998D-530372343220/data/Containers/Data/Application/E2164D76-B06D-4507-BE91-141D84AF518D/tmp/97426550-B9EE-49AF-8492-06BE807DDE9E.jpeg",));
// String imagePath = "file:///users/wzswang/Library/Developer/CoreSimulator/Devices/AD43C312-1098-4939-998D-530372343220/data/Containers/Data/Application/B62ED4BD-8C82-43F4-BF49-B7E850C91CA5/tmp/797D38FC-7329-4477-BF55-2B4AA9491AB4.jpeg";
// String imagePath = "https://pics7.baidu.com/feed/aa64034f78f0f736ef4432c65211a71ceac41303.jpeg?token=c18d3f1446db80d9b3074f1c990ba7db&s=F2BB31C4448AB15754DA54820300E098";
@override
void initState() {
super.initState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
print(_platformVersion + "oooooooo1");
var platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
print(_platformVersion + "oooooooo2");
platformVersion = await WxxPlugin.platformVersion;
print(_platformVersion + "oooooooo3");
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// 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.
print(_platformVersion + "oooooooo4");
if (!mounted) return;
setState(() {
// myImgV = Image.memory(platformVersion,width: 100,height: 100);
myImgV = Image.file(new File(platformVersion));
_platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child:Listener(child:Column(children: <Widget>[
Text('Running on: $_platformVersion\n'),
// Image.network(imagePath,width: 100,height: 100,)
// Image.memory(bytes)
Container(
height: 100.0,
width: 100.0,
child: myImgV,
)
,
],) ,
onPointerDown: (down) {
initPlatformState();
},
)
),
),
);
}
}