<!-- 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 let a Gemini agent perform calculations locally in a Flutter GenUI app instead of computing them itself?

Create a class extending SynchronousClientFunction in the genui package, defining a name, description, return type, and JSON argument schema, then implement executeSync to run the math in Dart. Register the function in the app's Catalog functions list so PromptBuilder exposes its name, description, and schema to the LLM's system prompt, letting the agent call it via an A2UI expression instead of computing values itself.

_daily.dev surfaces practical Flutter and GenUI patterns for developers wiring agent logic into client apps._

### Why shouldn't an LLM agent handle arithmetic directly in a generative UI app?

Asking a large language model to do arithmetic introduces latency from network round-trips and increases the chance of calculation errors, since models aren't inherently reliable at precise math. Offloading operations like ingredient costs, tax totals, or unit conversions to local Dart code via client-side functions avoids this overhead, cuts token usage, and produces consistently formatted, accurate results rendered immediately on device.

_developers evaluating where to draw the line between AI reasoning and local logic can track these patterns on 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

---

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

[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-08-28T23:25:27.075Z","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","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 let a Gemini agent perform calculations locally in a Flutter GenUI app instead of computing them itself?","acceptedAnswer":{"@type":"Answer","text":"Create a class extending SynchronousClientFunction in the genui package, defining a name, description, return type, and JSON argument schema, then implement executeSync to run the math in Dart. Register the function in the app's Catalog functions list so PromptBuilder exposes its name, description, and schema to the LLM's system prompt, letting the agent call it via an A2UI expression instead of computing values itself. daily.dev surfaces practical Flutter and GenUI patterns for developers wiring agent logic into client apps."}},{"@type":"Question","name":"Why shouldn't an LLM agent handle arithmetic directly in a generative UI app?","acceptedAnswer":{"@type":"Answer","text":"Asking a large language model to do arithmetic introduces latency from network round-trips and increases the chance of calculation errors, since models aren't inherently reliable at precise math. Offloading operations like ingredient costs, tax totals, or unit conversions to local Dart code via client-side functions avoids this overhead, cuts token usage, and produces consistently formatted, accurate results rendered immediately on device. developers evaluating where to draw the line between AI reasoning and local logic can track these patterns on daily.dev."}}]}
```

