Integrate the OpenWeatherMap API in FlutterFlow by creating an API Group with the base URL and your API key. Call the current weather endpoint with a city name or GPS coordinates to display temperature, conditions, and a weather icon. Add a second API call for the 5-day forecast and render daily cards in a horizontal ScrollView for a complete weather experience.
Connecting FlutterFlow to a Weather API
Weather data is a common feature for travel apps, event planners, outdoor activity platforms, and dashboards. This tutorial shows you how to connect FlutterFlow to the OpenWeatherMap API, display current conditions with dynamic icons, fetch the user's location for local weather, and build a 5-day forecast carousel.
Prerequisites
- A FlutterFlow project with at least one page
- A free OpenWeatherMap account with an API key
- Basic understanding of FlutterFlow API Calls and JSON paths
Step-by-step guide
Set up the OpenWeatherMap API Group in FlutterFlow
Set up the OpenWeatherMap API Group in FlutterFlow
Go to API Calls in the left panel and create a new API Group named WeatherAPI. Set the base URL to https://api.openweathermap.org/data/2.5. Add a Header: Content-Type set to application/json. Create the first API Call named GetCurrentWeather with method GET and path /weather. Add query parameters: q (String, the city name), appid (String, your API key), and units (String, set default to 'metric'). Test the call with a sample city to verify it returns temperature, weather description, and icon data in the response.
Expected result: The API Call returns current weather JSON with temp, description, and icon code when tested.
Build the current weather display card
Build the current weather display card
On your WeatherPage, add a TextField at the top for city search with a search IconButton. Below it, add a Container styled as a weather card with rounded corners and a subtle shadow. Inside the Container, place a Column. Add an Image widget bound to the weather icon URL: https://openweathermap.org/img/wn/{iconCode}@2x.png where iconCode comes from the API response at path weather[0].icon. Add a Text widget for the temperature from main.temp, formatted with a degree symbol. Add another Text for the description from weather[0].description. Add a Row below with humidity (main.humidity) and wind speed (wind.speed) in smaller text. On the search IconButton tap, trigger the GetCurrentWeather API call with the TextField value.
Expected result: Searching a city displays the current temperature, weather icon, description, humidity, and wind speed.
Add location-based weather using device GPS
Add location-based weather using device GPS
Create a Custom Action that uses the geolocator package to get the device's current latitude and longitude. The action should request location permission, get the current position, and return lat and lng as output variables. Create a second API Call in your WeatherAPI group named GetWeatherByCoords with path /weather and query parameters: lat, lon, appid, and units. On the WeatherPage, add an On Page Load action that runs the geolocation Custom Action, then calls GetWeatherByCoords with the returned coordinates, and binds the result to the weather card. Add a location IconButton that re-triggers this flow to refresh with current location.
1// Custom Action: getCurrentLocation2import 'package:geolocator/geolocator.dart';34Future<List<double>> getCurrentLocation() async {5 LocationPermission permission = await Geolocator.checkPermission();6 if (permission == LocationPermission.denied) {7 permission = await Geolocator.requestPermission();8 }9 final position = await Geolocator.getCurrentPosition(10 desiredAccuracy: LocationAccuracy.medium,11 );12 return [position.latitude, position.longitude];13}Expected result: The app loads weather for the user's current GPS location on page load and when tapping the location button.
Create the 5-day forecast API call and horizontal card layout
Create the 5-day forecast API call and horizontal card layout
Add a third API Call named GetForecast with path /forecast and the same query parameters as GetCurrentWeather. This endpoint returns forecast data in 3-hour intervals for 5 days. On the WeatherPage below the current weather card, add a Text heading '5-Day Forecast'. Add a ListView set to horizontal scroll direction with a fixed height of 140. Bind it to the API response list at path list, but since the data comes in 3-hour intervals, create a Custom Function that filters the list to one entry per day (pick the noon entry for each unique date). Each child Container displays the day name, weather icon, and high/low temperatures.
Expected result: A horizontal row of 5 forecast cards showing the day, icon, and temperature range for each upcoming day.
Add error handling and loading states
Add error handling and loading states
Wrap the weather card in a Conditional Builder. Show a CircularProgressIndicator while the API call is in progress. If the API returns an error (city not found returns a 404 code in the JSON), display an error Container with a message like 'City not found. Please check the spelling.' Add a try-again button. For the geolocation flow, handle the case where the user denies location permission by showing a message asking them to enter a city manually. Store the last successful city in App State so the app loads cached data on relaunch before the API responds.
Expected result: The app gracefully handles loading, API errors, missing cities, and denied location permissions.
Complete working example
1API GROUP: WeatherAPI2 Base URL: https://api.openweathermap.org/data/2.534API CALL 1: GetCurrentWeather5 Method: GET6 Path: /weather7 Query Params: q (city), appid (API key), units (metric)8 Response paths:9 main.temp → temperature10 weather[0].description → condition text11 weather[0].icon → icon code12 main.humidity → humidity %13 wind.speed → wind speed1415API CALL 2: GetWeatherByCoords16 Method: GET17 Path: /weather18 Query Params: lat, lon, appid, units1920API CALL 3: GetForecast21 Method: GET22 Path: /forecast23 Query Params: q (city), appid, units24 Response: list[] → filter to 1 per day2526PAGE: WeatherPage27WIDGET TREE:28 Column29 ├── Row (search bar)30 │ ├── TextField (city name)31 │ ├── IconButton (search → GetCurrentWeather)32 │ └── IconButton (location → geolocation + GetWeatherByCoords)33 ├── Container (current weather card)34 │ └── Column35 │ ├── Image (icon: openweathermap.org/img/wn/{icon}@2x.png)36 │ ├── Text (temperature + °C)37 │ ├── Text (description)38 │ └── Row39 │ ├── Icon + Text (humidity %)40 │ └── Icon + Text (wind speed m/s)41 ├── Text ("5-Day Forecast" heading)42 └── ListView.horizontal (height: 140)43 Backend: GetForecast response, filtered to 1/day44 └── Container (forecast card)45 └── Column46 ├── Text (day name)47 ├── Image (weather icon)48 └── Text (high° / low°)4950CUSTOM ACTION: getCurrentLocation51 Uses geolocator package52 Returns: [latitude, longitude]53 Handles permission request5455CUSTOM FUNCTION: filterForecastToDaily56 Input: forecast list (3-hour intervals)57 Output: 5 entries, one per day (noon reading)58 Logic: group by date, pick entry closest to 12:00Common mistakes
Why it's a problem: Exposing the API key in client-side API call headers
How to avoid: Route API calls through a Cloud Function that holds the key server-side, or use FlutterFlow's Private API option to keep the key hidden.
Why it's a problem: Displaying raw 3-hour forecast data instead of daily summaries
How to avoid: Create a Custom Function that groups forecast entries by date and picks one representative entry per day, typically the noon reading.
Why it's a problem: Not handling location permission denial gracefully
How to avoid: Fall back to a city search TextField when location permission is denied. Show a clear message explaining that they can type a city name instead.
Why it's a problem: Calling the API on every keystroke in the search field
How to avoid: Trigger the API call only on the search button tap or when the user presses Enter, not on TextField onChange.
Best practices
- Use FlutterFlow's Private API option or Cloud Functions to protect your API key
- Display weather icons from OpenWeatherMap's icon URL for consistent visual representation
- Cache the last weather result in App State for instant display on app relaunch
- Handle all error states: city not found, network failure, and permission denied
- Use metric or imperial units based on user preference stored in App State
- Filter 3-hour forecast data to daily summaries for a cleaner UI
- Add pull-to-refresh so users can manually update weather data
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I want to integrate the OpenWeatherMap API in FlutterFlow. Show me how to set up the API Group, create calls for current weather and 5-day forecast, parse the JSON response, display weather icons, and add geolocation for local weather.
Create a weather dashboard page with a search bar at the top, a large card showing current temperature with a weather icon, and a horizontal row of 5 smaller cards for the weekly forecast below.
Frequently asked questions
Is the OpenWeatherMap API free to use?
Yes, the free tier includes 60 calls per minute and access to current weather and 5-day forecast endpoints. This is sufficient for most apps. Paid plans offer minute-by-minute data, historical data, and higher rate limits.
Can I use a different weather API instead of OpenWeatherMap?
Yes. WeatherAPI.com, Tomorrow.io, and Visual Crossing all work similarly. Create an API Group with the new base URL and adjust the JSON response paths to match that API's response format.
How do I show weather for multiple saved cities?
Store a list of city names in App State. On page load, loop through the list and call GetCurrentWeather for each city. Display results in a ListView where each card shows one city's weather summary.
Can I display weather data without the user searching?
Yes. Use the geolocation Custom Action on page load to get the device coordinates automatically, then call GetWeatherByCoords. The weather card populates without any user interaction.
How often should I refresh weather data?
OpenWeatherMap updates data roughly every 10 minutes. Refresh on page load and add a pull-to-refresh gesture. Avoid refreshing more frequently than every 5 minutes to stay within API rate limits.
Can RapidDev help build a weather-integrated app?
Yes. RapidDev can implement weather dashboards with radar maps, severe weather alerts, location-based notifications, multi-city tracking, and integration with any weather data provider.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation