Skip to content

Commit ef6f4da

Browse files
committed
Edit title when edit rescue
1 parent ec5336c commit ef6f4da

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/rescue_post/screen/rescue_editor_screen.dart

+9-6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ part of petisland.rescue_post.sceen;
33
class RescueEditorScreen extends TStatefulWidget {
44
static const name = '/RescueEditorScreen';
55
final Rescue rescue;
6-
6+
final bool isEdit;
77
const RescueEditorScreen.create({Key key})
88
: this.rescue = null,
9+
isEdit = false,
10+
super(key: key);
11+
const RescueEditorScreen.edit({this.rescue, Key key})
12+
: isEdit = true,
913
super(key: key);
10-
const RescueEditorScreen.edit({this.rescue, Key key}) : super(key: key);
1114

1215
@override
1316
_RescueCreationScreenState createState() => _RescueCreationScreenState();
@@ -23,7 +26,7 @@ class _RescueCreationScreenState extends TState<RescueEditorScreen> {
2326

2427
@override
2528
Widget build(BuildContext context) {
26-
final title = 'Create Rescue Post';
29+
final title = widget.isEdit ? 'Edit Rescue Post' : 'Create Rescue Post';
2730
return Stack(
2831
children: [
2932
Scaffold(
@@ -54,9 +57,9 @@ class _RescueCreationScreenState extends TState<RescueEditorScreen> {
5457
}
5558

5659
void _handleCreateRescue(BuildContext context) async {
57-
final images = await _uploadImage(editingBloc.newImages);
58-
rescueService
59-
.create(editingBloc.rescue, images.map((e) => e.id).toList())
60+
_uploadImage(editingBloc.newImages)
61+
.then((images) =>
62+
rescueService.create(editingBloc.rescue, images.map((e) => e.id).toList()))
6063
.then((value) => rescueListingBloc.refreshRescuePost())
6164
.then((value) => this.closeScreen(context, RescueEditorScreen.name))
6265
.catchError(

0 commit comments

Comments
 (0)