sqfentity_gen 1.1.0+5

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

sqfentity_gen #

This package required for sqfentity ORM for Flutter code generator Includes Generators and Converters with build.yaml

Getting Started #

click for more information: https://github.com/hhtokpinar/sqfEntity

1.1.0+5 #

bugfix SequenceManager error on multi database

1.1.0+4 #

added unknown (text) dbType for unrecognized columns

1.1.0+3 #

added Date (Small Date) dbType

    SqfEntityField('birthDate', DbType.date),

1.1.0+2 #

added DateTime dbType

    SqfEntityField('birthDate', DbType.datetime),

1.1.0+1 #

modified sqlite dbType mapping

1.1.0 #

merged package with sqfentity_base

1.0.3+5 #

removed analyzer from dependencies

1.0.3+4 #

added FormBuilder

1.0.3+3 #

removed FormBuilder

1.0.3+2 #

added analyzer 0.38.2

1.0.3+1 #

sqfentity_base exported to sqfentity_base 1.0.1 package

1.0.2+4 #

Blob type mapped as Uint8List instead String

1.0.2 #

Added function to generate model from existing database

1.0.1 #

sqfentity_base moved into this package

1.0.0+7 #

some required changes applied

1.0.0+6 #

  • Initial publish This package required for sqfentity_gen ORM for Flutter code generator Includes SqfEntity base classes and Annotation Classes


import 'package:flutter/material.dart';

// STEP 1: import sqfentity package.
import 'package:sqfentity_gen/sqfentity_gen.dart';
import 'package:sqfentity/sqfentity.dart';

// STEP 1: define your tables as shown in the example Classes below.
// Define the 'TableCategory' constant as SqfEntityTable.
const tableCategory = SqfEntityTable(
    tableName: 'category',
    primaryKeyName: 'id',
    primaryKeyType: PrimaryKeyType.integer_auto_incremental,
    useSoftDeleting: true,
    // when useSoftDeleting is true, creates a field named 'isDeleted' on the table, and set to '1' this field when item deleted (does not hard delete)
        null, // SqfEntity will set it to TableName automatically when the modelName (class name) is null
    // declare fields
    fields: [
      SqfEntityField('name', DbType.text),
      SqfEntityField('isActive', DbType.bool, defaultValue: true),

// Define the 'TableProduct' constant as SqfEntityTable.
const tableProduct = SqfEntityTable(
    tableName: 'product',
    primaryKeyName: 'id',
    primaryKeyType: PrimaryKeyType.integer_auto_incremental,
    useSoftDeleting: true,
    fields: [
      SqfEntityField('name', DbType.text),
      SqfEntityField('description', DbType.text),
      SqfEntityField('price', DbType.real, defaultValue: 0),
      SqfEntityField('isActive', DbType.bool, defaultValue: true),
          parentTable: tableCategory,
          deleteRule: DeleteRule.CASCADE,
          defaultValue: '0'), // Relationship column for CategoryId of Product
      SqfEntityField('rownum', DbType.integer,
              seqIdentity /*Example of linking a column to a sequence */),
      SqfEntityField('imageUrl', DbType.text)

// Define the 'Todo' constant as SqfEntityTable.
const tableTodo = SqfEntityTable(
    tableName: 'todos',
    primaryKeyName: 'id',
        false, // when useSoftDeleting is true, creates a field named 'isDeleted' on the table, and set to '1' this field when item deleted (does not hard delete)
    primaryKeyType: PrimaryKeyType.integer_unique,
        'https://jsonplaceholder.typicode.com/todos', // optional: to synchronize your table with json data from webUrl

    // declare fields
    fields: [
      SqfEntityField('userId', DbType.integer),
      SqfEntityField('title', DbType.text),
      SqfEntityField('completed', DbType.bool, defaultValue: false)

// Define the 'identity' constant as SqfEntitySequence.
const seqIdentity = SqfEntitySequence(
  sequenceName: 'identity',
  maxValue:  10000, /* optional. default is max int (9.223.372.036.854.775.807) */
  //modelName: 'SQEidentity', 
                      /* optional. SqfEntity will set it to sequenceName automatically when the modelName is null*/
  //cycle : false,    /* optional. default is false; */
  //minValue = 0;     /* optional. default is 0 */
  //incrementBy = 1;  /* optional. default is 1 */
  // startWith = 0;   /* optional. default is 0 */

// STEP 2: Create your Database Model constant instanced from SqfEntityModel
// Note: SqfEntity provides support for the use of multiple databases. So you can create many Database Models and use them in the application.
const myDbModel = SqfEntityModel(
    modelName: null,
    databaseName: 'sampleORM.db',
    // put defined tables into the tables list.
    databaseTables: [tableCategory, tableProduct, tableTodo],
    // put defined sequences into the sequences list.
    sequences: [seqIdentity],
        null // 'assets/sample.db' // This value is optional. When bundledDatabasePath is empty then EntityBase creats a new database when initializing the database

/* STEP 3: That's All.. 
--> Go Terminal Window and run command below
    flutter pub run build_runner build --delete-conflicting-outputs
  Note: After running the command Please check lib/model/model.g.dart 
  Enjoy.. Huseyin TOKPINAR

void main(List<String> args) async {
  // Run Entity Model samples
  // ATTENTION! when the software/app is started, you must check the database was it initialized.
  // If needed, initilizeDb method runs CREATE / ALTER TABLE query for you.
  final bool isInitialized = await MyDbModel().initializeDB();
  if (isInitialized == false) {
    // If the database is not initialized, something went wrong. Check DEBUG CONSOLE for alerts
    // TO DO

class MyDbModel extends SqfEntityModelProvider{

Use this package as a library

1. Depend on it

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

  sqfentity_gen: ^1.1.0+5

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or 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:sqfentity_gen/sqfentity_gen.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 Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21


Detected platforms: Flutter, other

Primary library: package:sqfentity_gen/sqfentity_gen.dart with components: io.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
build ^1.0.0 1.2.0
source_gen ^0.9.4+4 0.9.4+5
Transitive dependencies
analyzer 0.38.5
args 1.5.2
async 2.4.0
charcode 1.1.2
collection 1.14.12
convert 2.1.1
crypto 2.1.3
csslib 0.16.1
dart_style 1.3.1
front_end 0.1.27
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
kernel 0.3.27
logging 0.11.3+2
meta 1.1.7
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
path 1.6.4
pedantic 1.8.0+1
pub_semver 1.4.2
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+12
yaml 2.2.0