sql_conn 0.0.2 sql_conn: ^0.0.2 copied to clipboard
Plugin for connecting Flutter Android application to SQL Server. Easily read data from SQL Database. Perform CURD as well as many other operation on database using this plugin.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:sql_conn/sql_conn.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
Future<void> connect() async {
await SqlConn.connect(
ip: "192.168.167.176",
port: "1433",
databaseName: "MDCData",
username: "AS",
password: "112233");
}
Future<void> read(String query) async {
var res = await SqlConn.readData(query);
debugPrint(res.toString());
}
Future<void> write(String query) async {
var res = await SqlConn.writeData(query);
debugPrint(res.toString());
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () => connect(), child: const Text("Connect")),
ElevatedButton(
onPressed: () => read("SELECT * FROM IP_List"),
child: const Text("Read")),
ElevatedButton(
onPressed: () =>
write("DELETE FROM IP_List WHERE LOC='vv1'"),
child: const Text("Write")),
ElevatedButton(
onPressed: () => SqlConn.disconnect(),
child: const Text("Disconnect"))
],
),
)),
);
}
}