flutter_feathersjs 4.1.5 copy "flutter_feathersjs: ^4.1.5" to clipboard
flutter_feathersjs: ^4.1.5 copied to clipboard

Real-Time Flutter Apps, Powered by FeathersJS.

FlutterFeathersJs


FlutterFeathersJs



The road to the feathersjs headquarters https://feathersjs.com/



GitHub Repo stars pub version GitHub last commit GitHub license

FlutterFeathersJs is a Flutter package designed to simplify the development of real-time applications using the FeathersJS Node framework. It provides an intuitive API and seamless integration between Flutter and FeathersJS, empowering developers to build powerful and responsive real-time applications with ease.

Features #

  • Effortless Integration: Seamlessly connect your Flutter frontend with your FeathersJS backend using FlutterFeathersJs's simple and straightforward API.
  • Real-Time Communication: Utilize FeathersJS's real-time capabilities to create dynamic and interactive Flutter applications.
  • Authentication Support: Authenticate users using email/password or tokens, ensuring secure communication between your Flutter app and FeathersJS server.
  • Socket.io or REST Client: Choose between Socket.io or REST client to suit your project's needs and communication preferences.
  • Event Handling: Leverage FeathersJS's event-driven architecture to handle real-time events and updates efficiently.
  • Scalable and Reliable: Benefit from FeathersJS's scalability options and FlutterFeathersJs's robust design to build reliable real-time applications.

Installation #

To start using FlutterFeathersJs, add it to your project's pubspec.yaml file:

dependencies:
  flutter_feathersjs: ^latest_version

Replace latest_version with the latest version of FlutterFeathersJs available on pub.dev.

Then, run the following command in your project's root directory:

flutter pub get

Getting Started #

To get started with FlutterFeathersJs, follow these steps:

  1. Import the FlutterFeathersJs package into your Flutter project:

    import 'package:flutter_feathersjs/flutter_feathersjs.dart';
    
  2. Initialize FlutterFeathersJs as a single instance:

    const BASE_URL = "https://your-feathersjs-server.com";
    
    // Use tools like get_it to initialize FlutterFeathersJs globally across your app
    FlutterFeathersjs flutterFeathersjs = FlutterFeathersjs()..init(baseUrl: BASE_URL);
    
  3. Authenticate a user using email/password:

    var response = await flutterFeathersjs.authenticate(userName: user["email"], password: user["password"]);
    
    print(response);
    
  4. Re-authenticate with a token:

    var response = await flutterFeathersjs.reAuthenticate();
    print(response);
    
  5. Get the authenticated user:

    var response = await flutterFeathersjs.user();
    print(response);
    

For more detailed usage examples and API documentation, please refer to the FlutterFeathersJs documentation.

Configure and Use Socket.io or REST Client #

To configure and use either the Socket.io or REST client, follow the examples below:

Socket.io Client #

FlutterFeathersjs socketIOClient = FlutterFeathersjs();

IO.Socket io = IO.io(BASE_URL);

socketIOClient.configure(FlutterFeathersjs.socketioClient(io));

// Authenticate with Socket.io client
var response = await socketIOClient.authenticate(userName: user["email"], password: user["password"]);

print(response);

// Re-authenticate with Socket.io client
var reAuthResponse = await socketIOClient.reAuthenticate();

// Create a message using Socket.io standalone client
var ioResponse = await socketIOClient.service('messages').create({"text": 'A new message'});

// Get the authenticated user
var userResponse = await socketIOClient.user();

REST Client #

FlutterFeathersjs restClient = FlutterFeathersjs();

Dio dio = Dio(BaseOptions(baseUrl: BASE_URL));

restClient.configure(FlutterFeathersjs.restClient(dio));

// Authenticate user using REST client
var response = await restClient.authenticate(userName: user["email"], password: user["password"]);

print(response);

// Re-authenticate user using REST client
var reAuthResponse = await restClient.reAuthenticate();

// Call service using REST client
var restResponse = await restClient.service('messages').create({"text": 'A new message'});

// Get the authenticated user
var user = await restClient.user();

Contributing #

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please create a new issue on the issue tracker. Pull requests are also appreciated.

Before contributing, please review our contribution guidelines.

License #

This project is licensed under the MIT License.


If you find FlutterFeathersJs useful, consider giving it a star on GitHub and sharing it with your friends and colleagues. Happy coding!