App UI | Test Results |
---|---|
The Weather App is designed to provide real-time weather updates with a simple and user-friendly interface. To use the app:
- Search Weather: Search weather by seach bar
- Show Current Weather: data on the HomePage.
- Display the forecast: for the next few days in the Forecast Detail Page view.
- Pull-to-refresh
- Toggle Unit: Switch between Celsius and Fahrenheit temperature units.
- Geolocation: Implement functionality to fetch the user's current location and display weather accordingly.
App structure, the cubit/ directory within the weather/ folder indicates that are using a simplified version of the BLoC pattern, known as Cubit. The main difference is that Cubit is a lighter and simpler way to manage state without the full complexity of streams that come with a full BLoC implementation.
By adhering to the BLoC pattern, app is more maintainable and scalable, which is advantageous if you plan to add more features in the future or need to handle more complex state management scenarios.
-
Navigate to your project directory:
cd path/to/your/weather_app
-
API Key config: To get an API key, sign up here: https://home.openweathermap.org/users/sign_up
Then paste it in
api_keys.default.dart
and rename this file toapi_keys.dart
.You can also specify an API Key via --dart-define. Example:
"flutter run --dart-define API_KEY=YOUR_API_KEY
-
Get all the dependencies:
flutter pub get
This command fetches all the necessary Flutter packages defined in your
pubspec.yaml
files. -
Run the build_runner:
flutter pub run build_runner build
This step will generate code for your project using the build_runner package. This is commonly used for projects that use code generation for features like JSON serialization.
-
Check that an emulator is running or a device is connected:
flutter devices
This command lists all available devices or emulators.
-
Run the app:
flutter run
This command builds the app and installs it on the connected device or emulator. If you have multiple devices available, you might need to specify the device ID with the
-d
flag.
Optional steps if you encounter any issues:
-
Clean the build:
flutter clean
Sometimes build-related problems can be resolved by cleaning the project.
-
Run tests to ensure your app is working correctly:
flutter test
This will run any unit or widget tests you've written in the
test/
directory.
Note: Make sure to run
flutter pub run build_runner build
whenever you make changes to files that require code generation. If you want to watch for changes and automatically generate code, you can replacebuild
withwatch
in the build_runner command.
If you have any issues or questions, feel free to reach out to me at coduy96@gmail.com.