Skip to content

Instantly share code, notes, and snippets.

@anoochit
Created December 9, 2025 15:27
Show Gist options
  • Select an option

  • Save anoochit/0a96d8e6a346e9a744439b6e38e039c6 to your computer and use it in GitHub Desktop.

Select an option

Save anoochit/0a96d8e6a346e9a744439b6e38e039c6 to your computer and use it in GitHub Desktop.
This is a Flutter project for a todo application. It uses Firebase for backend services, specifically Firestore to store the todo tasks.

Gemini Code Assistant Context

This document provides context for the Gemini code assistant to understand the todo_app project.

Project Overview

This is a Flutter project for a todo application. It uses Firebase for backend services, specifically Firestore to store the todo tasks. The project is connected to the Firebase project with the ID genai-workshop-fe4e0. The todo tasks are stored in a Firestore collection named todos.

The application supports Android, iOS and Web.

Features

  • Add new tasks to the todo list.
  • Swipe a task to the right to mark it as complete.
  • Swipe a task to the left to delete it (with a confirmation dialog).
  • Completed tasks are displayed with a strikethrough text style.

Firebase Setup

To add your Flutter project to Firebase, use the flutterfire CLI.

  1. Install FlutterFire CLI: If you haven't already, install the FlutterFire CLI:

    dart pub global activate flutterfire_cli
  2. Configure Firebase Project: Run the following command in your project root to configure Firebase for your Flutter app:

    flutterfire configure --project=genai-workshop-fe4e0

    This command will guide you through selecting platforms (Android, iOS, Web, Windows, etc.) and automatically generate the necessary configuration files (e.g., lib/firebase_options.dart).

  3. Verify Configuration: Ensure that lib/firebase_options.dart has been generated with your project-specific configurations.

Building and Running

Building

To build the project, run the following command:

flutter build

Running

To run the project, use the following command:

flutter run

You can also specify a target platform:

flutter run -d <platform>

Replace <platform> with android, ios, or web.

Testing

To run the tests, use the following command:

flutter test

Development Conventions

This project follows the standard Flutter and Dart conventions.

  • The main application entry point is lib/main.dart.
  • The main UI for the todo list is in lib/pages/todos.dart.
  • Tests are located in the test directory.
  • Dependencies are managed in pubspec.yaml.
  • The project uses flutter_lints for code analysis, with rules configured in analysis_options.yaml.
  • The project uses Firebase for backend services, with Firestore as the database.
  • The Firebase project ID is genai-workshop-fe4e0.
  • The Firestore collection for todos is todos.

Retrospective Report

1. Initial Goal

The primary objective was to implement a fully functional Flutter-based "Todo" application as specified in the GEMINI.md document. The core requirements included Firebase Firestore integration for the backend, and features for adding, deleting, and marking tasks as complete.

2. Implementation Steps

  1. Dependency Management: I began by inspecting the pubspec.yaml file and added the necessary Firebase packages: firebase_core, cloud_firestore, and firebase_auth.
  2. Firebase Configuration: I executed flutterfire configure to properly link the Flutter application with the specified Firebase project (genai-workshop-fe4e0), which generated the required lib/firebase_options.dart configuration file.
  3. UI and Logic Development:
    • I created the lib/pages/todos.dart file, which contains the primary user interface and business logic for managing the todo list. This included UI for displaying tasks, an input field for adding new tasks, and stream-based, real-time updates from Firestore.
    • The lib/main.dart file was then updated to initialize the Firebase connection asynchronously and to set TodosPage as the application's home screen.

3. Problem Encountered

Following the initial implementation, an exception was reported during the "swipe-to-complete" action: A dismissed Dismissible widget is still part of the tree.

4. Root Cause Analysis

The error occurred because the Dismissible widget's onDismissed callback was being triggered, causing Flutter to expect the widget to be immediately removed from the widget tree. However, the implementation was only updating the task's status in Firestore, not removing it. This violated the Dismissible widget's contract, leading to the assertion error.

5. Resolution

To address the issue and improve the user experience, I implemented the following changes:

  1. Used confirmDismiss: I replaced the problematic logic in onDismissed with the confirmDismiss callback, which provides more control over the dismissal action.
  2. Swipe to Complete: For a right-swipe, the task's completed status is updated in Firestore, and confirmDismiss returns false. This prevents the widget from being removed from the tree, correctly reflecting the "update" action.
  3. Swipe to Delete: For a left-swipe, a confirmation dialog is now shown. The confirmDismiss callback returns the boolean result from this dialog, ensuring the item is only dismissed if the user confirms the deletion. The actual deletion from Firestore now happens in the onDismissed callback, which is only invoked if confirmDismiss returns true.
  4. UX Enhancement: As a bonus, I added an onTap handler to the ListTile for each task, allowing users to toggle the completion status with a simple tap—a common and intuitive interaction pattern.

6. Final Outcome

The bug was successfully resolved, and the application's functionality now correctly and robustly implements the requirements outlined in the GEMINI.md file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment