quick_cache_flutter 1.0.2 copy "quick_cache_flutter: ^1.0.2" to clipboard
quick_cache_flutter: ^1.0.2 copied to clipboard

Manage your cache securely with a single line of code , without sacrificing performance.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:quick_cache_flutter/quick_cache_flutter.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  QuickCacheFlutter.instance.init();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  TextEditingController textEditingController = TextEditingController();
  ValueNotifier<dynamic> cachedString = ValueNotifier('');

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          TextField(
            controller: textEditingController,
          ),
          ElevatedButton(
              onPressed: () async {
                QuickCacheFlutter.instance.setCache(
                    key: 'testDuration',
                    value: textEditingController.text,
                    expiryDuration: const Duration(seconds: 20));
              },
              child: const Text('Add cache')),
          ElevatedButton(
              onPressed: () async {
                var value = await QuickCacheFlutter.instance
                    .readCache(key: 'testDuration');
                cachedString.value = value;
              },
              child: const Text('get cache')),
          ValueListenableBuilder(
            valueListenable: cachedString,
            builder: (context, value, child) {
              return Text('$value');
            },
          ),
        ],
      ),
    );
  }
}
8
likes
150
points
1
downloads

Publisher

verified publisherappflo.dev

Weekly Downloads

Manage your cache securely with a single line of code , without sacrificing performance.

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

BSD-3-Clause (license)

Dependencies

flutter, flutter_secure_storage, hive, hive_flutter, path_provider

More

Packages that depend on quick_cache_flutter