0

im tying to connect to my mysql database using mysql1 package, i've tried sqljocky as well, but both of them dont work. I get error Error: Unsupported operation: RawSocket constructor my code is exactly like in example, heres my code, maybe youll see what im doing wrong.

import 'package:mysql1/mysql1.dart';

class Database {

  static var s = ConnectionSettings(
    user: "user",
    password: "password",
    host: "host",
    port: 3306,
    db: "db",
  );

static Future<MySqlConnection> connect() async{
  return await MySqlConnection.connect(s);

}}
1
  • Does your code work on the Android emulator? I get a similar message when I use the web browser to access mysql but it works fine on Android. I think for host you should used either 'local host' or '10.0.2.2' for emulator Commented Mar 26, 2021 at 11:52

1 Answer 1

1

Unfortunately, mysql1 does not support web: https://github.com/adamlofts/mysql1_dart#flutter-web

I think in general, a web application would be better off using a REST-API approach, since you don't want to expose your SQL credentials in the Frontend.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.