gpt4 book ai didi

构建运行器的 flutter 生成器问题

转载 作者:行者123 更新时间:2023-12-03 18:34:14 24 4
gpt4 key购买 nike

每当我尝试运行 flutter packages pub run build_runner watch 时,都会在终端中收到此错误消息

Failed to precompile build_runner:build_runner:
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/dart_style-1.3.3/lib/src/dart_formatter.dart:105:30: Error: Too
many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.
scanner.configureFeatures(featureSet);
^
pub finished with exit code 1
这发生在我从 ^1.6.0 => ^ 3.0.0 更新 moor_flutter 插件之后
旧插件没有错误
这是我的代码
import 'package:moor_flutter/moor_flutter.dart';
part 'Database.g.dart';
class Users extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get name => text().withLength(min:1,max:50)();
TextColumn get mobile => text().withLength(min:1,max:25)();
DateTimeColumn get birthdate => dateTime()();
}
@UseMoor(tables : [Users ],daos:[UserDao])
class AppDatabase extends _$AppDatabase {
AppDatabase():super(FlutterQueryExecutor.inDatabaseFolder(path: 'db.sqlite',
logStatements: true));

@override
int get schemaVersion =>1;
}
@UseDao(tables:[Users ],)
class UserDao extends DatabaseAccessor<AppDatabase> with _$UserDaoMixin{
final AppDatabase db;
UserDao(this.db):super(db);

Future <List<User>> getAllUsers() => select(users).get();
Stream <List<User>> watchAllUsers() {
return (select(users)
..orderBy([
(p)=> OrderingTerm(expression:p.id,mode:OrderingMode.desc ),
// (p)=> OrderingTerm(expression:p.id,mode:Ordering.desc )
])
)
.watch();

}
Stream <List<User>> watchUsersByName(String txt) {

String qu="SELECT * FROM users where ";
for (int i = 0; i < txt.length-1; i++){
String c = txt[i];
qu=qu+"name like '%"+c+"%' and ";
}
qu=qu+"name like '%"+txt[txt.length-1]+"%' ORDER BY id DESC";
return customSelectStream(
qu,readsFrom: {users}
).map((rows){
return rows.map((row) => User.fromData(row.data,db)).toList();
});

}


Future insertUser(Insertable<User> user) => into(users).insert(user);
Future updateUser(Insertable<User> user) => update(users).replace(user);
Future deleteUser(Insertable<User> user) => delete(users).delete(user);
}
vs 代码在 Appdatabase 构造函数和 customselectstream 函数中给了我错误,但是
我在他们的 Github 存储库中搜索了示例,发现 Appdatabase 构造函数与我的相同。
在我评论 watchusersbyname 后问题仍然存在,我也尝试从 Appdatabase 构造函数中的 super 中删除参数,但没有任何改变
所以你能告诉我有什么问题吗?
提前致谢。

最佳答案

这是您需要运行并检查解决方案的一个命令

flutter pub upgrade

关于构建运行器的 flutter 生成器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62700386/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com