我正在尝试停泊(sqflite builder),我正在关注文档但不为我工作,如果有人实施请帮忙

I m trying moor (sqflite builder), I m following documents but not working for me, pls help if anyone implemented

我正在尝试 moor (flutter sqflite builder),我正在关注文档但不适合我,如果有人实施请帮忙。 引脚是 table 的名称。请帮忙,提前谢谢 错误:

{
    "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);
} 

pubspec.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:

您需要在 Table 定义中将 Pin 替换为 Pins :

class Pins extends Table {
    IntColumn get id => integer().autoIncrement()();
    TextColumn get name => text().withLength(min: 4)();
    DateTimeColumn get createdAt => dateTime().nullable()();
}

这将创建一个名为 Pin 的数据 class(不同于 table class Pins),您可以这样使用它:

@UseMoor(tables: [Pins])    // <-- Use Pins class here
class SnapexpensesDatabase extends _$SnapexpensesDatabase {
    SnapexpensesDatabase() : super(_openConnection());

    @override
    int get schemaVersion => 1;

    Future<int> insertTask(Pin pin) => into(pins).insert(pin);
}