vone_ipfs 0.0.13 vone_ipfs: ^0.0.13 copied to clipboard
A IPFS project.
import 'package:flutter/material.dart';
import 'package:vone_ipfs/bean/upload_result_entity.dart';
import 'package:vone_ipfs/component/file_upload_view.dart';
import 'package:vone_ipfs/utils/ipfs_utils.dart';
import 'package:vone_ipfs/component/image_upload_view.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: HomePage(),
),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
List<UploadResultEntity> _files = [];
@override
void initState() {
// TODO: implement initState
super.initState();
IPFSUtils.getInstance('260a2ed0-6ff9-42f7-9125-26221ddba36f');
IPFSUtils.instance!.initUserId("10653");
// Future.delayed(Duration(seconds: 10),(){
// setState(() {
_files.add(UploadResultEntity(IPFSUtils.instance!.getFilePath('102', 'Screenshot_2021-12-30-09-49-31-618_com.example.wts(3).jpg'),'','aaaa.jpg'));
// });
// });
Future.delayed(Duration(seconds: 20),(){
setState(() {
_files.add(UploadResultEntity(IPFSUtils.instance!.getFilePath('81', 'aaaa.jpg'),'','aaaa.jpg'));
_files.add(UploadResultEntity(IPFSUtils.instance!.getFilePath('81', 'aaaa.jpg'),'','aaaa.jpg'));
});
});
}
@override
Widget build(BuildContext context) {
print(_files.length);
return ListView(
children: [
Text('文件上传'),
Container(
child: FileUploadView(
_files,
'2',
'vonevone',
(files) {
print(files);
},
maxCount: 3,
isCanEdit: true,
fileType: IPFSFileType.custom,
allowedExtensions: ['jpg', 'png', 'doc', 'docx', 'ppt'],
isFixedDir: false,
isAllowCloud: false,
),
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
),
Text('单图片上传'),
ImageUploadView(
images: _files,
dirName: 'vonevone',
dirId: '2',
isFixedDir: true,
isAllowCloud: true,
isCanEdit: false,
uploadMode: UploadMode.SINGLE,
btnPosition: UploadBtnPosition.RIGHT,
valueChangedCallback: (value) {
print(value);
},
),
Text('多图片上传'),
ImageUploadView(
dirName: 'vonevone',
dirId: '3',
images: _files,
isCanEdit: true,
isFixedDir: true,
isAllowCloud: true,
uploadMode: UploadMode.MULTIPLE,
btnPosition: UploadBtnPosition.TOP,
addImageWidget: Text('上传'),
valueChangedCallback: (value) {
print(value);
},
),
],
);
// return Center(
// child: InkWell(
// child: Text('Running on:'),
// onTap: () {
// IPFSUtils.fileUploadSingle(context, (value) {});
// },
// ),
// );
}
}