glutton 1.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 76

Glutton #

Flutter shared preferences customized plugin. Secure, Encrypted, Simplified use, Simple key-value pairs storage.

Getting Started #

In your flutter project add the dependency:

dependencies:
  ...
  glutton: ^1.0.5

Usage #

Importing package

import 'package:glutton/glutton.dart';

Using Glutton

Saving data inside glutton

bool isSuccess = await Glutton.eat(key, data);

Retrieve data inside glutton

dynamic data = await Glutton.vomit(key);

Check if data is exist inside glutton

bool isExist = await Glutton.have(key);

Remove data inside glutton

bool isSuccess = await Glutton.digest(key);

Clear all data inside glutton

await Glutton.flush();

Can we save class object? #

The current answer is no.

Written in JSON and Serialization, flutter doesn't provide library like GSON or Moshi. Such a library would require using runtime reflection, which is disabled in Flutter. So we can't automatically turn class into json or the opposite, but we need to transform it manual first to edible data type.

Edible data type #

  • List
  • Set
  • Map (can eat json here)
  • DateTime
  • String
  • bool
  • int (can eat enum index here)
  • double
  • Uri

Example #

Save & retrieve class

Save:

/// 1. Create user object
User user = User(
  name: "Gentleton",
  age: 21,
  createdAt: DateTime.now(),
);

/// 2. Transform user object to map
Map<String, dynamic> userMap = user.toJson();

/// 3. Save user map inside glutton
bool isSuccess = await Glutton.eat(<UserKey>, userMap);

Retrieve

/// 1. Retrieve user map inside glutton
Map<String, dynamic> userMap = await Glutton.vomit(<UserKey>);

/// 2. Transform user map to user object
User user = User.fromJson(userMap);

Save & retrieve date

Save:

/// 1. Set selected date
DateTime date = await showDatePicker(
  context: context,
  initialDate: _selectedDate,
  firstDate: DateTime(1990),
  lastDate: DateTime(2030),
);

/// 2. Save selected date inside glutton
await Glutton.eat(<DateKey>, date);

Retrieve

/// 1. Retrieve user map inside glutton
DateTime date = await Glutton.vomit(<DateKey>);

Save & retrieve enum

Save:

/// 1. Retrieve index of enum
int index = Season.index;

/// 2. Save index inside glutton
await Glutton.eat(<enumKey>, index);

Retrieve

/// 1. Retrieve index inside glutton
int index = await Glutton.vomit(<enumKey>);

/// 2. Transform index to enum
Season _season = SeasonManager.fromIndex(index);

You can follow Season enum for step 2 retrieve enum

[1.0.5] - 06/11/2020 #

  • Update readme

[1.0.4] - 06/11/2020 #

  • Fixing revert string

[1.0.3] - 04/30/2020 #

  • Update readme
  • Fixing description

[1.0.2] - 04/23/2020 #

  • Fix eat list and set
  • Add eat uri

[1.0.1] - 04/20/2020 #

  • Update Readme

[1.0.0] - 04/20/2020 #

  • Update Readme

[0.0.1] - 04/20/2020 #

  • Initial Release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:glutton_example/eat_class/eat_class_page.dart';
import 'package:glutton_example/eat_date/eat_date_page.dart';
import 'package:glutton_example/eat_enum/eat_enum_page.dart';
import 'package:glutton_example/eat_uri/eat_uri_page.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    ThemeData _themeData = ThemeData.light();
    return MaterialApp(
      title: 'Glutton Example',
      debugShowCheckedModeBanner: false,
      home: MainPage(),
      theme: _themeData.copyWith(
        primaryColor: Colors.purple,
        buttonTheme: _themeData.buttonTheme.copyWith(
          buttonColor: Colors.purple,
          textTheme: ButtonTextTheme.primary,
        ),
      ),
    );
  }
}

class MainPage extends StatefulWidget {
  @override
  _MainPageState createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  List _possibleEaten = [
    'List',
    'Set',
    'Map (can eat json here)',
    'DateTime',
    'String',
    'bool',
    'int (can eat enum index here)',
    'double'
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        resizeToAvoidBottomInset: false,
        appBar: AppBar(
          title: Text('Glutton Example'),
          elevation: 0.0,
          centerTitle: true,
        ),
        body: SingleChildScrollView(
          child: Padding(
            padding: const EdgeInsets.all(16.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: <Widget>[
                RaisedButton(
                  elevation: 0.0,
                  child: Text('Example eat & vomit class'),
                  onPressed: () => Navigator.push(
                    context,
                    MaterialPageRoute(
                      builder: (_) => EatClassPage(),
                    ),
                  ),
                ),
                RaisedButton(
                  elevation: 0.0,
                  child: Text('Example eat & vomit enum'),
                  onPressed: () => Navigator.push(
                    context,
                    MaterialPageRoute(
                      builder: (_) => EatEnumPage(),
                    ),
                  ),
                ),
                RaisedButton(
                  elevation: 0.0,
                  child: Text('Example eat & vomit date'),
                  onPressed: () => Navigator.push(
                    context,
                    MaterialPageRoute(
                      builder: (_) => EatDatePage(),
                    ),
                  ),
                ),
                RaisedButton(
                  elevation: 0.0,
                  child: Text('Example eat & vomit uri'),
                  onPressed: () => Navigator.push(
                    context,
                    MaterialPageRoute(
                      builder: (_) => EatUriPage(),
                    ),
                  ),
                ),
                SizedBox(height: 8.0),
                Divider(),
                SizedBox(height: 8.0),
                Text(
                  'Glutton Food',
                  style: TextStyle(
                    color: Colors.purple,
                    fontSize: 24.0,
                    fontWeight: FontWeight.w500,
                  ),
                ),
                SizedBox(height: 4.0),
                Text(
                  'Edible data type:',
                  style: TextStyle(
                    color: Colors.black54,
                    fontSize: 16.0,
                  ),
                ),
                SizedBox(height: 8.0),
                ..._possibleEaten
                    .map(
                      (value) => Padding(
                        padding: const EdgeInsets.only(bottom: 8.0),
                        child: Text(
                          '- $value',
                          style: TextStyle(
                            fontSize: 16.0,
                            color: Colors.black54,
                          ),
                        ),
                      ),
                    )
                    .toList(),
              ],
            ),
          ),
        ));
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  glutton: ^1.0.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:glutton/glutton.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
53
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
76
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Android

Because:

  • package:glutton/glutton.dart that imports:
  • package:glutton/src/glutton.dart that imports:
  • package:glutton/src/glutton_digestion.dart that imports:
  • package:glutton/src/utils/glutton_stomach.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: Linux

Package does not support Flutter platform Web

Because:

  • package:glutton/glutton.dart that imports:
  • package:glutton/src/glutton.dart that imports:
  • package:glutton/src/glutton_digestion.dart that imports:
  • package:glutton/src/utils/glutton_stomach.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: Linux

Package does not support Flutter platform Windows

Because:

  • package:glutton/glutton.dart that imports:
  • package:glutton/src/glutton.dart that imports:
  • package:glutton/src/glutton_digestion.dart that imports:
  • package:glutton/src/utils/glutton_stomach.dart that imports:
  • package:shared_preferences/shared_preferences.dart that declares support for platforms: Android, iOS, Linux, macOS, Web

Package does not support Flutter platform iOS

Because:

  • package:glutton/glutton.dart that imports:
  • package:glutton/src/glutton.dart that imports:
  • package:glutton/src/glutton_digestion.dart that imports:
  • package:glutton/src/utils/glutton_stomach.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: Linux

Package does not support Flutter platform macOS

Because:

  • package:glutton/glutton.dart that imports:
  • package:glutton/src/glutton.dart that imports:
  • package:glutton/src/glutton_digestion.dart that imports:
  • package:glutton/src/utils/glutton_stomach.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: Linux

Package not compatible with SDK dart

Because:

  • glutton that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
encrypt ^4.0.0 4.0.2
flutter 0.0.0
shared_preferences ^0.5.7 0.5.8
Transitive dependencies
args 1.6.0
asn1lib 0.6.5
charcode 1.1.3
clock 1.0.1
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
file 5.2.1
flutter_web_plugins 0.0.0
intl 0.16.1
meta 1.1.8 1.2.2
path 1.7.0
path_provider_linux 0.0.1+2
path_provider_platform_interface 1.0.2
platform 2.2.1
plugin_platform_interface 1.0.2
pointycastle 1.0.2
process 3.0.13
shared_preferences_linux 0.0.2+1
shared_preferences_macos 0.0.1+10
shared_preferences_platform_interface 1.0.4
shared_preferences_web 0.1.2+7
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
xdg_directories 0.1.0
Dev dependencies
flutter_test