Fluter Package Sharedpreference

[Solved] Fluter Package Sharedpreference | Dart - Code Explorer | yomemimo.com
Question : sharedpreferences flutter

Answered by : chandramouli-s

dependencies: shared_preferences: ^2.0.11
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('stringValue', "abc");
prefs.setInt('intValue', 123);
prefs.setDouble('doubleValue', 115.0);
prefs.setBool('boolValue', true);

Source : https://pub.dev/packages/shared_preferences | Last Update : Sat, 28 Aug 21

Question : flutter sharedpreferences

Answered by : victorious-vulture-8rkwe6kmw5l0

import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() { runApp(MaterialApp( home: Scaffold( body: Center( child: RaisedButton( onPressed: _incrementCounter, child: Text('Increment Counter'), ), ), ), ));
}
_incrementCounter() async { SharedPreferences prefs = await SharedPreferences.getInstance(); int counter = (prefs.getInt('counter') ?? 0) + 1; print('Pressed $counter times.'); await prefs.setInt('counter', counter);
}

Source : https://pub.dev/packages/shared_preferences | Last Update : Sat, 17 Jul 21

Question : fluter package sharedpreference

Answered by : aguda-john

dependencies: nb_utils: ^4.5.2
// for initializing
void main() async { WidgetsFlutterBinding.ensureInitialized(); await initialize(); runApp(MyApp());
}
// adding key
return MaterialApp( debugShowCheckedModeBanner: false, navigatorKey: navigatorKey, home: HomePage(),
);
// then just use
/// add a Double, int, string in SharedPref
await setValue("key", 20.0);
\
///to get
getBoolAsync("key");
/// Returns a Double if exists in SharedPref
getDoubleAsync("key");
/// Returns a Int if exists in SharedPref
getIntAsync("key");
/// Returns a String if exists in SharedPref
getStringAsync("key");

Source : | Last Update : Wed, 01 Jun 22

Answers related to fluter package sharedpreference

Code Explorer Popular Question For Dart