Я пытаюсь мур (flutter sqflite builder), я слежу за документами, но у меня не работает, пожалуйста, помогите, если кто-нибудь реализовал. Пин это название таблицы. Просьба помочь, спасибо заранее Ошибка:
{
"resource": "/D:/my project/snapexpenses/lib/Database/moor_database.dart",
"owner": "dart",
"code": "undefined_identifier",
"severity": 8,
"message": "Undefined name 'pins'.\nTry correcting the name to one that is defined, or defining the name.",
"source": "dart",
"startLineNumber": 42,
"startColumn": 55,
"endLineNumber": 42,
"endColumn": 59,
"tags": []
}
например код здесь
import 'dart:io';
import 'package:moor/moor.dart';
import 'package:moor_ffi/moor_ffi.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart' as p;
part 'moor_database.g.dart';
class Expenses extends Table{
IntColumn get id => integer().autoIncrement()();
TextColumn get name => text().withLength(min: 1, max: 180)();
DateTimeColumn get createdAt => dateTime().nullable()();
}
class Pin extends Table{
IntColumn get id => integer().autoIncrement()();
TextColumn get name => text().withLength(min: 4)();
DateTimeColumn get createdAt => dateTime().nullable()();
}
LazyDatabase _openConnection() {
// the LazyDatabase util lets us find the right location for the file async.
return LazyDatabase(() async {
// put the database file, called db.sqlite here, into the documents folder
// for your app.
final dbFolder = await getApplicationDocumentsDirectory();
final file = File(p.join(dbFolder.path, 'db.sqlite'));
return VmDatabase(file,logStatements: true);
});
}
// tables we just defined. We'll see how to use that database class in a moment.
@UseMoor(tables: [Pin])
class SnapexpensesDatabase extends _$SnapexpensesDatabase {
// we tell the database where to store the data with this constructor
SnapexpensesDatabase() : super(_openConnection());
// you should bump this number whenever you change or add a table definition. Migrations
// are covered later in this readme.
@override
int get schemaVersion => 1;
Future insertTask(Insertable<PinData> pin) => into(pins).insert(pin);
}
pubspe c .yml файл
dependencies:
flutter:
sdk: flutter
moor: 2.2.0 # use the latest version
moor_ffi: 0.3.1 # use the latest version
path_provider: 1.5.1
path: 1.6.4
flutter_slidable: ^0.5.3
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
moor_generator: 2.2.0 # use the latest version
build_runner: