flutter_session 0.1.1 copy "flutter_session: ^0.1.1" to clipboard
flutter_session: ^0.1.1 copied to clipboard

Adds session support to Flutter. Works with mobile, web and (hopefully) desktop builds.

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);
copied to clipboard

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);
copied to clipboard

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);
copied to clipboard

Read values from the session: #

dynamic token = await FlutterSession().get("token");
copied to clipboard

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

216
likes
40
points
66
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.14 - 2025.03.29

Adds session support to Flutter. Works with mobile, web and (hopefully) desktop builds.

Repository (GitHub)

License

MIT (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on flutter_session