xc_db_maker 1.0.7

  • Readme
  • Changelog
  • Example
  • Installing
  • 52

This package is use to create easily an instance of sqlite db and ready to use. Quick and easy to integrate

Get an xc Database instance #

    await Make.xcCreationTables(dbname: "dbname", listTables:listTables );
    Database _db = Make.db

Exambles #

    List<Tables> listTables = <Tables>[
      Tables(
          name: "client",
    
          columns: '''
              fullname TEXT NULL,
              city TEXT NULL,
              country TEXT NULL,
              address TEXT NULL
              '''
      ),
      Tables(
          name: "user",
          columns: '''
              login TEXT NULL,
              pwd TEXT NULL
              '''
      ),
      //....
    ];
    await Make.xcCreationTables(dbname: "dbname", listTables:listTables );
    
    //Create an entity

    class Client {
      final fullname;
      final city;
      final country;
      final address;
    
      Client({
        this.fullname,
        this.city ,
        this.country,
        this.address
      });
    
      Map<String, dynamic> toMap() {
    
        return {
          'fullname': fullname,
          'city': city,
          'country': country,
          'address': address,
        };
      }
    
      factory Client.fromJson(Map<String, dynamic> json) {
        return Client(
            fullname: json['fullname'],
            city: json['city'],
            country: json['country'],
            address: json['address']
        );
      }
    }

    //New client
    Client newClient  = Client(
        fullname: "TINA K. Arouna",
        city: "Abidjan",
        country: "Côte d'ivoire",
        address: "Cocody angré - xcodevs corporation"
      );
    
    make.db.insert('client',newClient.toMap())

Futures #

09 basiques functions in French and English version

  • xcAdd () or xcAjoute() : adding an entity
  • xcReadFirst() or xcLitPremier() : Read first row in table
  • xcReadLast() or xcLitDerneir() : Read last row in table
  • xcModify() or xcModifie() : Modify current entity
  • xcDelete() or xcSupprime() : Delete current entity
  • xcDeleteAll() or xcSupprimeTout() : Delete all entity
  • xcFind() or xcTrouve() : Seach in entity
  • xcReadNext() or xcLitSuivant() : Read next row
  • xcReadPrevious() or xcPrecedent() : Read previous row

[1.0.7] - 2020-03-23. #

  • Depending :
  • sqlite ^1.1.6
  • path_provider 1.6.5
  • path 1.6.4

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:xc_db_maker_example/app_db.dart';
import 'package:xc_db_maker_example/entities/client.dart';
import 'package:xc_db_maker_example/models/pdo_manager.dart';

void main() async{
  WidgetsFlutterBinding.ensureInitialized();
  await appDb.xcDBInit(); // Initialize and create in memory db
  runApp(MyApp());
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'xc b maker',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'XC DB Maker'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);


  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  EntityPdoManager entityPdoManager = EntityPdoManager.instance;
  Client newClient  = Client(
    fullname: "TINA K. Arouna",
    city: "Abidjan",
    country: "Côte d'ivoire",
    address: "Cocody angré - xcodevs corporation"
  );

  @override
  void initState() {
    appDb.onDbCloseCallback = _onDbClose;
    super.initState();
  }
  @override
  void dispose() {
    appDb.closeDb();
    super.dispose();
  }

  _onDbClose() async{
    print("DATABASE IS CLOSED");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(

          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'Smart db creator:',
            ),
            Padding(
              padding: EdgeInsets.all(15.0),
              child: MaterialButton(
                onPressed: (){
                  entityPdoManager.addClient(newClient);
                  debugPrint("Client added");
                },
                child: Text("Add Client"),
                color: Colors.blue,
              )
            ),
            Padding(
                padding: EdgeInsets.all(15.0),
                child: MaterialButton(
                  onPressed: (){
                    entityPdoManager.deleteAllClient();
                    debugPrint("Clients deleted");
                  },
                  child: Text("Delete all Client"),
                  color: Colors.blue,
                ),

            )
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  xc_db_maker: ^1.0.7

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:xc_db_maker/xc_db_maker.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
4
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
52
Learn more about scoring.

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

  • Dart: 2.8.2
  • pana: 0.13.8-dev
  • Flutter: 1.17.1

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
path ^1.6.4 1.7.0
path_provider ^1.6.5 1.6.9
sqflite ^1.1.6 1.3.0+2 1.3.1-dev.1
Transitive dependencies
collection 1.14.12
meta 1.1.8
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
platform 2.2.1
plugin_platform_interface 1.0.2
sky_engine 0.0.99
sqflite_common 1.0.1
synchronized 2.2.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test