FLUTTER ECOSYSTEM

jhourlad/flutter_session

Adiciona funcionalidade de sessão ao Flutter. Funciona em aplicativos móveis, da web e (esperamos) de mesa

Capa do projeto flutter_session
Stars
28
Forks
22
Último push (UTC)
19 de jun. de 2022
Status do projeto
Ativo
Joe Estrella GitHub avatar
GITHUB User

Joe Estrella ↗

Makati City, PhilippinesSite oficial ↗
LinguagensDart

Pacotes publicados por este repositório

Dependências usadas

Lista de dependências 3 itens
  • flutter{"sdk":"flutter"}
  • shared_preferences^2.0.5
  • flutter_testDesenvolvimento{"sdk":"flutter"}

README original

Texto original em inglês. Visite o GitHub para a versão atual.

Expandir / recolher README

flutter_session

Adds session support to Flutter. Works with mobile, web and (hopefully) desktop builds. (Don't forget to hit the like button if you find the package helpful.)

Write values to the session:
await FlutterSession().set("token", myJWTToken);

or

var session = FlutterSession();
await session.set("token", myJWTToken);
await session.set("name", "jhourlad");
await session.set("id", 1);
await session.set("price", 10.50);
await session.set("isOK", true);

Saving objects, make sure that it has the toJson() method. See https://ashamp.github.io/jsonToDartModel:

class Data {
  final int id;
  final String data;

  Data({this.data, this.id});

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = Map<String, dynamic>();
    data["id"] = id;
    data["data"] = this.data;
    return data;
  }
}

Data mappedData = Data(id: 1, data: "Lorem ipsum something, something...");
await FlutterSession().set('mappedData', mappedData);
Read values from the session:
dynamic token = await FlutterSession().get("token");

Session persists throughout the app's lifetime. (Don't forget to hit the like button if you find the package helpful.)