aliyun_oss_ios 0.0.3+2 copy "aliyun_oss_ios: ^0.0.3+2" to clipboard
aliyun_oss_ios: ^0.0.3+2 copied to clipboard

outdated

ios implementation of the aliyun_oss_plugin.

example/lib/main.dart

import 'package:aliyun_oss_platform_interface/aliyun_oss_platform_interface.dart';
import 'package:flutter/material.dart';
import 'dart:async';

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> {
  dynamic initResult;
  double? progress;
  bool? finish;
  String? error;
  @override
  void initState() {
    super.initState();
    initOSS();
    AliyunOSSPlatform.instance.addMethodCallListener(MethodCallListener(
        initListener: (initData) {},
        progressListener: (progressData) {
          progress = progressData.totalBytesSent /
              progressData.totalBytesExpectedToSend;

          setState(() {});
        },
        failListener: (failData) {
          error = failData.error;
          setState(() {});
        }));
  }

  initOSS() async {
    initResult = await AliyunOSSPlatform.instance.init(
      endpoint,
      // OSSStsTokenCredentialProvider(
      //     accessKeyId: stsAccessKeyId,
      //     secretKeyId: stsAccessKeySecret,
      //     securityToken: stsSecurityToken),
      OSSPlainTextAKSKCredentialProvider(
        accessKeyId: accessKeyId,
        accessKeySecret: accessKeySecret,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text(error != null
              ? "上传错误: $error"
              : 'Running on: $initResult, progress: $progress, finish: $finish'),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () async {
            // runPlayground();
            AliyunOSSPlatform.instance.upload(bucketName);
          },
          child: const Icon(Icons.send),
        ),
      ),
    );
  }

  bool running = false;
  void runPlayground() async {
    if (running) return;
    running = true;
    var cancel = startListening((msg) {
      setState(() {
        print('事件频道: $msg');
      });
    });
    await Future.delayed(const Duration(seconds: 4));
    cancel();
    running = false;
  }
}
0
likes
0
pub points
4%
popularity

Publisher

unverified uploader

ios implementation of the aliyun_oss_plugin.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on aliyun_oss_ios