network_resource 0.0.2 copy "network_resource: ^0.0.2" to clipboard
network_resource: ^0.0.2 copied to clipboard

outdated

Automatically cache network resources and use them when offline.

example/main.dart

import 'package:flutter/material.dart';
import '../lib/network_resource.dart';

final _resource1 = NetworkResource(
  url: 'http://example.com/resource1.json',
  filename: 'resource1.json',
  maxAge: Duration(minutes: 60),
);

class MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: FutureBuilder<ResourceData>(
      future: _resource1.get(),
      builder: (context, snapshot) {
        if (snapshot.hasData) {
          return Text('${snapshot.data.data}');
        } else if (snapshot.hasError) {
          return Text('${snapshot.error}');
        }
        return Center(child: CircularProgressIndicator());
      },
    ));
  }
}

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Network Resource example',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  MyHomePageState createState() {
    return new MyHomePageState();
  }
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Automatically cache network resources and use them when offline.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, http, path_provider

More

Packages that depend on network_resource