INFRIA Flutter SDK

pub package Dart Analysis Flutter License: MIT Coverage

INFRIA is a complete AI Infrastructure SDK and conversational UI suite for Flutter applications. It enables seamless integration of RAG (Retrieval-Augmented Generation) knowledge bases and Dynamic Client-Side Function Calling (Tool Use) directly into your mobile apps without managing complex AI pipelines or exposing private LLM API keys.


๐ŸŒŸ Key Features

  • ๐Ÿ’ฌ Ready-to-Use Inclusive Chat UI (InfriaChat): Modern, customizable chat interface supporting Light/Dark themes, avatar customization, typing indicator animations, auto-scrolling, and responsive layouts.
  • โšก Dynamic Client-Side Function Calling: Cloud LLMs can securely request and execute native functions on the mobile device (e.g., querying local hospital SIMRS APIs, retrieving GPS coordinates, accessing device sensors, local SQLite data) with automated round-trip response orchestration.
  • ๐Ÿ”’ BYOK (Bring Your Own Key) Security: Private LLM keys (Gemini / OpenAI) and cloud vector databases remain encrypted on the server side โ€” never embedded in the mobile client.
  • ๐Ÿ’ก Inclusive UX Design:
    • Suggestion Chips: Quick action & contextual question buttons above the input bar.
    • Function Execution Indicator: Visual status indicators while the device executes local handlers.
    • Confirmation Dialog: Built-in confirmation modals for sensitive client actions.
    • User Feedback Loop: Thumbs up/down rating bars (๐Ÿ‘ / ๐Ÿ‘Ž) to track answer quality and detect knowledge gaps.
  • ๐Ÿ”„ Session Management: Isolated conversation session handling with auto-generated UUIDs.
  • ๐ŸŽจ Flexible Presentation Modes: Fullscreen views, Modal Bottom Sheets (showInfriaChatBottomSheet), Dialog overlays (showInfriaChatDialog), and Floating Action Buttons (InfriaChatFloatingButton).
  • ๐Ÿ› ๏ธ Developer Tooling (CLI): Dedicated CLI tool (infria login, infria init, infria current, infria use) with official Google Sign-In and automated options generation.

๐Ÿ—๏ธ Architecture Overview

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚               Flutter Client Application               โ”‚
โ”‚  - InfriaSDK & DefaultInfriaOptions                    โ”‚
โ”‚  - ChatController & InfriaChat UI                      โ”‚
โ”‚  - FunctionRegistry & FunctionExecutor (On-Device)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚ HTTPS / WSS / SSE (/v1/runtime/chat)
                           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 INFRIA RUNTIME GATEWAY                 โ”‚
โ”‚  - Firebase Cloud Functions & Multi-Tenant Gateway     โ”‚
โ”‚  - Firestore & Encrypted Secret Vault (BYOK Keys)      โ”‚
โ”‚  - RAG Vector Knowledge Retrieval & Search Engine      โ”‚
โ”‚  - LLM Orchestrator (Google Gemini / OpenAI)           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quickstart Guide

1. Installation

Add infria to your pubspec.yaml dependencies:

flutter pub add infria

Install the INFRIA CLI globally:

dart pub global activate infria

2. Configure Your Project via CLI

Sign in with your Google account and link your AI project:

# Authenticate with Google
infria login

# Link your active INFRIA project (generates lib/infria_options.dart)
infria init

3. Initialize in lib/main.dart

import 'package:flutter/material.dart';
import 'package:infria/infria.dart';
import 'infria_options.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Initialize INFRIA SDK (Developer experience similar to FlutterFire)
  await InfriaSDK.initializeApp(
    options: DefaultInfriaOptions.currentPlatform,
  );

  runApp(const MyApp());
}

4. Register Client-Side Functions (Tool Calling)

Register Dart handlers that the cloud AI can dynamically invoke:

// Example: Registering a queue check function
InfriaSDK.onFunctionCall(
  'check_queue_status',
  (Map<String, dynamic> args) async {
    final poliType = args['poli_type'] as String;
    
    // Call your local backend / hospital SIMRS database
    final queueInfo = await HospitalApi.getQueue(poliType);

    return {
      'current_number': queueInfo.current,
      'patient_number': queueInfo.patient,
      'remaining': queueInfo.remaining,
    };
  },
);

5. Display the Chat Interface

class ChatScreen extends StatefulWidget {
  const ChatScreen({super.key});

  @override
  State<ChatScreen> createState() => _ChatScreenState();
}

class _ChatScreenState extends State<ChatScreen> {
  late final ChatController _controller;

  @override
  void initState() {
    super.initState();
    // Auto-binds to the initialized InfriaSDK instance
    _controller = ChatController();
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('AI Health Assistant')),
      body: InfriaChat(
        controller: _controller,
        title: 'Hospital Assistant',
        theme: InfriaChatTheme.light(),
        suggestions: const [
          '๐Ÿฉบ Check Queue Status',
          '๐Ÿ“… Specialist Doctor Schedule',
          '๐Ÿ“‹ Insurance Referral Info',
        ],
        enableFeedback: true,
        onFeedback: (messageId, isHelpful, reason) {
          debugPrint('Feedback for $messageId: $isHelpful ($reason)');
        },
      ),
    );
  }
}

๐ŸŽจ Presentation Overlays

showInfriaChatBottomSheet(
  context: context,
  controller: _controller,
  title: 'AI Support',
  theme: InfriaChatTheme.dark(),
);

Floating Action Button

Scaffold(
  body: const HomeScreen(),
  floatingActionButton: InfriaChatFloatingButton(
    controller: _controller,
    title: 'Ask AI',
    showBadge: true,
  ),
);

๐Ÿ› ๏ธ CLI Commands Reference

Command Description
infria login Sign in to INFRIA Web Console via Google Authentication.
infria init Interactive project selector & generates lib/infria_options.dart.
infria current Inspect active developer session & currently configured project.
infria use <id> Switch the active project in lib/infria_options.dart instantly.
infria unlink Remove active project configuration from this workspace.
infria projects List all AI projects associated with your authenticated account.
infria logout Sign out and remove local credentials.

๐Ÿงช Testing & Reliability

All components are rigorously tested with 100% test pass rate:

flutter test
dart analyze

๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.

Developed with โค๏ธ by the INFRIA Team โ€ข https://infria.dev

Libraries

infria
Infria Flutter Package - Clean & customizable AI chat UI library.
infria_options