Files
apidash/packages/genai/lib/widgets/ai_config_field.dart
Ankit Mahato 72fea1ba65 Refactor genai package to new modular interface
Reorganized the genai package by removing legacy LLM-related files and introducing a new modular interface under the 'interface' directory. Added provider-specific model classes, centralized constants, and updated the example to use the new API and data structures. Updated exports in genai.dart and improved dependency management.
2025-08-27 02:08:36 +05:30

35 lines
887 B
Dart

import 'package:flutter/material.dart';
import '../models/models.dart';
class AIConfigField extends StatelessWidget {
final bool numeric;
final ModelConfig configuration;
final Function(ModelConfig) onConfigUpdated;
final bool readonly;
const AIConfigField({
super.key,
this.numeric = false,
required this.configuration,
required this.onConfigUpdated,
this.readonly = false,
});
@override
Widget build(BuildContext context) {
return TextFormField(
initialValue: configuration.value.value.toString(),
onChanged: (x) {
if (readonly) return;
if (numeric) {
if (x.isEmpty) x = '0';
if (num.tryParse(x) == null) return;
configuration.value.value = num.parse(x);
} else {
configuration.value.value = x;
}
onConfigUpdated(configuration);
},
);
}
}