UnitType enum

Inheritance

Constructors

UnitType()
const

Values

TEXT → const UnitType

SQLite type: TEXT Dart type: String

NUMERIC → const UnitType

Not Support in this.

INTEGER → const UnitType

SQLite type: INTEGER Dart type: int Supported values: from -2^63 to 2^63 - 1

REAL → const UnitType

SQLite type: REAL Dart type: num

BLOB → const UnitType

SQLite typ: BLOB Dart type: Uint8List

On Android blob lookup does not work when using Uint8List as dart type in a query such as:

final id = Uint8List.fromList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
await db.insert('test', {'id': id, 'value': 1});
var result = await db.query('test', where: 'id = ?', whereArgs: [id]);

This would lead to an empty result on Android. Native implementation can not handle this in a proper way. The solution is to use the hex() SQLite function.

import 'package:sqflite_common/utils/utils.dart' as utils;

result = await db.query('test', where: 'hex(id) = ?', whereArgs: [utils.hex(id)]);
final db = await openDatabase(
  inMemoryDatabasePath,
  version: 1,
  onCreate: (db, version) async {
    await db.execute(
      'CREATE TABLE test (id BLOB, value INTEGER)',
    );
  },
);
final id = Uint8List.fromList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
await db.insert('test', {'id': id, 'value': 1});
var result = await db.query('test', where: 'id = ?', whereArgs: [id]);
print('regular blob lookup (failing on Android)): $result');

// The compatible way to lookup for BLOBs (even work on Android) using the hex function
result = await db.query('test', where: 'hex(id) = ?', whereArgs: [utils.hex(id)]);
print('correct blob lookup: $result');

expect(result.first['value'], 1);

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

values → const List<UnitType>
A constant List of the values in this enum, in order of their declaration.