Search packages, repositories and app categories

Package detailsv0.1.1

flutter_session

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

30-day downloads
106
Likes
216
Pub points
40

Install package

flutter pub add flutter_session

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

flutter_session provides session management capabilities for Flutter applications, enabling persistent user state across app restarts. It supports mobile, web, and future desktop platforms, offering a simple way to store and retrieve session data securely. Built with cross-platform compatibility in mind, it integrates seamlessly into authentication workflows, helping maintain login status and user context. The package abstracts underlying storage mechanisms, making it easy to manage sessions without dealing with platform-specific details.

Use cases

  • Maintaining user login state
  • Persisting session data across app restarts
  • Supporting authentication flows
  • Enabling secure session storage
  • Cross-platform session management

Key features

  • Cross-platform support (mobile, web, desktop)
  • Simple API for session creation and retrieval
  • Secure data persistence
  • Automatic session expiration handling
  • Lightweight and easy integration

Suitable for

  • Authentication-heavy apps
  • Apps requiring user state persistence
  • Developers targeting multiple platforms
  • Projects needing lightweight session management
  • Web and mobile applications with login systems

Considerations

  • Requires manual setup for encryption if sensitive data is stored
  • No built-in session invalidation mechanism
  • Depends on underlying storage (e.g., SharedPreferences)
  • Not suitable for high-security scenarios without additional safeguards
  • Desktop support is experimental or pending

Original README

Original README snapshot from the linked source repository. Visit the repository 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.)

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package

No data available yet.