Skip to main content

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

A Flutter package for displaying animated emotional states for LLM interactions.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:llm_emotions/flux_animation.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: Colors.black),
      home: const ExampleScreen(),
    );
  }
}

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

  @override
  State<ExampleScreen> createState() => _ExampleScreenState();
}

class _ExampleScreenState extends State<ExampleScreen> {
  final FluxController _controller = FluxController();
  AnimationType _animationType = AnimationType.icon;

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

  void _toggleAnimationType() {
    setState(() {
      _animationType = _animationType == AnimationType.icon
          ? AnimationType.robotFace
          : AnimationType.icon;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('LLM Emotions Example'),
        backgroundColor: Colors.transparent,
        elevation: 0,
        actions: [
          const Text('Icon'),
          Switch(
            value: _animationType == AnimationType.robotFace,
            onChanged: (value) => _toggleAnimationType(),
            activeTrackColor: Colors.purpleAccent,
            inactiveThumbColor: Colors.cyanAccent,
          ),
          const Text('Robot'),
          const SizedBox(width: 20),
        ],
      ),
      body: Stack(
        children: [
          Center(
            child: FluxAnimation(
              controller: _controller,
              type: _animationType,
              key: ValueKey(_animationType),
            ),
          ),
          Positioned(
            bottom: 0,
            left: 0,
            right: 0,
            child: Container(
              height: 140,
              padding: const EdgeInsets.symmetric(vertical: 10),
              decoration: const BoxDecoration(
                gradient: LinearGradient(
                  begin: Alignment.bottomCenter,
                  end: Alignment.topCenter,
                  colors: [Colors.black, Colors.transparent],
                ),
              ),
              child: SingleChildScrollView(
                scrollDirection: Axis.horizontal,
                padding: const EdgeInsets.symmetric(horizontal: 20),
                child: Row(
                  children: CoreState.values
                      .map(
                        (state) => Padding(
                          padding: const EdgeInsets.only(right: 8),
                          child: ActionChip(
                            label: Text(
                              state.name.toUpperCase(),
                              style: const TextStyle(fontSize: 10),
                            ),
                            backgroundColor: _controller.current == state
                                ? Colors.cyanAccent
                                : Colors.grey[900],
                            labelStyle: TextStyle(
                              color: _controller.current == state
                                  ? Colors.black
                                  : Colors.white,
                            ),
                            onPressed: () =>
                                setState(() => _controller.setState(state)),
                          ),
                        ),
                      )
                      .toList(),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
0
likes
150
points
22
downloads

Documentation

API reference

Publisher

verified publisherkanakapalli.in

Weekly Downloads

A Flutter package for displaying animated emotional states for LLM interactions.

Repository (GitHub)

License

MIT (license)

Dependencies

flutter

More

Packages that depend on llm_emotions