build method

  1. @override
dynamic build(
  1. dynamic context
)

Implementation

@override
Widget build(BuildContext context) {
  final l10n = AppLocalizations.of(context)!;
  return AnimatedBuilder(
    animation: controller,
    builder: (context, _) => Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: <Widget>[
        Text(
          l10n.aiPlaygroundTitle,
          style: Theme.of(context).textTheme.headlineSmall,
        ),
        ExpansionTile(
          title: Text(l10n.aiSettings),
          children: <Widget>[PlaygroundSettingsForm(controller: controller)],
        ),
        if (controller.error != null)
          Padding(
            padding: const EdgeInsets.symmetric(vertical: 8),
            child: Text(
              l10n.aiError(controller.error!),
              style: TextStyle(color: Theme.of(context).colorScheme.error),
            ),
          ),
        SizedBox(
          height: 520,
          child: Card(
            child: ChatPanel(
              messages: controller.messages,
              onSend: controller.send,
              onStop: controller.stop,
              busy: controller.busy,
            ),
          ),
        ),
        Align(
          alignment: Alignment.centerRight,
          child: TextButton.icon(
            onPressed: controller.messages.isEmpty ? null : controller.clear,
            icon: const Icon(Icons.restart_alt),
            label: Text(l10n.aiClear),
          ),
        ),
      ],
    ),
  );
}