Skip to content

Instantly share code, notes, and snippets.

@M97Chahboun
Last active June 28, 2022 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save M97Chahboun/25cdeed2f072f8b466a0d2ec089c8b89 to your computer and use it in GitHub Desktop.
Save M97Chahboun/25cdeed2f072f8b466a0d2ec089c8b89 to your computer and use it in GitHub Desktop.
import 'package:example/models/post_model.dart';
import 'package:mvc_rocket/mvc_rocket.dart';
const String postsEndpoint = "posts";
class PostRequests {
static Future getPosts(Post postModel) =>
RocketController().get(rocketRequestKey).getObjData(
// endpoint
postsEndpoint,
// your model
postModel,
inspect: (data) {
return data;
},
// if you received data as List multi will be true & if data as map you not should to define multi its false as default
multi: true,
// parameters for send it with request
// params:{"key":"value"},
// inspect method for determine exact json use for generate your model in first step
// if your api send data directly without any supplement values you not should define it
// inspect:(data)=>data["response"]
);
static Future postPosts(Post postModel){
// RocketController().get(rocketRequestKey).postObjData();
// TODO : implement post request
}
static Future putPosts(int id, Post postModel){
// RocketController().get(rocketRequestKey).putObjData();
// TODO : implement put request
}
static Future deletePosts(int id){
// RocketController().get(rocketRequestKey).delJsonData();
// TODO : implement delete request
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment