askless 2.0.0 copy "askless: ^2.0.0" to clipboard
askless: ^2.0.0 copied to clipboard

Flutter client of Askless framework, which facilitates building realtime servers for JavaScript and Flutter Apps

Askless - Flutter client #

🏁 PortuguΓͺs (Portuguese)

Flutter client of Askless framework, which facilitates building realtime servers for JavaScript and Flutter Apps, Askless allows to:

  • 🀝 perform a websocket connection to exchange data that:

    • πŸ“³ supports streams on the client side in Flutter

    • πŸ’» supports JavaScript clients: Web and Node.js

    • β†ͺ️ it retries to send data automatically in case of connectivity issues between the client and the server

    • 🏷 handles multiples and identical listen requests from a client as a single one in the server

  • ✏️ create your own CRUD operations with any database you like (Create, Read, Update and Delete)

  • β›” restrict client access to CRUD operations

  • πŸ“£ notify in real-time clients who are listening for changes in a route, you can choose:

    • 🚷 only specify clients will receive the data

    • βœ”οΈ all clients will receive the data

  • πŸ”’ accept and deny connection attempts

This is the client side in Flutter, click here to access the server side in Node.js.

Getting Started #

Alt Text

The "Getting Started" is a example of the Flutter client, an example is executed locally.

1 - First create the server, click here and follow the server instructions in the section "Getting Started"

2 - To use an encrypted connection on a test environment such as this example (ws:// connection instead of wss://) follow these instructions. Do not apply this on a production environment

3 - Install

pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter
    
  # Add this line:
  askless: ^2.0.0

4 - Import the package

import 'package:askless/askless.dart';

5 - Initialize informing the server url with port (default: 3000). On the server side you can access the myAsklessServer.localUrl attribute to discover.

6 - Perform the connection with AsklessClient.instance.connect()

Example:

void main() {
  AsklessClient.instance.init(serverUrl:"ws://192.168.2.1:3000");
  AsklessClient.instance.connect();
  runApp(TrackingApp());
}    

7 - Copy and paste this template into build

@override
Widget build(BuildContext context) {
  return Scaffold(
      appBar: AppBar(
        title: Text("Tracking"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            //Show the status of the tracking in realtime
            // FIRST TODO

            SizedBox(height: 100,),

            //Send data to server with body as text: "I'm waiting"
            // SECOND TODO
           ],
        ),
      )
  );
}

8 - Replace FIRST TODO by a widget that listen in realtime a route in the server

AsklessClient.instance
    .listenAndBuild(
        route: 'product/tracking',
        builder: (context,  snapshot) {
            if(!snapshot.hasData)
                return Container();
            return Text(snapshot.data, style: _textStyle);
        }
    ),

Replace SECOND TODO by a button that send data to a route in the server

ElevatedButton(
    child: Text("I'm waiting", style: _textStyle,),
    onPressed: (){
         AsklessClient.instance
            .create(route: 'product/customerSaid', body: 'I\'m waiting')
            .then((res) => print(res.isSuccess ? 'Success' : res.error!.code));
    },
)

Project ready! You can run :)

Following these links, you can also check this "Getting Started" complete project of the Flutter client and of the server in Node.js.

Issues #

Feel free to open a issue about:

  • ❔ questions

  • πŸ’‘ suggestions

  • πŸ“„ documentation improvements

  • 🐜 potential bugs

License #

MIT

9
likes
100
pub points
77%
popularity

Publisher

verified publisherwisetap.com

Flutter client of Askless framework, which facilitates building realtime servers for JavaScript and Flutter Apps

Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (LICENSE)

Dependencies

collection, connectivity_plus, flutter, get_it, injectable, meta, random_string, synchronized, web_socket_channel

More

Packages that depend on askless