android 谁能帮我在Flutter中使用sql_conn包

mnowg1ta  于 2023-09-29  发布在  Android
关注(0)|答案(1)|浏览(113)

正在尝试连接到静态IP数据库。但在初始化im得到这个错误
错误代码:

flutter: Connection failed: MissingPluginException(No implementation found for method connectDB on channel plugin.sqlconn.sql_conn/sql_conn)
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method disconnectDB on channel plugin.sqlconn.sql_conn/sql_conn)

请注意,我已经尝试过Flutter清洁和强迫Flutter软件包得到
整个代码如下,用于测试连接

import 'package:flutter/material.dart';
import 'package:sql_conn/sql_conn.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
title: "Test",
home: TestPage(),
);
}
}

class TestPage extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Plugin example app'),
),
body: Center(
child: ElevatedButton(
onPressed: () async {
await connect(context);
},
child: Text("Connect"),
),
),
);
}

Future connect(BuildContext ctx) async {
try {
await SqlConn.connect(
ip: "ip_add",
port: "1443",
databaseName: "TEST",
username: "u_id",
password: "pwd",
);
print("Connected!");
} catch (e) {
print("Connection failed: $e");
} finally {
SqlConn.disconnect();
}
}
}
bkhjykvo

bkhjykvo1#

我重新创建了这个项目,并在sql_conn的build.gradle中更新了Kotlin版本,它对我很有效

相关问题