Chuyển đến nội dung chính

Bài đăng

Hiển thị các bài đăng có nhãn UX

Flutter forms past the toy example: async validation, focus, and autofill

The Flutter form cookbook gets you to a working sign-up screen in about forty lines. Then a designer looks at it and you discover that the errors flash before anyone has typed, the Enter key does nothing, the password manager ignores the fields, and on a small phone the keyboard covers the field you are editing. None of those are validation problems. They are the parts of “a form” that the tutorial does not model. The three objects, and what each owns Form is a coordinator, not a layout. It holds a FormState that can validate() , save() and reset() every FormField beneath it in the tree. FormField owns one value, its error string, and whether it has been touched. TextFormField is a FormField wrapped around a TextField . final _formKey = GlobalKey < FormState >(); Form ( key : _formKey, child : Column (children : [ TextFormField ( decoration : const InputDecoration (labelText : 'Email' ), validator : (value) => (...

Streaming UX: designing for tokens arriving one at a time

A twelve-second response with a spinner feels broken. The same twelve seconds with text appearing after 400ms feels fast. Nothing about the model changed — only what the user could see while waiting. That is the whole argument for streaming, and it is a good one. What follows is the set of problems you inherit along with it. The plumbing, briefly Both major providers stream over server-sent events: a long-lived HTTP response of data: lines, each carrying a JSON event. The events that matter are the ones that append text, the ones that signal a content block starting or finishing, and the terminal event that carries the stop reason and final usage numbers. Two structural rules: Never stream directly from a browser or mobile client to the provider. Doing so puts your API key on the device. Proxy through your own endpoint, which also gives you a place to log, rate-limit and enforce guardrails. Your proxy should stream out as it streams in , not buffer. If you await the full upst...