Last updated:
0 purchases
future server
Future Server #
Please note you must read get_server guide to continue
Getting Started #
Installing
Add Get to your pubspec.yaml file:
run dart create project and add to your pubspec:
dependencies:
future_get_server:
copied to clipboard
Import future_server in files that it will be used:
import 'package:future_get_server/future_server.dart';
copied to clipboard
Future Server #
What if you want to make the server wait untill you get the data from somewhere like firebase or MYSQL ?
Let me show you ..
First define yout Future, But make sure it will return a String
To create a server, and send a plain text:
void main() {
runApp(
FutureServer(
home: Home(),
),
);
}
copied to clipboard
Let's create a controller
class HomeController extends GetxController {}
copied to clipboard
and then define yout Future and make sure it will return a String
Future<String> getData() async {
return Future.delayed(Duration(seconds: 3), () => 'Done');
}
copied to clipboard
and just put FutureWidget and now you have a perfect server
class HomeView extends GetView<HomeController> {
@override
Widget build(BuildContext context) {
return FutureWidget(controller.getData());
}
}
copied to clipboard
Now the server will return a 'Done' after 3 seconds.
But what if you want to use MSQL
first you need to define settings
final dbSettings = ConnectionSettings(
host: 'localhost',
port: 3306,
user: 'test',
password: 'testpassowrd',
db: 'test1');
final futureMYSQL = FutureMYSQL(dbsettings: dbSettings);
copied to clipboard
if you wonder how to use it .. here is it
var fetch = await futureMYSQL.futureFetch(fields: [], table: 'users');
copied to clipboard
This will fetch a fields in table users
you can select fields by add them to the list --> futureMYSQL.futureFetch(fields: ['username','email'], table: 'users');
You can also fetch user where id
var results = await futureMYSQL.futureFetchWhere(
fields: [],
whereFields: ['id'],
table: 'profiles',
whereFieldsValues: ['1'],
);
copied to clipboard
Please read get_server guide to understand what we are talking about
https://pub.dev/packages/get_server#
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.