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

outdated

Implementation of jsend specification ( a specification that tells how JSON Response are structured) in dart. Details of jsend specification is available at https://github.com/omniti-labs/jsend

Implementation of jsend specification in dart. Simply putting, jsend is a specification that tells how JSON responses coming from server should be structured.

Using #

import 'package:jsend/jsend.dart';

// ... your code

var someHTTPResponse = await http.get('https://api-that-gives-json-response');

// obtained HTTP Response can be parsed to jsend Response as

var jsendResp = jsendResponse(someHTTPResponse);

Getting status, message and data #

//status
jsendResp.status

//message
jsendResp.message

//data
jsendResp.data

Handling validation errors in fields #

By jsend standard, we send validation errors in data field. This package contains some helper methods to read errors in fields.

//checking if errors exist in a field

if(jsendResp.hasErrorIn('email')){
    // executed if errors exist in email field
}

//getting errors in a field
var errorInEmail = jsendResp.errorIn('email') ;
// returns null in case no errors exist.

Created from templates made available by Stagehand under a BSD-style license.

3
likes
0
pub points
1%
popularity

Publisher

unverified uploader

Implementation of jsend specification ( a specification that tells how JSON Response are structured) in dart. Details of jsend specification is available at https://github.com/omniti-labs/jsend

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

http

More

Packages that depend on jsend