shared_pref_pro 1.1.4 copy "shared_pref_pro: ^1.1.4" to clipboard
shared_pref_pro: ^1.1.4 copied to clipboard

A clean, extensible, and production-ready local storage plugin with Smart Expiring Cache support. Works on Android, iOS, Web, Windows, macOS, and Linux.

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _sharedPref = SharedPrefPro.instance;
  String _storedValue = 'None';
  final _controller = TextEditingController();

  @override
  void initState() {
    super.initState();
    _loadValue();
  }

  Future<void> _loadValue() async {
    final value = await _sharedPref.get<String>('test_key');
    setState(() {
      _storedValue = value ?? 'None';
    });
  }

  Future<void> _saveValue() async {
    await _sharedPref.save<String>('test_key', _controller.text);
    _loadValue();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('SharedPrefPro Example')),
        body: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            children: [
              Text('Stored Value: $_storedValue'),
              TextField(
                controller: _controller,
                decoration: const InputDecoration(labelText: 'Enter value'),
              ),
              ElevatedButton(
                onPressed: _saveValue,
                child: const Text('Save'),
              ),
              ElevatedButton(
                onPressed: () async {
                  await _sharedPref.clear();
                  _loadValue();
                },
                child: const Text('Clear'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
2
likes
150
points
331
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A clean, extensible, and production-ready local storage plugin with Smart Expiring Cache support. Works on Android, iOS, Web, Windows, macOS, and Linux.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface, web

More

Packages that depend on shared_pref_pro

Packages that implement shared_pref_pro