Marco
a52a50d4d1
Persist theme in sqlite database. A new table was created for this. Add migration to add table for persisted theme
358 lines
11 KiB
Dart
358 lines
11 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
part of 'database.dart';
|
|
|
|
// ignore_for_file: type=lint
|
|
class $PersistentNoteTable extends PersistentNote
|
|
with TableInfo<$PersistentNoteTable, PersistentNoteData> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$PersistentNoteTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<String> id = GeneratedColumn<String>(
|
|
'id', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _contentMeta =
|
|
const VerificationMeta('content');
|
|
@override
|
|
late final GeneratedColumn<String> content = GeneratedColumn<String>(
|
|
'content', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
@override
|
|
List<GeneratedColumn> get $columns => [id, content];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'persistent_note';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<PersistentNoteData> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_idMeta);
|
|
}
|
|
if (data.containsKey('content')) {
|
|
context.handle(_contentMeta,
|
|
content.isAcceptableOrUnknown(data['content']!, _contentMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_contentMeta);
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => const {};
|
|
@override
|
|
PersistentNoteData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return PersistentNoteData(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}id'])!,
|
|
content: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}content'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$PersistentNoteTable createAlias(String alias) {
|
|
return $PersistentNoteTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class PersistentNoteData extends DataClass
|
|
implements Insertable<PersistentNoteData> {
|
|
final String id;
|
|
final String content;
|
|
const PersistentNoteData({required this.id, required this.content});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<String>(id);
|
|
map['content'] = Variable<String>(content);
|
|
return map;
|
|
}
|
|
|
|
PersistentNoteCompanion toCompanion(bool nullToAbsent) {
|
|
return PersistentNoteCompanion(
|
|
id: Value(id),
|
|
content: Value(content),
|
|
);
|
|
}
|
|
|
|
factory PersistentNoteData.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return PersistentNoteData(
|
|
id: serializer.fromJson<String>(json['id']),
|
|
content: serializer.fromJson<String>(json['content']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<String>(id),
|
|
'content': serializer.toJson<String>(content),
|
|
};
|
|
}
|
|
|
|
PersistentNoteData copyWith({String? id, String? content}) =>
|
|
PersistentNoteData(
|
|
id: id ?? this.id,
|
|
content: content ?? this.content,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('PersistentNoteData(')
|
|
..write('id: $id, ')
|
|
..write('content: $content')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(id, content);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is PersistentNoteData &&
|
|
other.id == this.id &&
|
|
other.content == this.content);
|
|
}
|
|
|
|
class PersistentNoteCompanion extends UpdateCompanion<PersistentNoteData> {
|
|
final Value<String> id;
|
|
final Value<String> content;
|
|
final Value<int> rowid;
|
|
const PersistentNoteCompanion({
|
|
this.id = const Value.absent(),
|
|
this.content = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
});
|
|
PersistentNoteCompanion.insert({
|
|
required String id,
|
|
required String content,
|
|
this.rowid = const Value.absent(),
|
|
}) : id = Value(id),
|
|
content = Value(content);
|
|
static Insertable<PersistentNoteData> custom({
|
|
Expression<String>? id,
|
|
Expression<String>? content,
|
|
Expression<int>? rowid,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (content != null) 'content': content,
|
|
if (rowid != null) 'rowid': rowid,
|
|
});
|
|
}
|
|
|
|
PersistentNoteCompanion copyWith(
|
|
{Value<String>? id, Value<String>? content, Value<int>? rowid}) {
|
|
return PersistentNoteCompanion(
|
|
id: id ?? this.id,
|
|
content: content ?? this.content,
|
|
rowid: rowid ?? this.rowid,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<String>(id.value);
|
|
}
|
|
if (content.present) {
|
|
map['content'] = Variable<String>(content.value);
|
|
}
|
|
if (rowid.present) {
|
|
map['rowid'] = Variable<int>(rowid.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('PersistentNoteCompanion(')
|
|
..write('id: $id, ')
|
|
..write('content: $content, ')
|
|
..write('rowid: $rowid')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $PersistentThemeTable extends PersistentTheme
|
|
with TableInfo<$PersistentThemeTable, PersistentThemeData> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$PersistentThemeTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _brightnessMeta =
|
|
const VerificationMeta('brightness');
|
|
@override
|
|
late final GeneratedColumn<String> brightness = GeneratedColumn<String>(
|
|
'brightness', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant("dark"));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [brightness];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'persistent_theme';
|
|
@override
|
|
VerificationContext validateIntegrity(
|
|
Insertable<PersistentThemeData> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('brightness')) {
|
|
context.handle(
|
|
_brightnessMeta,
|
|
brightness.isAcceptableOrUnknown(
|
|
data['brightness']!, _brightnessMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => const {};
|
|
@override
|
|
PersistentThemeData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return PersistentThemeData(
|
|
brightness: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}brightness'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$PersistentThemeTable createAlias(String alias) {
|
|
return $PersistentThemeTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class PersistentThemeData extends DataClass
|
|
implements Insertable<PersistentThemeData> {
|
|
final String brightness;
|
|
const PersistentThemeData({required this.brightness});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['brightness'] = Variable<String>(brightness);
|
|
return map;
|
|
}
|
|
|
|
PersistentThemeCompanion toCompanion(bool nullToAbsent) {
|
|
return PersistentThemeCompanion(
|
|
brightness: Value(brightness),
|
|
);
|
|
}
|
|
|
|
factory PersistentThemeData.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return PersistentThemeData(
|
|
brightness: serializer.fromJson<String>(json['brightness']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'brightness': serializer.toJson<String>(brightness),
|
|
};
|
|
}
|
|
|
|
PersistentThemeData copyWith({String? brightness}) => PersistentThemeData(
|
|
brightness: brightness ?? this.brightness,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('PersistentThemeData(')
|
|
..write('brightness: $brightness')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => brightness.hashCode;
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is PersistentThemeData && other.brightness == this.brightness);
|
|
}
|
|
|
|
class PersistentThemeCompanion extends UpdateCompanion<PersistentThemeData> {
|
|
final Value<String> brightness;
|
|
final Value<int> rowid;
|
|
const PersistentThemeCompanion({
|
|
this.brightness = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
});
|
|
PersistentThemeCompanion.insert({
|
|
this.brightness = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
});
|
|
static Insertable<PersistentThemeData> custom({
|
|
Expression<String>? brightness,
|
|
Expression<int>? rowid,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (brightness != null) 'brightness': brightness,
|
|
if (rowid != null) 'rowid': rowid,
|
|
});
|
|
}
|
|
|
|
PersistentThemeCompanion copyWith(
|
|
{Value<String>? brightness, Value<int>? rowid}) {
|
|
return PersistentThemeCompanion(
|
|
brightness: brightness ?? this.brightness,
|
|
rowid: rowid ?? this.rowid,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (brightness.present) {
|
|
map['brightness'] = Variable<String>(brightness.value);
|
|
}
|
|
if (rowid.present) {
|
|
map['rowid'] = Variable<int>(rowid.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('PersistentThemeCompanion(')
|
|
..write('brightness: $brightness, ')
|
|
..write('rowid: $rowid')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
abstract class _$AppDatabase extends GeneratedDatabase {
|
|
_$AppDatabase(QueryExecutor e) : super(e);
|
|
late final $PersistentNoteTable persistentNote = $PersistentNoteTable(this);
|
|
late final $PersistentThemeTable persistentTheme =
|
|
$PersistentThemeTable(this);
|
|
@override
|
|
Iterable<TableInfo<Table, Object?>> get allTables =>
|
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
@override
|
|
List<DatabaseSchemaEntity> get allSchemaEntities =>
|
|
[persistentNote, persistentTheme];
|
|
}
|