Answers for "sharedpreferences flutter"

4

sharedpreferences flutter

dependencies:
  shared_preferences: ^2.0.7

SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('stringValue', "abc");
prefs.setInt('intValue', 123);
prefs.setDouble('doubleValue', 115.0);
prefs.setBool('boolValue', true);
Posted by: Guest on August-21-2021
2

shared prefs flutter

dependencies:
  shared_preferences: ^0.5.12+4
Posted by: Guest on November-29-2020
3

android sharedpreferences

SharedPreferences sharedPref = getSharedPreferences("name", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString("key", "Value");
editor.commit();
Posted by: Guest on November-07-2020
0

flutter sharedpreferences

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);
}
Posted by: Guest on July-10-2021

Code answers related to "sharedpreferences flutter"

Code answers related to "Dart"

Browse Popular Code Answers by Language