<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/quick-reliable-calculations-with-a2ui-s-client-side-functions-ag3gyicrc" -->

---
title: Quick, reliable calculations with A2UI&#x27;s Client-Side...
description: A walkthrough of A2UI&#x27;s client-side functions in the genui package for Flutter, showing how an LLM agent can delegate deterministic operations like arithmetic...
canonical: https://daily.dev/posts/quick-reliable-calculations-with-a2ui-s-client-side-functions-ag3gyicrc
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Quick, reliable calculations with A2UI&#x27;s Client-Side Functions | daily.dev
og:description: A walkthrough of A2UI&#x27;s client-side functions in the genui package for Flutter, showing how an LLM agent can delegate deterministic operations like arithmetic...
og:url: https://daily.dev/posts/quick-reliable-calculations-with-a2ui-s-client-side-functions-ag3gyicrc
og:image: https://api.daily.dev/og/posts/ag3gyICRC.png
og:image:alt: Quick, reliable calculations with A2UI&#x27;s Client-Side Functions
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick, reliable calculations with A2UI's Client-Side Functions

**[Flutter](https://daily.dev/sources/flutter)** · 6 min read · 6 upvotes · 1 comments

## Summary

A walkthrough of A2UI's client-side functions in the genui package for Flutter, showing how an LLM agent can delegate deterministic operations like arithmetic to local Dart code instead of computing them itself. The pattern is demonstrated with a CalculateCostFunction class in a sample kitchen assistant app called Commis, covering catalog registration, system prompt integration, and how Gemini emits A2UI messages invoking the function to render accurate, low-latency results with support for Flutter Hot Reload during development.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://flutter.dev/blog/a2ui-client-side-functions>

## Questions this post answers

### How do I create a client-side function in Flutter's genui package so an LLM agent can call local Dart code instead of computing values itself?

Extend SynchronousClientFunction and implement name, description, returnType, argumentSchema (built with json_schema_builder), and executeSync. Register the instance in the functions list of your GenUI Catalog alongside UI components. The genui PromptBuilder automatically extracts the function's name, description, and schema into the system prompt so the LLM can emit an A2UI call with matching arguments, which the SurfaceController evaluates locally via executeSync.

_Developers building agentic Flutter apps can track GenUI and A2UI patterns like this on daily.dev._

### Why should math and calculations be handled by client-side code instead of an LLM in an agentic app?

Offloading arithmetic to on-device Dart code avoids the latency of round-tripping prompts to an LLM, reduces token consumption, and eliminates errors since LLMs aren't reliably designed for precise arithmetic. In a Flutter GenUI example, a CalculateCostFunction computes ingredient costs synchronously and returns a formatted dollar string rendered immediately, rather than asking Gemini to guess the total.

_Anyone weighing LLM-driven versus local computation can follow practical patterns like this via daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@leonidbugaev** · 0 upvotes

> The useful split is which side is allowed to be approximate. Choosing which cost function to call can stay with the model. Computing the total cannot. Put the exact operation in local code with a check that can fail, then let the agent call it. A wrong number should break a unit test, not invite another prompt that asks the model to be careful.

## Similar posts on daily.dev

- [Speeding up generative UI with async A2UI](https://daily.dev/posts/speeding-up-generative-ui-with-async-a2ui-wnqyq30ys) · Flutter · 3 upvotes · 0 comments
- [Guide to Gemini Enterprise and A2UI integration](https://daily.dev/posts/guide-to-gemini-enterprise-and-a2ui-integration-wwj9kzhvm) · Google Cloud · 0 upvotes · 0 comments
- [GenUI Beyond Chat: Caching and Replaying A2UI Lessons with Firebase — Part 2](https://daily.dev/posts/genui-beyond-chat-caching-and-replaying-a2ui-lessons-with-firebase-part-2-sgtfhad4b) · Medium · 0 upvotes · 0 comments
- [A2UI v0.9: The New Standard for Portable, Framework-Agnostic Generative UI](https://daily.dev/posts/a2ui-v0-9-the-new-standard-for-portable-framework-agnostic-generative-ui-s5oyfx03f) · Google Developers · 12 upvotes · 2 comments
- [Is A2UI the Telegram Mini App of AI?](https://daily.dev/posts/is-a2ui-the-telegram-mini-app-of-ai--iuc9xyg9z) · LogRocket · 0 upvotes · 0 comments

---

Tags: [#ai-agents](https://daily.dev/tags/ai-agents), [#flutter](https://daily.dev/tags/flutter), [#dart](https://daily.dev/tags/dart), [#generative-ui](https://daily.dev/tags/generative-ui)

[View this post on daily.dev](https://daily.dev/posts/quick-reliable-calculations-with-a2ui-s-client-side-functions-ag3gyicrc)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Quick, reliable calculations with A2UI's Client-Side Functions","url":"https://daily.dev/posts/quick-reliable-calculations-with-a2ui-s-client-side-functions-ag3gyicrc","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/quick-reliable-calculations-with-a2ui-s-client-side-functions-ag3gyicrc"},"datePublished":"2026-08-28T23:25:03.406Z","dateModified":"2026-09-14T08:58:55.805Z","description":"A walkthrough of A2UI's client-side functions in the genui package for Flutter, showing how an LLM agent can delegate deterministic operations like arithmetic...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ecdd5c5e18af0d3c7a2cd87410a572d?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ecdd5c5e18af0d3c7a2cd87410a572d?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Flutter","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Flutter","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/flutter","url":"https://daily.dev/sources/flutter"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/quick-reliable-calculations-with-a2ui-s-client-side-functions-ag3gyicrc","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":6},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"ai-agents,flutter,dart,generative-ui","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Flutter","item":"https://daily.dev/sources/flutter"},{"@type":"ListItem","position":3,"name":"Quick, reliable calculations with A2UI's Client-Side Functions"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/quick-reliable-calculations-with-a2ui-s-client-side-functions-ag3gyicrc","comment":[{"@type":"Comment","text":"The useful split is which side is allowed to be approximate. Choosing which cost function to call can stay with the model. Computing the total cannot. Put the exact operation in local code with a check that can fail, then let the agent call it. A wrong number should break a unit test, not invite another prompt that asks the model to be careful.","datePublished":"2026-08-30T07:04:20.642Z","url":"https://daily.dev/posts/ag3gyICRC#c-WEfyGnj5d","author":{"@type":"Person","name":"Leonid Bugaev","url":"https://daily.dev/leonidbugaev","image":"https://lh3.googleusercontent.com/a/ACg8ocLhMgurwTmJElWaH9A8Ju8cHvZxgMCDt009jEYkmFCyUGAoaGSw=s96-c"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/quick-reliable-calculations-with-a2ui-s-client-side-functions-ag3gyicrc#faq","mainEntity":[{"@type":"Question","name":"How do I create a client-side function in Flutter's genui package so an LLM agent can call local Dart code instead of computing values itself?","acceptedAnswer":{"@type":"Answer","text":"Extend SynchronousClientFunction and implement name, description, returnType, argumentSchema (built with json_schema_builder), and executeSync. Register the instance in the functions list of your GenUI Catalog alongside UI components. The genui PromptBuilder automatically extracts the function's name, description, and schema into the system prompt so the LLM can emit an A2UI call with matching arguments, which the SurfaceController evaluates locally via executeSync. Developers building agentic Flutter apps can track GenUI and A2UI patterns like this on daily.dev."}},{"@type":"Question","name":"Why should math and calculations be handled by client-side code instead of an LLM in an agentic app?","acceptedAnswer":{"@type":"Answer","text":"Offloading arithmetic to on-device Dart code avoids the latency of round-tripping prompts to an LLM, reduces token consumption, and eliminates errors since LLMs aren't reliably designed for precise arithmetic. In a Flutter GenUI example, a CalculateCostFunction computes ingredient costs synchronously and returns a formatted dollar string rendered immediately, rather than asking Gemini to guess the total. Anyone weighing LLM-driven versus local computation can follow practical patterns like this via daily.dev."}}]}
```

