unruffled_feathersjs

Creator: coderz1093

Last updated:

0 purchases

unruffled_feathersjs Image
unruffled_feathersjs Images
Add to Cart

Description:

unruffled feathersjs

Unruffled x FeathersJS #
unruffled_feathersjs is feathersjs client for Flutter that manages offline by default.
Quick start #
1. Add to pubspec.yaml #
dependencies:
json_annotation: ^4.5.0
unruffled_feathersjs: ^1.5.0

dev_dependencies:
build_runner: any
json_serializable: ^6.2.0
unruffled_generator: ^1.2.0
copied to clipboard
NOTE : Unruffled relies to json_annotation and json_serializable to work as expected, please ensure to add theme in your dependencies.
2. Declare models #
Declare models used by your remote service and generate Unruffled adapters.
@UnruffledFeathersJsData()
@JsonSerializable()
class User extends DataModel<User> {
@override
@JsonKey(name: '_id') // e.g MongoDB item has '_id' as unique identifier
int? id;

String name;

String surname;

int age;

User({super.key, this.id, required this.name, required this.surname, required this.age});
}
copied to clipboard
Build your flutter directory to generate a UserAdapter()
flutter pub run build_runner build
NOTE: Your class must construct a String? key and Object? id and pass it to super();

id refers to your remote object ID\
key refers to your local object ID generated by unruffled

3. Register adapters #
For all platforms except web, use path_provider to generate a directory path.
final dir = await getApplicationSupportDirectory(); // path_provider package
var unruffled = UnruffledFeathersJs(
baseDirectory: dir,
defaultBaseUrl: 'http://example.com',
)
.registerRepository(UserRepository());
copied to clipboard
4. Initialize Unruffled #
Before using Unruffled, ensure to initialize it.
await unruffled.init();
copied to clipboard
🚀 That's it, you're ready to go !
Usage #
unruffled_feathersjs provides default authenticate & refresh token methods, override it if needed.
1. Authenticate #
final data = {
"email": "[email protected]",
"password": "test123",
"strategy": "local",
};
Map<String, dynamic> result = await unruffled.authenticate(body: data);
copied to clipboard
By default, unruffled_feathersjs use DefaultTokenStorageImpl() and manage automatically to save access token and pass it in an Authorization header.
For more complex cases, you can create mixin on UnruffledFeathersJs or add Dio interceptors.
2. Other #
unruffled_feathersjs extends unruffled, for more documentation check the package unruffled

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.