Search packages, repositories and app categories

GitHub repositoryjhourlad/flutter_session

flutter_session

Adds session functionality to Flutter. Works on both mobile, web and (hopefully) desktop apps

flutter_session project cover
Stars
28
Forks
22
Last push (UTC)
Jun 19, 2022
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

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.)

Joe Estrella GitHub avatar
GitHub author

Joe Estrella ↗

Makati City, PhilippinesOfficial website ↗
LanguagesDart

Packages published by this repository

Dependencies used

Dependency list 3 items

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗