lessql 0.0.1-alpha

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 69

LesSQL

LesSQL is a flutter plugin for sqlite.

Getting started

1.Import LesSQL

import 'package:lessql/lessql.dart';

2.Init databse

Define DB

class FooDB extends LesDB{

  @override
  String getName() {
    return 'foo_db';
  }

  @override
  int getVersion() {
    return 1;
  }

}

Define table

class FooTable1 extends LesTable{

  @override
  List<String> getColumnNames() {
    return ['c1','c2','c3','c4'];
  }

  @override
  List<String> getColumnTypes() {
    return [Contract.TYPE_NUMBER,Contract.TYPE_NUMBER,Contract.TYPE_NUMBER,Contract.TYPE_NUMBER,];
  }

  @override
  String getTableName() {
    return 'table1';
  }
  @override
  List<int> getPrimaryColumnIndexes() {
    return [1];
  }

  @override
  String getAutoIncrementID(){
    return "id";
  }
}

Init database

LesSQL.initLesDB(new FooDB(), [new FooTable1(),new FooTable2()]);

Insert

LesTable and LesEntity must correspond one-to-one

class FooEntity1 extends LesEntity{

  String c1;
  int c2;
  int c3;
  int c4;

  FooEntity1(this.c1,this.c2,this.c3,this.c4);

  @override
  List getValues() {
    return [c1,c2,c3,c4];
  }
}

Random random = new Random();
FooEntity1 entity1 = new FooEntity1(random.nextInt(10000).toString(),
                     random.nextInt(10000), 
                     random.nextInt(10000), 
                     random.nextInt(10000));
LesSQL.insert(new FooTable1(), entity1.getValues()).then(_updateDes);

License

   Copyright 2017 Qinglian.Zhang

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

[0.0.1-alpha] - In developing.

  • In developing.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:lessql/lessql.dart';
import 'dart:math';


class FooDB extends LesDB{

  @override
  String getName() {
    return 'foo_db';
  }

  @override
  int getVersion() {
    return 1;
  }

}

class FooTable1 extends LesTable{

  @override
  List<String> getColumnNames() {
    return ['c1','c2','c3','c4'];
  }

  @override
  List<String> getColumnTypes() {
    return [Contract.TYPE_STRING,Contract.TYPE_NUMBER,Contract.TYPE_NUMBER,Contract.TYPE_NUMBER,];
  }

  @override
  String getTableName() {
    return 'table1';
  }
  @override
  int getPrimaryColumnIndex() {
    return -1;
  }

  @override
  String getAutoIncrementID(){
    return "id";
  }
}

class FooEntity1 extends LesEntity{

  String c1;
  int c2;
  int c3;
  int c4;

  FooEntity1(this.c1,this.c2,this.c3,this.c4);

  @override
  List getValues() {
    return [c1,c2,c3,c4];
  }
}

class FooTable2 extends LesTable{

  @override
  List<String> getColumnNames() {
    return ['c1','c2',];
  }

  @override
  List<String> getColumnTypes() {
    return [Contract.TYPE_NUMBER,Contract.TYPE_STRING];
  }

  @override
  String getTableName() {
    return 'table2';
  }

  @override
  int getPrimaryColumnIndex() {
    return 0;
  }

  @override
  String getAutoIncrementID(){
    return "";
  }
}

void main() {
  runApp(new MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> implements LesSQLCallback{

  String des = "no opration";
  String ip = "";
  @override
  initState() {
    super.initState();
    LesSQL.initSelf(this);
    LesSQL.initLesDB(new FooDB(), [new FooTable1(),new FooTable2()]).then(_updateDes);
    _updateIP("确保你的手机和电脑连接同意路由器");
  }

  _insert(){
    Random random = new Random();
    FooEntity1 entity1 = new FooEntity1(random.nextInt(10000).toString(), random.nextInt(10000), random.nextInt(10000), random.nextInt(10000));
    LesSQL.insert(new FooTable1(), entity1.getValues()).then(_updateDes);
  }

  _updateDes(String str){
    setState(()=>des = str);
  }
  
  _updateIP(String str){
    setState(()=>ip = str);
  }
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin example app')
        ),
        body: new Center(
          child: new Column(children: <Widget>[
            new Text(ip,style: new TextStyle(fontSize: 20.0,color:Colors.black),),
            new Text(des),
            new RaisedButton(onPressed: _insert, child:  new Text("insert",style: new TextStyle(color: Colors.black,fontSize: 20.0),))
          ],)
        )
      )
    );
  }
  @override
  initDBIP(String ipAddress) {
    _updateIP(ipAddress);
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  lessql: "^0.0.1-alpha"

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


      import 'package:lessql/lessql.dart';
  
Version Uploaded Documentation Archive
0.0.1-alpha Sep 30, 2017 Go to the documentation of lessql 0.0.1-alpha Download lessql 0.0.1-alpha archive

Analysis

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

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
43 / 100
Health:
Code health derived from static analysis. [more]
95 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
98 / 100
Overall score:
Weighted score of the above. [more]
69
Learn more about scoring.

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

  • Package is pre-release.

    Pre-release versions should be used with caution, their API may change in breaking ways.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 4 hints.

    Run flutter format to format lib/db/db.dart.

    Run flutter format to format lib/lessql.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.10
meta 1.1.5
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7