How I Built a Flutter + Gemini AI App to 'Hack' My University Attendance (Open Source)

Published: (January 3, 2026 at 12:59 PM EST)
4 min read
Source: Dev.to

Source: Dev.to

If you are an engineering student (like me at the University of Moratuwa), you know the terror of the 80 % Rule.

It’s simple math: Attend 80 % of classes or get banned from the exam.

In reality it’s a nightmare.

  • “If I skip today’s lecture, does my percentage drop to 79.9 %?”
  • “Did the lecturer count that medical leave?”
  • “Can I afford to sleep in tomorrow?”

I found myself doing complex algebra at 2 AM just to decide whether I could skip a morning lecture. I needed a tool that didn’t just track habits, but actually strategized for me.

So I built The 80 Percent.

Below is a walkthrough of the full‑stack solution I engineered with Flutter, Google Gemini AI, and a heavily optimized Firebase backend – all while staying on the free tier.

1. The Strategy Engine: “Safe to Skip” Logic

Most habit trackers only say “You are at 75 %.” That’s useless information. I needed actionable advice.

The “Buffer” Formula

If you are above your target, how many classes can you miss before you hit the danger zone?

// The Magic Formula
int calculateSafeSkips(int present, int total, double target) {
  // Formula: floor((present / target) - total)
  int skips = ((present / target) - total).floor();
  return skips < 0 ? 0 : skips;
}

Scenario: You attended 18/20 classes. Target = 80 %.
Result: You can safely skip 2 more classes.

Why it matters: It stops students from panic‑attending classes they don’t need, preventing burnout.

The “Recovery” Formula

If you are failing, how many classes must you attend in a row to become safe again?

// The Recovery Formula
int calculateRecovery(int present, int total, double target) {
  // Formula: ceil((target * total - present) / (1 - target))
  return ((target * total - present) / (1 - target)).ceil();
}

This is critical because a student at 70 % needs to know exactly when they will be safe again.

2. The AI Challenge: Parsing Timetables with Gemini 2.5

The biggest friction in any student app is setup. Nobody wants to manually type in 15 modules and timeslots.

Why Gemini 2.5 Flash?

ReasonBenefit
Speed & CostIdeal for a free student app – low‑latency, cheap inference.
Multimodal IntelligenceAccepts PDF/Image inputs directly.
Zero‑Shot CapabilityNo need for lengthy few‑shot examples; a single, well‑structured system instruction is enough.

Implementation (Zero‑Shot Prompt)

final model = GenerativeModel(
  model: 'gemini-2.5-flash',
  apiKey: apiKey,
);

final prompt = """
You are an intelligent assistant that extracts university timetable data.
**GOAL**: Extract timetable metadata, modules, and classes into structured JSON.
**SCHEMA**:
{
  "modules": [{"code": String, "name": String, ...}],
  "classes": [{"day": String, "time": String, "location": String, ...}]
}
""";

final response = await model.generateContent([
  Content.text(prompt),
  Content.data('image/png', timetableImageBytes),
]);

The app parses the JSON response and batch‑writes the classes to the local database. This “Zero‑Shot” approach keeps the request payload small and fast.

3. The Architecture: Surviving the Firebase Free Tier

As a student I have $0 budget. Firebase is great, but the Firestore limits (50 000 reads/day) are a trap. With 500 users opening the app 10 times a day and fetching 10 records each, you’d hit the quota on day 1.

My “Offline‑First” Solution

ComponentWhat it does
Local CachingLoads data from the device instantly on launch.
Lazy SyncingWrites to Firestore only when the user explicitly changes something (e.g., marking attendance).
No Images in DBSkipped profile‑picture sync to avoid the paid “Blaze” plan or bulky Base64 hacks.

Using a Repository Pattern, the app can scale to thousands of users without spending a cent.

4. The Result: A Production‑Ready Beta

“The 80 %” isn’t just a calculator; it’s a full‑stack academic tool.

  • Tech Stack: Flutter, Firebase Auth / Firestore, Provider, Gemini API.
  • Status: Open‑source & beta live.

Building this taught me that engineering is about trade‑offs – I sacrificed fancy features (cloud images) for stability (free‑tier limits) and replaced simple logic with precise math to make the app genuinely useful.

Screenshot

The 80 Percent screenshot

Try It Out

I’m looking for feedback from fellow developers and students.

  • 👉 Notion Documentation (link truncated in original; replace with the correct URL when available)

Feel free to clone the repo, open issues, or suggest improvements!

[The 80% Attendance Strategy for Undergrads](https://ill-grenadilla-8a4.notion.site/The-80-Attendance-Strategy-for-Undergrads-2d4d8852a123808c900cd5c78f7de104?pvs=74)

👉 [Demo code and APK file](https://github.com/inusha-thathsara/attendance-tracker-demo/tree/main)

*(Star the repo if you think the project is cool! ⭐)*
Back to Blog

Related posts

Read more »

The RGB LED Sidequest 💡

markdown !Jennifer Davishttps://media2.dev.to/dynamic/image/width=50,height=50,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%...

Mendex: Why I Build

Introduction Hello everyone. Today I want to share who I am, what I'm building, and why. Early Career and Burnout I started my career as a developer 17 years a...