dao_wrapped 0.2.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 75

dao_wrapped #


mixin sql wrapper with dao implementation for model.

implements methods

get, getAll, getByField,





all you need to do is describe table creation and model mapping(it can json_serializable).

example #

I recommend using the interface to communicate with the implementation.

for sample:


abstract class SampleGateway {
  Future<List<SampleModel>> getAll();

  Future<SampleModel> get(int id);

  Future set(SampleModel model);

  Future delete(int id);

and its implementation.

class SampleGatewayImpl with DaoMixin<SampleModel> implements SampleGateway {
  final SampleGatewayTable databaseGateway;

  SampleGatewayImpl(Database database)
      : databaseGateway = SampleGatewayTable(database);

Implements interface methods DaoMixin, so you don’t have to do anything with them.

Part with model mapping and description of the table made in DatabaseGateway.

You can use dao_wrapped_gen for generate sql table:

class SampleGatewayTable extends DatabaseGateway<SampleModel> with WithTable {
  final Database db;
  final ModelTable modelTable = _Table();


  SampleModel fromMap(Map<String, dynamic> map) {
    return SampleModel.fromMap(map);

  Map<String, dynamic> toMap(SampleModel model) {
    return model.toMap();

or you can not use it

class SampleGatewayTable implements DatabaseGateway<SampleModel> {
  final Database db;


  String get primaryId => "id";

  String get table => "SampleModel";

  Future createTable() async {
    var createTableRequest = "CREATE TABLE IF NOT EXISTS $table("
        "$primaryId INTEGER PRIMARY KEY,"
        "message TEXT)";
    await db.execute(createTableRequest);

  SampleModel fromMap(Map<String, dynamic> map) {
    return SampleModel.fromMap(map);

  Map<String, dynamic> toMap(SampleModel model) {
    return model.toMap();


[0.1.0] - 24.11.2019.

  • Initial release.

[0.1.1] - 24.11.2019.

  • edit description.

[0.1.2] - 29.11.2019.

  • add getByFields method.

[0.2.0] - 06.12.2019.

  • sql tables generation.


example #

example dao wrapped

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dao_wrapped: ^0.2.0+1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dao_wrapped/dao_wrapped.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 16, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Fix lib/src/table/database_gateway.dart. (-1 points)

Analysis of lib/src/table/database_gateway.dart reported 2 hints:

line 1 col 8: Unused import: 'package:dao_wrapped/src/dao/dao_mixin.dart'.

line 2 col 8: Unused import: 'package:dao_wrapped_annotation/dao_wrapped_annotation.dart'.

Fix lib/src/table/with_table.dart. (-0.50 points)

Analysis of lib/src/table/with_table.dart reported 1 hint:

line 2 col 8: Unused import: 'package:dao_wrapped/src/dao/dao_mixin.dart'.

Format lib/src/dao/dao_mixin.dart.

Run flutter format to format lib/src/dao/dao_mixin.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
dao_wrapped_annotation ^0.2.0 0.2.0
flutter 0.0.0
sqflite ^1.1.7+2 1.2.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
path 1.6.4
sky_engine 0.0.99
synchronized 2.1.1
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies