-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update flutter rocket example (#120)
* update flutter rocket example * update flutter example tests * bump version from 2.7.0+25 to 2.8.0+25 by fastlane plugin * update dev workflow * update flutter rocket package from pubspec * format codes * fixed tests issue
- Loading branch information
1 parent
ef474af
commit 126fb2f
Showing
28 changed files
with
525 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'package:flutter_rocket/flutter_rocket.dart'; | ||
|
||
const String todoUserIdField = "userId"; | ||
const String todoIdField = "id"; | ||
const String todoTitleField = "title"; | ||
const String todoCompletedField = "completed"; | ||
|
||
class Todos extends RocketModel<Todos> { | ||
int? userId; | ||
int? id; | ||
String? title; | ||
bool? completed; | ||
|
||
Todos({ | ||
this.userId, | ||
this.id, | ||
this.title, | ||
this.completed, | ||
}); | ||
|
||
@override | ||
void fromJson(Map<String, dynamic> json, {bool isSub = false}) { | ||
userId = json[todoUserIdField]; | ||
id = json[todoIdField]; | ||
title = json[todoTitleField]; | ||
completed = json[todoCompletedField]; | ||
super.fromJson(json, isSub: isSub); | ||
} | ||
|
||
void updateFields({ | ||
int? userIdField, | ||
int? idField, | ||
String? titleField, | ||
bool? completedField, | ||
}) { | ||
userId = userIdField ?? userId; | ||
id = idField ?? id; | ||
title = titleField ?? title; | ||
completed = completedField ?? completed; | ||
rebuildWidget(fromUpdate: true); | ||
} | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
final Map<String, dynamic> data = {}; | ||
data[todoUserIdField] = userId; | ||
data[todoIdField] = id; | ||
data[todoTitleField] = title; | ||
data[todoCompletedField] = completed; | ||
|
||
return data; | ||
} | ||
|
||
@override | ||
get instance => Todos(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import 'package:flutter_rocket/flutter_rocket.dart'; | ||
|
||
const String todosUserIdField = "userId"; | ||
const String todosIdField = "id"; | ||
const String todosTitleField = "title"; | ||
const String todosCompletedField = "completed"; | ||
|
||
class Todos extends RocketModel<Todos> { | ||
int? userId; | ||
int? id; | ||
String? title; | ||
bool? completed; | ||
|
||
Todos({ | ||
this.userId, | ||
this.id, | ||
this.title, | ||
this.completed, | ||
}); | ||
|
||
@override | ||
void fromJson(Map<String, dynamic> json, {bool isSub = false}) { | ||
userId = json[todosUserIdField]; | ||
id = json[todosIdField]; | ||
title = json[todosTitleField]; | ||
completed = json[todosCompletedField]; | ||
super.fromJson(json, isSub: isSub); | ||
} | ||
|
||
void updateFields({ | ||
int? userIdField, | ||
int? idField, | ||
String? titleField, | ||
bool? completedField, | ||
}) { | ||
userId = userIdField ?? userId; | ||
id = idField ?? id; | ||
title = titleField ?? title; | ||
completed = completedField ?? completed; | ||
rebuildWidget(fromUpdate: true); | ||
} | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
final Map<String, dynamic> data = {}; | ||
data[todosUserIdField] = userId; | ||
data[todosIdField] = id; | ||
data[todosTitleField] = title; | ||
data[todosCompletedField] = completed; | ||
|
||
return data; | ||
} | ||
|
||
@override | ||
get instance => Todos(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import 'package:flutter_ci_cd/models/photo_model.dart'; | ||
import 'package:mvc_rocket/mvc_rocket.dart'; | ||
import 'package:flutter_rocket/flutter_rocket.dart'; | ||
|
||
const String photosEndpoint = "photos"; | ||
|
||
class GetPhotos { | ||
static Future getPhotos(Photo photoModel) => Rocket.get(rocketRequestKey) | ||
.getObjData(photosEndpoint, photoModel, multi: true); | ||
static Future getPhotos(Photo photoModel) => | ||
Rocket.get<RocketClient>().request(photosEndpoint, model: photoModel); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
import 'package:flutter_ci_cd/models/post_model.dart'; | ||
import 'package:mvc_rocket/mvc_rocket.dart'; | ||
import 'package:flutter_rocket/flutter_rocket.dart'; | ||
|
||
const String postsEndpoint = "posts"; | ||
|
||
class GetPosts { | ||
static Future getPosts(Post postModel) => | ||
Rocket.get(rocketRequestKey).getObjData( | ||
// endpoint | ||
postsEndpoint, | ||
// your model | ||
postModel, | ||
inspect: (d) { | ||
return d; | ||
}, | ||
// 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 getPosts(Post postModel) { | ||
return Rocket.get<RocketClient>().request( | ||
// endpoint | ||
postsEndpoint, | ||
// your model | ||
model: postModel, | ||
inspect: (d) { | ||
return d; | ||
}, | ||
// 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"] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'package:flutter_ci_cd/models/todos.dart'; | ||
import 'package:flutter_rocket/flutter_rocket.dart'; | ||
|
||
const String todosEndpoint = "todos"; | ||
|
||
class GetTodos { | ||
static Future gettodos(Todos todosModel) => | ||
Rocket.get<RocketClient>().request(todosEndpoint, model: todosModel); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'package:flutter_ci_cd/models/todo.dart'; | ||
import 'package:flutter_rocket/flutter_rocket.dart'; | ||
|
||
const String todosEndpoint = "todos"; | ||
|
||
class GetTodos { | ||
static Future getTodos(Todos todosModel) => | ||
Rocket.get<RocketClient>().request(todosEndpoint, model: todosModel); | ||
} |
Oops, something went wrong.