FLUTTER ECOSYSTEM

jhourlad/flutter_session

Flutterにセッション機能を追加します。モバイル、Web、( hopefully )デスクトップアプリで動作します

flutter_session のプロジェクト画像
Stars
28
Forks
22
最終プッシュ(UTC)
2022/06/19
プロジェクト状態
公開中
Joe Estrella GitHub avatar
GITHUB User

Joe Estrella ↗

Makati City, Philippines公式サイト ↗
言語Dart

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 3 件

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

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