response_x 1.0.0 copy "response_x: ^1.0.0" to clipboard
response_x: ^1.0.0 copied to clipboard

outdated

library for exchanging response between server and client. it can be a useful tool for standardizing the way that a server communicates with its clients.

response_x #

pub package License: MIT library for exchanging response JSON between server and client. it can be a useful tool for standardizing the way that a server communicates with its clients.

Installing #

1. Depend on it #

Add this to your package's pubspec.yaml file:

dependencies:
  response_x: 1.0.0

2. Install it #

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

3. Import it #

Now in your Flutter code, you can use:

import 'package:response_x/response_x.dart';

4. Getting Started #

Import the library.

import 'package:response_x/response_x.dart';
final response = Response.success();
print(response.statusCode); // 200
print(response.message); // OK
print(response.data); // null
print(response.success); // true

5. Example #

import 'package:response_x/response_x.dart';
import 'package:http/http.dart' as http;

Future<Response> todos() async {
  final response = await http.get('https://jsonplaceholder.typicode.com/todos');
  if (response.statusCode == 200) {
    return Response.success(data: response.body, message: "todos fetched successfully");
  } else {
    return Response.error(message: 'there was an error fetching todos');
  }
}


void main() async {
  final response = await todos();
  if (response.success) {
    print(response.data);
  } else {
    print(response.message);
  }
}

Maintainers #

@ravikovind

7
likes
0
points
0
downloads

Publisher

verified publishervoltvave.com

Weekly Downloads

library for exchanging response between server and client. it can be a useful tool for standardizing the way that a server communicates with its clients.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

equatable

More

Packages that depend on response_x