Cinemapedia reads sensitive configuration values — such as the TheMovieDB API key — from aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/juuaaann456/DMI-Practica06/llms.txt
Use this file to discover all available pages before exploring further.
.env file at runtime. The file is loaded before the app starts using the flutter_dotenv package.
Prerequisites
Make sureflutter_dotenv is listed in your pubspec.yaml dependencies and that the .env file is declared as a Flutter asset:
pubspec.yaml
Creating the .env file
Create a.env file in the root of the project (next to pubspec.yaml) with the following content:
.env
your_api_key_here with a valid API key from TheMovieDB.
How the .env file is loaded
main() is declared async and calls dotenv.load() before runApp, guaranteeing that environment variables are available as soon as any widget or service requests them.
lib/main.dart
The Environment class
All environment variable access is centralised in a single class so the rest of the app never importsflutter_dotenv directly.
lib/config/constants/environment.dart
THE_MOVIEDB_KEY is missing from the .env file, the field falls back to the string 'No hay api key'. API calls will fail in this state, so always verify the key is present before running the app.
Environment variables reference
API key for TheMovieDB. Used to authenticate every HTTP request made to the TMDB REST API. Obtain a free key by creating an account and requesting API access in your account settings.
Using the value in your code
Import theEnvironment class wherever you need the key:
Because
theMovieDbKey is a static field it is read once when the class is first loaded. dotenv.load() must complete before any code accesses Environment.theMovieDbKey, which is why it is awaited in main().