back

( Session )

Beyond the API Call: On-Device AI in Flutter with LiteRT and Offline-First Architecture

#Advanced·Session·12:10 pm - 12:50 pm·fluttercon
session

Standard Flutter AI tutorials typically follow a predictable formula: capture a photo, transmit it to a remote API, and present the output. While this architecture operates smoothly under ideal conditions, it fails during API outages, over slow 2G connections, or when developing for agricultural environments where cloud dependence becomes a fundamental product risk rather than just a poor user experience. This session introduces an alternative architecture by demonstrating how to build a Flutter application that runs a crop disease classifier locally on the device. Powered by the flutter_litert plugin, the app utilises LiteRT - Google’s on-device AI runtime, formerly known as TensorFlow Lite. It stores recent predictions in Hive for offline access and relies on connectivity_plus to automatically detect network changes, transitioning seamlessly to a FastAPI backend when connectivity is available without any user-visible interruption. We will cover the end-to-end pipeline: exporting a PyTorch model for on-device inference, writing the preprocessing pipeline in Dart that matches the Python training pipeline exactly (a mismatch here silently ruins accuracy, and we will look at what that failure actually looks like), integrating the LiteRT interpreter with correct tensor shape and normalisation handling, and building a prediction service that abstracts over on-device and backend inference so the UI never knows which one it is using. Additionally, we will examine the integration seam for a RAG-driven chat functionality following disease identification. Rather than building the actual RAG pipeline live on stage, our focus will centre on the architectural contract between the Flutter client and the remote system, demonstrating how the application queries a backend RAG service to provide users with well-grounded, source-cited responses when they ask "what do I do about this?" Attendees will walk away with a production-grade Flutter mobile AI architecture capable of robust offline operation and graceful degradation, backed by solid benchmark data to validate each architectural choice.

Official feedback form