shared_preferences_viewer 0.0.1 copy "shared_preferences_viewer: ^0.0.1" to clipboard
shared_preferences_viewer: ^0.0.1 copied to clipboard

A package provides a widget showing datas stored in SharedPreferences.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shared_preferences_viewer/shared_preferences_viewer.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Builder(builder: (context) {
        return Scaffold(
          appBar: AppBar(
            title: const Text('Example'),
            actions: [
              IconButton(
                onPressed: () {
                  Navigator.of(context).push(
                    MaterialPageRoute(
                      builder: (context) => const SharedPreferencesView(),
                    ),
                  );
                },
                icon: const Icon(Icons.storage),
              )
            ],
          ),
          body: Center(
            child: TextButton(
              onPressed: () async {
                final pref = await SharedPreferences.getInstance();

                pref.setInt('count', 999);
                pref.setString('username', 'John Appleseed');
                pref.setBool('didViewedPolicy', false);
                pref.setDouble('height', 1234.5678);
                pref.setStringList(
                  'staredLanguage',
                  ['Dart', 'Swift', 'Kotlin', 'Objective-C', 'Java'],
                );
              },
              child: const Text('Add some sample datas'),
            ),
          ),
        );
      }),
    );
  }
}
0
likes
160
pub points
62%
popularity

Publisher

verified publisherblacklemon.dev

A package provides a widget showing datas stored in SharedPreferences.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, shared_preferences

More

Packages that depend on shared_preferences_viewer