#####flutter的图片上传进度(类似qq发送图片)
For help getting started with Flutter, view our online documentation.
For help on editing package code, view the documentation.
##How to use ?
dependencies:
progress_image: "^0.0.1"
$ flutter packages get
import 'package:progress_image/progress_image.dart';
##属性
##Example
import 'package:flutter/material.dart';
import 'package:progress_image/progress_image.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
GlobalKey<ProgressImageState> progressImageKey =
new GlobalKey<ProgressImageState>();
void _incrementCounter() {
progressImageKey.currentState.setProgress(100);
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new ProgressImage(
key: progressImageKey,
builder: (BuildContext context, Size size) {
return new Image.network(
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1527862078037&di=3ce4750ed2aa7629c2e25e49f065e06e&imgtype=0&src=http%3A%2F%2Fimg15.3lian.com%2F2015%2Ff2%2F82%2Fd%2F7.jpg',
width: size.width,
fit: BoxFit.fill,
height: size.height,
);
}),
],
),
),
floatingActionButton: new FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: new Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:progress_image/progress_image.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
GlobalKey<ProgressImageState> progressImageKey =
new GlobalKey<ProgressImageState>();
void _incrementCounter() {
progressImageKey.currentState.setProgress(100);
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new ProgressImage(
key: progressImageKey,
builder: (BuildContext context, Size size) {
return new Image.network(
'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1527862078037&di=3ce4750ed2aa7629c2e25e49f065e06e&imgtype=0&src=http%3A%2F%2Fimg15.3lian.com%2F2015%2Ff2%2F82%2Fd%2F7.jpg',
width: size.width,
fit: BoxFit.fill,
height: size.height,
);
}),
],
),
),
floatingActionButton: new FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: new Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
Add this to your package's pubspec.yaml file:
dependencies:
progress_image: ^0.0.2
You can install packages from the command line:
with Flutter:
$ flutter packages get
Alternatively, your editor might support flutter packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:progress_image/progress_image.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.0.2 | Jun 5, 2018 |
|
|
0.0.1 | Jun 3, 2018 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
41
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
50
|
Overall:
Weighted score of the above.
[more]
|
61
|
We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Format lib/progress_image.dart
.
Run flutter format
to format lib/progress_image.dart
.
Support the latest stable Dart SDK in pubspec.yaml
. (-20 points)
The SDK constraint in pubspec.yaml
doesn't allow the latest stable Dart SDK release.
The package description is too short. (-20 points)
Add more detail to the description
field of pubspec.yaml
. Use 60 to 180 characters to describe the package, what it does, and its target use case.
Package is pre-v0.1 release. (-10 points)
While nothing is inherently wrong with versions of 0.0.*
, it might mean that the author is still experimenting with the general direction of the API.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=1.23.0 <2.3.0 | ||
flutter | 0.0.0 | ||
Transitive dependencies | |||
collection | 1.14.11 | ||
meta | 1.1.6 | 1.1.7 | |
sky_engine | 0.0.99 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 | ||
Dev dependencies | |||
flutter_test |