diff --git a/lib/pages/application_details_page.dart b/lib/pages/application_details_page.dart index 0dca0450622061e42e8bb48722007e30c774e250..849d09197518d7ad9633971b28b25bb5905333ef 100644 --- a/lib/pages/application_details_page.dart +++ b/lib/pages/application_details_page.dart @@ -19,6 +19,8 @@ import 'package:smf_mobile/widgets/people_card.dart'; import 'package:smf_mobile/widgets/silverappbar_delegate.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'dart:async'; +import 'package:geolocator/geolocator.dart'; +import 'package:smf_mobile/services/location_service.dart'; // import 'package:connectivity_plus/connectivity_plus.dart'; // import 'package:smf_mobile/util/connectivity_helper.dart'; @@ -262,16 +264,26 @@ class _ApplicationDetailsPageState extends State<ApplicationDetailsPage> Future<void> _submitInspection() async { bool isInternetConnected = await Helper.isInternetConnected(); + Position position; // await Future.delayed(const Duration(milliseconds: 10)); if (isInternetConnected) { _validateUser(); } + try { + position = await LocationService.getCurrentPosition(); + } catch (error) { + Helper.toastMessage(error.toString()); + return; + } + if (_isleadInspector) { Map data = { 'applicationId': widget.application.applicationId, 'userId': _userId, - 'dataObject': _data + 'dataObject': _data, + 'latitude': position.latitude, + 'longitude': position.longitude, }; //Validate assessment form to make sure some inputs are given by the assessor diff --git a/lib/pages/inspection_summary.dart b/lib/pages/inspection_summary.dart index 6fa260a7329e009b3651714d50a77e58662f368c..6ca2d9818d0c51801694dda398cea988ffb2428c 100644 --- a/lib/pages/inspection_summary.dart +++ b/lib/pages/inspection_summary.dart @@ -7,8 +7,6 @@ import 'package:smf_mobile/constants/color_constants.dart'; // import 'package:smf_mobile/models/form_model.dart'; import 'package:smf_mobile/pages/login_email_page.dart'; import 'package:smf_mobile/repositories/application_repository.dart'; -import 'package:geolocator/geolocator.dart'; -import 'package:smf_mobile/services/location_service.dart'; // import 'package:smf_mobile/repositories/form_repository.dart'; import 'package:smf_mobile/util/helper.dart'; import 'package:smf_mobile/widgets/people_card.dart'; @@ -128,16 +126,7 @@ class _InspectionSummaryPageState extends State<InspectionSummaryPage> { } Future<void> _submitInspection() async { - Position position; bool isInternetConnected = await Helper.isInternetConnected(); - - try { - position = await LocationService.getCurrentPosition(); - } catch (error) { - Helper.toastMessage(error.toString()); - return; - } - // await Future.delayed(const Duration(milliseconds: 10)); if (isInternetConnected) { _validateUser(); @@ -154,6 +143,7 @@ class _InspectionSummaryPageState extends State<InspectionSummaryPage> { 'Enter the summary of this inspection': _summaryController.text } }; + print(data); final responseCode = await Provider.of<ApplicationRespository>(context, listen: false) .submitInspection(isInternetConnected, data);