super_shared_preferences 0.0.2 super_shared_preferences: ^0.0.2 copied to clipboard
Shared library that can read and write data on Android SharedPres files with SharedName.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:shared_preferences/super_shared_preferences.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String value = "";
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
SharedPreferences.instance(sharedName: "newName")
.setValue("key", "testKey");
String val = await SharedPreferences.instance().getValue("key");
if (!mounted) return;
setState(() {
value = val;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('getValue,value=$value'),
),
),
);
}
}