formless 0.1.0 copy "formless: ^0.1.0" to clipboard
formless: ^0.1.0 copied to clipboard

A Flutter package that turns any list of fields into an AI-powered conversational form. Validates answers via Groq, OpenAI, Gemini, or DeepSeek and returns a clean key→value map when all fields are collected.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:formless/formless.dart';

/// Pass your API key at run time, e.g.:
/// `flutter run --dart-define=FORMLESS_API_KEY=your_key_here`
const String _apiKey = String.fromEnvironment('FORMLESS_API_KEY');

void main() {
  runApp(const FormlessExampleApp());
}

class FormlessExampleApp extends StatelessWidget {
  const FormlessExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Formless example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.teal),
        useMaterial3: true,
      ),
      home: const FormlessDemoPage(),
    );
  }
}

class FormlessDemoPage extends StatelessWidget {
  const FormlessDemoPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Formless')),
      body: Padding(
        padding: const EdgeInsets.all(24),
        child: _apiKey.isEmpty
            ? const Center(
                child: Text(
                  'Provide your API key at run time:\n\n'
                  'flutter run --dart-define=FORMLESS_API_KEY=your_key_here',
                  textAlign: TextAlign.center,
                ),
              )
            : Formless(
                provider: AiProvider.openAi,
                apiKey: _apiKey,
                questions: [
                  QuestionsModel(
                    question: 'What is your full name?',
                    key: 'name',
                    type: QuestionFieldType.text,
                  ),
                  QuestionsModel(
                    question: 'What is your email address?',
                    key: 'email',
                    type: QuestionFieldType.email,
                  ),
                  QuestionsModel(
                    question: 'What is your phone number?',
                    key: 'phone',
                    type: QuestionFieldType.phone,
                    validationMessage: 'Must include country code',
                  ),
                ],
                theme: FormlessTheme(
                  userBubbleColor: Colors.teal.shade600,
                  sendButtonColor: Colors.teal.shade600,
                ),
                onComplete: (data) {
                  debugPrint('Formless complete: $data');
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(content: Text('Done: $data')),
                  );
                },
                onError: (error) {
                  debugPrint('Formless error: $error');
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(content: Text(error)),
                  );
                },
              ),
      ),
    );
  }
}
4
likes
0
points
237
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package that turns any list of fields into an AI-powered conversational form. Validates answers via Groq, OpenAI, Gemini, or DeepSeek and returns a clean key→value map when all fields are collected.

Repository (GitHub)
View/report issues

Topics

#form #ai #llm #chat #validation

License

unknown (license)

Dependencies

flutter, http

More

Packages that depend on formless