download 1.0.0 download: ^1.0.0 copied to clipboard
Cross-Platform file downloader for Dart and Flutter projects.
import 'package:download/download.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Download',
theme: ThemeData(
useMaterial3: true,
brightness: Brightness.dark,
colorSchemeSeed: Colors.purple,
),
home: const HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
void _download() {
final stream = Stream.fromIterable('Hello World!'.codeUnits);
download(stream, 'hello.txt');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Download'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
Text(
'Click the FAB to download.',
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _download,
tooltip: 'Download',
child: const Icon(Icons.download),
),
);
}
}