wetransfer 0.3.0+0

  • Readme
  • Changelog
  • Example
  • Installing
  • 48

WeTransfer for Flutter #

A Flutter package that allows upload and dowload files to Wetransfer.

How to create a new instance #

Create a new instance with :

 WeTransferClient client = await WeTransferClient.create('<api_key>');

Example #

    WeTransferClient client = await WeTransferClient.create('<api_key>');
    
    Transfer transfer = await client.createTransfer(
        myFiles, "Test transfer.");

    await client.uploadFiles(transfer).forEach((state) =>
        print('${state.file.name} : ${state.type}'));

    String url = await client.finalizeTransfer(transfer);

    client?.close();

[0.3.0+0] - 31/10/2019. #

  • FileUploadState has now now a timestamp
  • The Transfer class is now detailed
  • WeTransferClient.getTransferInfo now returns a Transfer instead of the url of the Transfer

[0.2.0+1] - 24/10/2019. #

  • Added an example
  • Fixed the changelog

[0.2.0] - 24/10/2019. #

  • Revamped project structure
  • Deleted the WeTransferClient.completeFilesUpload(transfer) method as it is now done automatically in WeTransferClient.uploadFiles(transfer)

[0.1.1] - 18/10/2019. #

  • Fixing packages infos, no code changes

[0.0.1] - 18/10/2019. #

  • Initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:file_picker/file_picker.dart';
import 'package:wetransfer/wetransfer.dart';
import 'dart:io';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: App(),
    );
  }
}

class App extends StatefulWidget {
  @override
  _AppState createState() => _AppState();
}

class _AppState extends State<App> {
  WeTransferClient client;
  String _url;

  @override
  void initState() {
    super.initState();
    WeTransferClient.create('cTx6MZXt6n8So0PMNn5uq4YdHq54RIhS3bNYIBG8')
        .then((cli) => setState(() => client = cli));
  }

  @override
  void dispose() {
    client?.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        title: Text(
          "Let's Share !",
          style: Theme.of(context).textTheme.title,
        ),
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          RaisedButton(
            onPressed: _send,
            child: Text("Choose and send files"),
          ),
          if (_url != null)
            Center(
              child: Text(
                _url,
                style: Theme.of(context).textTheme.title.copyWith(fontSize: 18),
              ),
            ),
        ],
      ),
    );
  }

  void _send() async {
    print("Gonna choose files");
    setState(() {
      _url = null;
    });

    Map<String, String> files = await FilePicker.getMultiFilePath();
    print("Got files");

    print("Creating transfer");

    Transfer transfer = await client.createTransfer(
        files.values.map<File>((f) => File(f)).toList(), "Test transfer yayyy");

    print("Transfer with id ${transfer.id} created");

    print("Uploading ${transfer.files.length} files");

    await client.uploadFiles(transfer).forEach(
        (s) => "${s.file.name} : ${s.type} ${s.done ? "done" : "in progress"}");

    print('Completed all uploads');
    print("Finalizing transfer");

    String url = await client.finalizeTransfer(transfer);

    setState(() {
      _url = url;
    });

    print("Transfer ${transfer.id} ready : $url");
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  wetransfer: ^0.3.0+0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:wetransfer/wetransfer.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

We analyzed this package on Apr 6, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (xml).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.2 <3.0.0
http ^0.12.0+2 0.12.0+4
path ^1.6.4 1.6.4
unique_ids ^1.0.10 1.0.10
xml ^3.5.0 3.7.0 4.1.0
Transitive dependencies
async 2.4.1
charcode 1.1.3
collection 1.14.11 1.14.12
convert 2.1.1
flutter 0.0.0
http_parser 3.1.4
meta 1.1.8
pedantic 1.9.0
petitparser 3.0.2
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test