I am trying to use AI generated code (not a developer by trade) to convert doubles values from an API endpoint to an acceptable LatLng format for Flutterflow to receive to plot markers on a map. I have been unsuccessful and cannot figure out why.
When I attempt to run the code, nothing happens. The page variable never updates and the actions tree just stops. No values actually get input into the end LatLng field. I can read out what the custom function is doing, and it appears to be writing it like you'd expect.
Here is the code:
import 'dart:convert'; import 'dart:math' as math; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:intl/intl.dart'; import 'package:timeago/timeago.dart' as timeago; import '/flutter_flow/lat_lng.dart'; import '/flutter_flow/place.dart'; import '/flutter_flow/uploaded_file.dart'; import '/flutter_flow/custom_functions.dart'; import '/backend/backend.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import '/backend/schema/structs/index.dart'; import '/backend/schema/enums/enums.dart'; import '/backend/sqlite/sqlite_manager.dart'; import '/auth/firebase_auth/auth_util.dart'; List<LatLng>? convertDoublestoLatLng( List<double>? latitude, List<double>? longitude, ) { /// MODIFY CODE ONLY BELOW THIS LINE // convert latitude double and longitude double into LatLng if (latitude == null || longitude == null) { return null; } if (latitude.length != longitude.length) { throw ArgumentError( 'Latitude and longitude lists must have the same length'); } final List<LatLng> latLngList = []; for (int i = 0; i < latitude.length; i++) { latLngList.add(LatLng(latitude[i], longitude[i])); } return latLngList; /// MODIFY CODE ONLY ABOVE THIS LINE }