This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this code belongs to https://fluttercompletereference.com/ | |
//Chapter 17: Advanced HTTP | |
//****************************************************************************** | |
void main() => runApp(DemoApp()); | |
class DemoApp extends StatelessWidget { | |
const DemoApp(); | |
@override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this code belongs to https://fluttercompletereference.com/ | |
//Chapter 17: Files Download | |
//****************************************************************************** | |
class DownloadWidget extends StatelessWidget { | |
final String url = "https://website.com/files/something.pdf"; | |
const DownloadWidget(); | |
@override | |
Widget build(BuildContext context) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this code belongs to https://fluttercompletereference.com/ | |
//Chapter 17: Files Download | |
//****************************************************************************** | |
class DownloadProgress with ChangeNotifier { | |
double get progress => _progress; | |
void start({ required String url, required String localPath}) async { | |
// Reset in case it isn't at zero |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this code belongs to https://fluttercompletereference.com/ | |
//Chapter 17: Files Download | |
//****************************************************************************** | |
void main() => runApp(DemoApp()); | |
class DemoApp extends StatelessWidget { | |
const DemoApp(); | |
@override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this code belongs to https://fluttercompletereference.com/ | |
//Chapter 17: HTTP Requests | |
//****************************************************************************** | |
class ErrorItemWidget extends StatelessWidget { | |
const ErrorItemWidget(); | |
@override | |
Widget build(BuildContext context) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this code belongs to https://fluttercompletereference.com/ | |
//Chapter 17: HTTP Requests | |
//****************************************************************************** | |
class SuccessItemWidget extends StatelessWidget { | |
final Item? data; | |
const SuccessItemWidget(this.data); | |
@override | |
Widget build(BuildContext context) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this code belongs to https://fluttercompletereference.com/ | |
//Chapter 17: HTTP Requests | |
//****************************************************************************** | |
class HTTPWidget extends StatefulWidget { | |
final HTTPRequest<Item> _request; | |
const HTTPWidget(this._request); | |
@override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this code belongs to https://fluttercompletereference.com/ | |
//Chapter 17: HTTP Requests | |
//****************************************************************************** | |
class RequestItem implements HTTPRequest<Item> { | |
final String url; | |
const RequestItem({ required this.url }); | |
Future<Item> execute() async { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this code belongs to https://fluttercompletereference.com/ | |
//Chapter 17: HTTP Requests | |
//****************************************************************************** | |
abstract class HTTPRequest<T> { | |
Future<T> execute(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this code belongs to https://fluttercompletereference.com/ | |
//Chapter 17: HTTP Requests | |
//****************************************************************************** | |
class Item { | |
final int id; | |
final String title; | |
Item({ | |
required this.id, | |
required this.title |
NewerOlder