shared_preferences_storage_view_driver 0.1.0-dev.4 copy "shared_preferences_storage_view_driver: ^0.1.0-dev.4" to clipboard
shared_preferences_storage_view_driver: ^0.1.0-dev.4 copied to clipboard

Shared preferences driver for storage_view. Flutter inspector tool for any database, storage

example/lib/main.dart

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shared_preferences_storage_view_driver/shared_preferences_storage_view_driver.dart';
import 'package:storage_view/storage_view.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final prefs = await SharedPreferences.getInstance();
  runApp(SharedPreferencesExample(sharedPreferences: prefs));
}

class SharedPreferencesExample extends StatefulWidget {
  const SharedPreferencesExample({
    Key? key,
    required this.sharedPreferences,
  }) : super(key: key);

  final SharedPreferences sharedPreferences;

  @override
  State<SharedPreferencesExample> createState() =>
      _SharedPreferencesExampleState();
}

class _SharedPreferencesExampleState extends State<SharedPreferencesExample> {
  @override
  void initState() {
    final rnd = Random();
    widget.sharedPreferences
      ..setInt('int ${rnd.nextInt(100).toString()}', rnd.nextInt(10000))
      ..setDouble('double ${rnd.nextInt(100).toString()}', rnd.nextDouble())
      ..setString('String  ${rnd.nextInt(100).toString()}',
          DateTime.now().toIso8601String())
      ..setBool('bool ${rnd.nextInt(100).toString()}', false);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'SharedPreferencesExample',
      theme: ThemeData(
        primarySwatch: Colors.green,
        primaryColor: Colors.green,
      ),
      home: Scaffold(
        body: StorageView(
          storageDriver: SharedPreferencesDriver(widget.sharedPreferences),
        ),
      ),
    );
  }
}
5
likes
150
points
145
downloads

Publisher

verified publisherfrezycode.com

Weekly Downloads

Shared preferences driver for storage_view. Flutter inspector tool for any database, storage

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, shared_preferences, storage_view

More

Packages that depend on shared_preferences_storage_view_driver