custom function don't save

Database & APIs
Resolved

ho, i have a custom function:

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/custom_functions.dart';
import '/flutter_flow/lat_lng.dart';
import '/flutter_flow/place.dart';
import '/flutter_flow/uploaded_file.dart';
import '/backend/schema/structs/index.dart';
import 'package:http/http.dart' as http;

Future<List<double>?> getLatLngFronAddress(String address)  async{
  /// MODIFY CODE ONLY BELOW THIS LINE

  final apiKey =
      'YOUR_API_KEY'; // Inserisci qui la tua API Key oppure usa un secret param
  final url = Uri.parse(
      'https://maps.googleapis.com/maps/api/geocode/json?address=${Uri.encodeComponent(address)}&key=$apiKey');

  final response = await http.get(url);

  if (response.statusCode == 200) {
    final data = json.decode(response.body);

    if (data['status'] == 'OK') {
      final location = data['results'][0]['geometry']['location'];
      final lat = location['lat'];
      final lng = location['lng'];
      return [lat, lng];
    } else {
      //debugPrint('Geocoding failed: ${data['status']}');
    }
  } else {
    //debugPrint('HTTP error: ${response.statusCode}');
  }
  return null;

  /// MODIFY CODE ONLY ABOVE THIS LINE
}

but flutter flow doesn't save the function whith the messagge: "the function is empty or cannot parsed. make sure not to modify code outside off the designaterd area"

the error is only in imported part

What have you tried so far?

chatgpt, search in flutter flow comunity

Did you check FlutterFlow's Documentation for this topic?
No
2
4 replies