Flutter Meal Tracker App

A Flutter app that allows users to track meal parameters (Fat and Sugar levels) for Breakfast, Lunch, Dinner, and Snacks. Users can select Low, Medium, or High for each parameter and store the entries in a local SQLite database. The app uses Easy Localization for language support and Provider for state management. Additionally, it includes a login screen for user authentication.

Table of Contents

  1. Features
  2. Database Schema
  3. Plugins Used
  4. Setup Guide
  5. Running the App
  6. Download APK
  7. Next Steps
  8. Webapp
  9. Documentation
  10. License

Features

  • Track meal parameters for Breakfast, Lunch, Dinner, and Snacks.
  • Each meal type has selectable Fat and Sugar levels (Low, Medium, High).
  • Save and retrieve meal data using a local SQLite database.
  • User authentication with a login screen.
  • Multi-language support using Easy Localization.
  • State management using Provider.
  • Simple, user-friendly UI.

Database Schema

Database Schema

SQL Representation of the Database

-- SQL commands for creating tables
CREATE TABLE users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL
);

CREATE TABLE meal_types (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL
);

CREATE TABLE meals (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    fat_level TEXT NOT NULL,
    sugar_level TEXT NOT NULL
);

CREATE TABLE day_meals (
    day DATE NOT NULL,
    meal_type_id INTEGER,
    meal_id INTEGER,
    PRIMARY KEY (day, meal_type_id),
    FOREIGN KEY (meal_type_id) REFERENCES meal_types(id),
    FOREIGN KEY (meal_id) REFERENCES meals(id)
);

Tables

  • users: Stores user information (no encryption used for names).
  • meal_types: Contains meal types (Breakfast, Lunch, Dinner, Snacks).
  • meals: Stores the fat and sugar level for each meal.
  • day_meals: Connects a day to its respective meals.

The app uses a composite primary key in day_meals to uniquely identify meals for each day and meal type.

Plugins Used

SQLite

The app uses SQLite to locally store meal data. All meal entries (Fat and Sugar levels) are saved and retrieved from this local database, ensuring offline functionality.

Flutter Login Plugin

The app uses the Flutter Login Plugin to handle user authentication. This plugin simplifies the process of adding a login screen with built-in form validation and animations.

Easy Localization

Easy Localization is used for multi-language support. All user-facing texts are stored in JSON files and can be easily extended for multiple languages.

Provider

Provider is used for state management, allowing efficient handling of state across the app, especially for user interactions with meal data.

Setup Guide

Installation

Build the Web App

To build the web version of the app, use the following command:

flutter build web --release --web-renderer html --target lib/main.dart

Build Android Release

To build the android release version of the app, use the following command:

flutter build apk --release

Android Setup

For Android setup instructions, refer to the Android Setup Guide.

iOS Setup

For iOS setup instructions, refer to the iOS Setup Guide.

Running the App

Once you've completed the setup, you can run the app using the following command:

flutter run

For additional build commands, such as building APKs for Android or iOS builds, refer to the Flutter documentation.

Download APK

You can download the latest release of the Flutter Meal Tracker App from the link below:

Next Steps

There are several potential enhancements for the Flutter Meal Tracker App:

  • Sync Mechanism for Local and Online Databases: Currently, the app stores data in separate local and online databases. A sync mechanism could be implemented to allow offline usage while still benefiting from the advantages of an online database. This would enable users to seamlessly transition between offline and online usage.
  • Opt-Out of Online Usage: For users who prioritize security and privacy, an option to fully opt out of online usage could be provided. This would ensure that no user data is transmitted or stored online, promoting security and data protection.

Deployed WebApp

The App has been built as web-app and can be found here: https://engaige.fe-wi.com/

Documentation

An online version of this documentation can be found at https://doku.engaige.fe-wi.com/

Generating App Documentation

To generate the project's documentation, you can use the dart doc command. This will create documentation for the codebase, including API references and class descriptions.

dart doc

The generated documentation will be located in the doc/api/ directory. You can open the index.html file in a web browser to view the full API documentation.

For more information about Dart documentation generation, refer to the Dart doc guide.

Excluding Sensitive Data from Documentation

When generating documentation for your app using dart doc, there may be certain files or parts of your codebase that you want to exclude from the public API documentation, such as sensitive constants or authentication tokens.

Option 1: Use @nodoc Annotation

To exclude specific variables, methods, or classes from the documentation, you can use the @nodoc annotation. Adding this annotation to any item will prevent Dartdoc from including it in the generated docs.

For example, if you want to exclude sensitive constants like API tokens:

/// @nodoc
const String kAuthentication_apiToken = 'your-api-token';
/// @nodoc
const String kAuthentication_pepper = 'your-pepper';

This approach works at the element level and ensures that any item with @nodoc will not be included in the documentation.

Option 2: Use dartdoc_options.yaml

Alternatively, you can use a dartdoc_options.yaml file to exclude entire files or libraries from the documentation. Place this file in the root of your project, and specify the files or directories you want to exclude.

Here’s an example of how to exclude specific files:

dartdoc:
  exclude:
    - lib/constants/authentication.dart
    - lib/constants/config.dart

Make sure that the paths you provide are relative to your project’s root and use POSIX-style paths (with forward slashes /).

Note: As of now, wildcard exclusion patterns (like lib/constants/*) are not supported, so you must list each file you want to exclude individually.

Verifying the Exclusion

After setting up the @nodoc annotations or the dartdoc_options.yaml, run the following command to generate your documentation:

dart doc

Check the generated documentation (located in the doc/api/ directory) to ensure that the sensitive items or files are excluded as expected.

For more detailed information on Dartdoc configurations, you can refer to the official Dartdoc documentation.

License

This software is provided under an Evaluation License Agreement. It may only be used for evaluation purposes and cannot be modified, copied, or distributed without the express permission of the author.

For full details, please refer to the LICENSE file.

Libraries

constants\authentication
constants\colors
constants\config
constants\sizes
constants\themes
main
models\meal
models\sizes\widget_size_values
models\user
providers\data_provider
providers\ui_readiness_provider
screens\meals_overview_daily
screens\welcome_screen
storage\api_connector
storage\api_repo\api_meal_repo
storage\api_repo\api_user_repo
storage\data_handler
storage\data_handler_repo\data_handler_meal_repo
storage\data_handler_repo\data_handler_user_repo
storage\database_repo\meal_database_repo
storage\database_repo\user_database_repo
storage\database_wrapper
storage\models\users_db_model
utils\auth_service
utils\custom_app_bar
utils\date_time_utils
utils\encryption_utils
utils\language_utils
utils\os_utils
utils\shared_pref_utils
utils\ui\responsive_design_utils
utils\UI\ui_utils
utils\ui\ui_utils
utils\user_utils
widgets\dialogs\loading_dialog
widgets\language_switcher
widgets\meal_progress_bar
widgets\meal_type_item
widgets\remember_me_checkbox
widgets\scroll_to_top_fab