Skip to content

Commit

Permalink
Image upload updation
Browse files Browse the repository at this point in the history
  • Loading branch information
rohit5krish committed Jul 18, 2022
1 parent 81701d4 commit c42ce76
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 0 additions & 2 deletions lib/application/students/students_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'package:bloc/bloc.dart';
import 'package:image_picker/image_picker.dart';
import 'package:meta/meta.dart';
import 'package:student_management/domain/student_model.dart';
import 'package:student_management/main.dart';

Expand Down
31 changes: 18 additions & 13 deletions lib/presentation/update_student/update_student.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,22 @@ class UpdateStudent extends StatelessWidget {
sbHeight30,

// Submit button
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
primary: Colors.green, fixedSize: const Size(110, 45)),
onPressed: () {
saveButtonClicked(context);
},
icon: const Icon(Icons.save),
label: const Text(
'Save',
style: TextStyle(fontSize: 16),
)),
BlocBuilder<StudentsCubit, StudentsState>(
builder: (context, state) {
return ElevatedButton.icon(
style: ElevatedButton.styleFrom(
primary: Colors.green,
fixedSize: const Size(110, 45)),
onPressed: () {
saveButtonClicked(context, state.imgPath.toString());
},
icon: const Icon(Icons.save),
label: const Text(
'Save',
style: TextStyle(fontSize: 16),
));
},
),
],
),
));
Expand All @@ -162,7 +167,7 @@ class UpdateStudent extends StatelessWidget {
}
}

saveButtonClicked(BuildContext context) {
saveButtonClicked(BuildContext context, String imagePath) {
final isValid = formKey.currentState!.validate();
if (isValid) {
final String _name = _upNameCtrl.text.trim();
Expand All @@ -176,7 +181,7 @@ class UpdateStudent extends StatelessWidget {
branch: _branch,
place: _place,
phone: _phone,
image: _upImage);
image: imagePath);
BlocProvider.of<StudentsCubit>(context)
.updateStudent(_studentDetail, index);
Navigator.of(context).pop();
Expand Down

0 comments on commit c42ce76

Please sign in to comment.