Skip to content
pubscout

b012_data

2.1.0, released 2 weeks ago by b012tech.com

Spring Boot-inspired local SQLite CRUD and file helpers for Flutter entities.

$ flutter pub add b012_data
Source repository

What it does

Automatically generates SQLite CRUD statements from plain Dart entity classes without manual SQL or repository boilerplate. Provides file system helpers for reading, writing, and managing binary files and paths. Supports optional database and file encryption.

AI-written summary of version 2.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want local SQLite persistence without writing hand-written SQL or repositories
  • You need file system helpers alongside local database storage
  • You want optional encryption for your local database and files

Skip it when

  • You need a cloud-synced backend database
  • You require a full ORM with complex relationship mapping

Strengths

  • No hand-written SQL or repository boilerplate required
  • Handles both local SQLite CRUD and file system storage
  • Supports cross-platform including mobile, desktop, and web

Weaknesses

  • Requires careful exception handling as most entity methods throw when tables do not exist
  • First access creates a default database named sqlf_easy.db unless changed

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
9

Make sure Flutter bindings are initialized with WidgetsFlutterBinding.ensureInitialized() before calling methods that need the application documents directory.

class Person {
  String? idPers;
  String? firstName;
  String? lastName;
  bool? sex;
  DateTime? dateOfBirth;

  MapEntry<String, bool> get pKeyAuto => const MapEntry('idPers', false);
  List<String> get notNulls => <String>['firstName', 'lastName', 'sex', 'dateOfBirth'];

  Person([this.idPers, this.firstName, this.lastName, this.sex, this.dateOfBirth]);

  Map<String, dynamic> toMap() => {
        'idPers': idPers ?? ColumnType.String,
        'firstName': firstName ?? ColumnType.String,
        'lastName': lastName ?? ColumnType.String,
        'sex': sex ?? ColumnType.bool,
        'dateOfBirth': dateOfBirth ?? ColumnType.DateTime,
      };

  Person.fromMap(Map<String, Object?> json, {bool isInt = true}) {
    idPers = json['idPers'] as String?;
    firstName = json['firstName'] as String?;
    lastName = json['lastName'] as String?;
    sex = boolean(json['sex'], isInt: isInt);
    dateOfBirth = dateTime(json['dateOfBirth'] as String?);
  }

  Person fromMap(Map<String, Object?> json) => Person.fromMap(json);
}

Alternatives

Packages that do the same job and could replace b012_data.

  • sembast

    A NoSQL persistent embedded document-based database for Dart and Flutter.

Works with

Packages commonly used together with b012_data: ones it builds on, ones built on it, and its own family.