|
1 | | -# :bird: flutter_feathersjs :bird: |
| 1 | +<div align="center"> |
| 2 | +<h1>FlutterFeathersJs</h1> |
| 3 | + <br> |
2 | 4 |
|
| 5 | + |
3 | 6 |
|
4 | | - :rocket: **We're are working on the next release of this Project: 🎯 Version 5.0.0* |
| 7 | + <br> <br> |
| 8 | +> |
| 9 | +> `The road to the feathersjs headquarters https://feathersjs.com/` |
| 10 | +> |
| 11 | +> |
| 12 | + <br> <br> |
| 13 | +</div> |
5 | 14 |
|
6 | | -See our roadmap here: https://github.com/Dahkenangnon/flutter_feathersjs.dart/issues/52 |
7 | | - |
8 | | ------------------- |
9 | 15 |
|
10 | 16 |
|
11 | 17 | [](https://github.com/dahkenangnon/flutter_feathersjs) |
12 | 18 | [](https://pub.dev/packages/flutter_feathersjs) |
13 | 19 | [](https://github.com/dahkenangnon/flutter_feathersjs) |
| 20 | +[](./LICENSE) |
| 21 | + |
14 | 22 |
|
15 | | -<p align="center"> |
16 | | - <br> |
17 | | - Communicate with your feathers js server from flutter app with unbelieved ease and make happy your customers. |
18 | | - <br><br><br> |
19 | | -`Feathers js is a node framework for real-time applications and REST APIs.` |
20 | | -</p> |
21 | 23 |
|
| 24 | +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. |
22 | 25 |
|
| 26 | +## Features |
23 | 27 |
|
24 | | -<br> |
| 28 | +- **Effortless Integration**: Seamlessly connect your Flutter frontend with your FeathersJS backend using FlutterFeathersJs's simple and straightforward API. |
| 29 | +- **Real-Time Communication**: Utilize FeathersJS's real-time capabilities to create dynamic and interactive Flutter applications. |
| 30 | +- **Authentication Support**: Authenticate users using email/password or tokens, ensuring secure communication between your Flutter app and FeathersJS server. |
| 31 | +- **Socket.io or REST Client**: Choose between Socket.io or REST client to suit your project's needs and communication preferences. |
| 32 | +- **Event Handling**: Leverage FeathersJS's event-driven architecture to handle real-time events and updates efficiently. |
| 33 | +- **Scalable and Reliable**: Benefit from FeathersJS's scalability options and FlutterFeathersJs's robust design to build reliable real-time applications. |
25 | 34 |
|
26 | | -## Simple to use |
| 35 | +## Installation |
27 | 36 |
|
28 | | -### 1. Install it |
| 37 | +To start using FlutterFeathersJs, add it to your project's `pubspec.yaml` file: |
29 | 38 |
|
30 | 39 | ```yaml |
31 | | -# Please see https://pub.dev/packages/flutter_feathersjs/install |
32 | | -flutter_feathersjs: ^lastest |
| 40 | +dependencies: |
| 41 | + flutter_feathersjs: ^latest_version |
33 | 42 | ``` |
34 | 43 |
|
35 | | -### 2. Import it |
| 44 | +Replace `latest_version` with the latest version of FlutterFeathersJs available on [pub.dev](https://pub.dev/packages/flutter_feathersjs). |
36 | 45 |
|
37 | | -```dart |
38 | | -// Import it |
39 | | -import 'package:flutter_feathersjs/flutter_feathersjs.dart'; |
| 46 | +Then, run the following command in your project's root directory: |
40 | 47 |
|
| 48 | +```bash |
| 49 | +flutter pub get |
41 | 50 | ``` |
42 | 51 |
|
43 | | -### 3. Initialize it as single instance |
| 52 | +## Getting Started |
44 | 53 |
|
45 | | -```dart |
| 54 | +To get started with FlutterFeathersJs, follow these steps: |
46 | 55 |
|
| 56 | +1. Import the FlutterFeathersJs package into your Flutter project: |
47 | 57 |
|
48 | | - //your api baseUrl |
49 | | - const BASE_URL = "https://your-feathersjs-server.com"; |
| 58 | + ```dart |
| 59 | + import 'package:flutter_feathersjs/flutter_feathersjs.dart'; |
| 60 | + ``` |
50 | 61 |
|
51 | | - // Init it globally across your app, maybe with get_it or something like that |
52 | | - FlutterFeathersjs flutterFeathersjs = FlutterFeathersjs()..init(baseUrl: BASE_URL); |
| 62 | +2. Initialize FlutterFeathersJs as a single instance: |
53 | 63 |
|
54 | | - // Authenticate with email/password |
55 | | - var response = await flutterFeathersjs.authenticate(userName: user["email"], password: user["password"]); |
56 | | - print(response); |
| 64 | + ```dart |
| 65 | + const BASE_URL = "https://your-feathersjs-server.com"; |
57 | 66 |
|
58 | | - // ReAuthenticated with token |
59 | | - var response = await flutterFeathersjs.reAuthenticate(); |
60 | | - print(response); |
| 67 | + // Use tools like get_it to initialize FlutterFeathersJs globally across your app |
| 68 | + FlutterFeathersjs flutterFeathersjs = FlutterFeathersjs()..init(baseUrl: BASE_URL); |
| 69 | + ``` |
61 | 70 |
|
62 | | - // Get authenticated user |
63 | | - var response = await flutterFeathersjs.user(); |
| 71 | +3. Authenticate a user using email/password: |
64 | 72 |
|
65 | | -``` |
| 73 | + ```dart |
| 74 | + var response = await flutterFeathersjs.authenticate(userName: user["email"], password: user["password"]); |
| 75 | +
|
| 76 | + print(response); |
| 77 | + ``` |
| 78 | + |
| 79 | +4. Re-authenticate with a token: |
| 80 | + |
| 81 | + ```dart |
| 82 | + var response = await flutterFeathersjs.reAuthenticate(); |
| 83 | + print(response); |
| 84 | + ``` |
| 85 | + |
| 86 | +5. Get the authenticated user: |
| 87 | + |
| 88 | + ```dart |
| 89 | + var response = await flutterFeathersjs.user(); |
| 90 | + print(response); |
| 91 | + ``` |
66 | 92 |
|
67 | | -### 4. Configure and use only socketio or rest client |
| 93 | +For more detailed usage examples and API documentation, please refer to the [FlutterFeathersJs documentation](https://pub.dev/documentation/flutter_feathersjs/latest/). |
68 | 94 |
|
| 95 | +## Configure and Use Socket.io or REST Client |
| 96 | + |
| 97 | +To configure and use either the Socket.io or REST client, follow the examples below: |
| 98 | + |
| 99 | +### Socket.io Client |
69 | 100 |
|
70 | 101 | ```dart |
| 102 | +FlutterFeathersjs socketIOClient = FlutterFeathersjs(); |
71 | 103 |
|
72 | | - // Standalone socket io client |
73 | | - FlutterFeathersjs socketIOClient = FlutterFeathersjs(); |
| 104 | +IO.Socket io = IO.io(BASE_URL); |
74 | 105 |
|
75 | | - // Socket.io client |
76 | | - IO.Socket io = IO.io(BASE_URL); |
77 | | - socketIOClient.configure(FlutterFeathersjs.socketioClient(io)); |
| 106 | +socketIOClient.configure(FlutterFeathersjs.socketioClient(io)); |
78 | 107 |
|
79 | | - // Auth socketio client |
| 108 | +// Authenticate with Socket.io client |
| 109 | +var response = await socketIOClient.authenticate(userName: user["email"], password: user["password"]); |
80 | 110 |
|
81 | | - var response = await socketIOClient.authenticate(userName: user["email"], password: user["password"]); |
82 | | - print(response); |
| 111 | +print(response); |
83 | 112 |
|
84 | | - // ReAuth socketio client |
85 | | - var reAuthResponse = await socketIOClient.reAuthenticate(); |
86 | | - |
87 | | - // Create a message using socketio standalone client |
88 | | - var ioResponse = await socketIOClient.service('messages').create({"text": 'A new message'}); |
| 113 | +// Re-authenticate with Socket.io client |
| 114 | +var reAuthResponse = await socketIOClient.reAuthenticate(); |
89 | 115 |
|
90 | | - // Get the authenticated user |
91 | | - var userResponse = await socketIOClient.user(); |
| 116 | +// Create a message using Socket.io standalone client |
| 117 | +var ioResponse = await socketIOClient.service('messages').create({"text": 'A new message'}); |
92 | 118 |
|
| 119 | +// Get the authenticated user |
| 120 | +var userResponse = await socketIOClient.user(); |
93 | 121 | ``` |
94 | 122 |
|
95 | | -```dart |
96 | 123 |
|
97 | | - //StandAlone rest client |
98 | | - FlutterFeathersjs restClient = FlutterFeathersjs(); |
99 | | - Dio dio = Dio(BaseOptions(baseUrl: BASE_URL)); |
100 | | - restClient.configure(FlutterFeathersjs.restClient(dio)); |
101 | 124 |
|
| 125 | +### REST Client |
| 126 | + |
| 127 | +```dart |
| 128 | +FlutterFeathersjs restClient = FlutterFeathersjs(); |
102 | 129 |
|
103 | | - // Authenticate user using rest client |
104 | | - var response = await restClient.authenticate( userName: user["email"], password: user["password"]); |
105 | | - print(response); |
| 130 | +Dio dio = Dio(BaseOptions(baseUrl: BASE_URL)); |
106 | 131 |
|
107 | | - // Reauthenticate user using rest client |
108 | | - var reAuthResponse = await restClient.reAuthenticate(); |
| 132 | +restClient.configure(FlutterFeathersjs.restClient(dio)); |
109 | 133 |
|
110 | | - // Call service |
111 | | - var restResponse = await restClient.service('messages').create({"text": 'A new message'}); |
| 134 | +// Authenticate user using REST client |
| 135 | +var response = await restClient.authenticate(userName: user["email"], password: user["password"]); |
112 | 136 |
|
| 137 | +print(response); |
113 | 138 |
|
114 | | - // Get the authenticated user |
115 | | - var user = await restClient.user(); |
| 139 | +// Re-authenticate user using REST client |
| 140 | +var reAuthResponse = await restClient.reAuthenticate(); |
116 | 141 |
|
| 142 | +// Call service using REST client |
| 143 | +var restResponse = await restClient.service('messages').create({"text": 'A new message'}); |
117 | 144 |
|
| 145 | +// Get the authenticated user |
| 146 | +var user = await restClient.user(); |
118 | 147 | ``` |
119 | 148 |
|
120 | | -**You're ready to go: 3, 2, 1 :rocket:** |
| 149 | +## Contributing |
121 | 150 |
|
122 | | -## Support |
| 151 | +Contributions are welcome! If you encounter any issues or have suggestions for improvements, please create a new issue on the [issue tracker](https://github.com/Dahkenangnon/flutter_feathersjs.dart/issues). Pull requests are also appreciated. |
123 | 152 |
|
124 | | -Please email to **dah.kenangnon (at) gmail (dot) com** if you have any questions or comments or business support. |
| 153 | +Before contributing, please review our [contribution guidelines](CONTRIBUTING.md). |
125 | 154 |
|
126 | | -## Contributing |
| 155 | +## License |
| 156 | + |
| 157 | +This project is licensed under the [MIT License](LICENSE). |
| 158 | + |
| 159 | +--- |
127 | 160 |
|
128 | | -Please feel free to contribute to this project by opening an issue or creating a pull request. |
| 161 | +If you find FlutterFeathersJs useful, consider giving it a star on [GitHub](https://github.com/Dahkenangnon/flutter_feathersjs.dart) and sharing it with your friends and colleagues. Happy coding! |
0 commit comments