Skip to content

fix: map TextField border keyword onto the iOS field decoration - #53

Merged
AdamMusa merged 2 commits into
codex/engine-initializationfrom
fix/cupertino-textfield-border-none
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
codex/engine-initializationfrom
fix/cupertino-textfield-border-none

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Engine-only fix (no Ruby change; border, border_color, border_width, border_radius, filled, fill_color and bgcolor are already TextField keywords).

Problem

On iOS, text_field(border: "none") still drew the native rounded border and white fill. Inside cupertino_textfield.dart:

  1. The string "none" reached the Border-map parser, which threw.
  2. The catch left border null.
  3. defaultDecoration.copyWith(border: null, color: null, ...) keeps the default border, fill and radius.

This breaks the documented form_row(text_field(border: "none"), ...) pattern from Package B (engine #21 / ruflet #37). The other string values were off too: "outline" and "underline" drew a hard-coded 1 dp black line instead of the native separator hairline, and filled/fill_color were ignored on iOS.

Fix

One _decoration() helper in the Cupertino renderer, with no Material symbols:

Ruby border iOS rendering
absent native rounded field (unchanged)
Border map ({bottom: {...}}) that border on the native field (unchanged)
"outline" rounded Border.all with the native hairline color/width unless border_color/border_width are given; border_width: 0 removes it (same as Material)
"underline" bottom rule only (native hairline by default), square corners (unless border_radius), no fill
"none" no decoration at all (decoration: null): no border, no fill, and no gray box when disabled

These still paint on any style: bgcolor, filled: true (fill_color ?? bgcolor ?? CupertinoColors.tertiarySystemFill, the iOS filled-field color), gradient, image and shadows. For example, border: "none", filled: true gives a borderless filled field like a search field. border_radius defaults to the native 5 dp. Unknown border strings fall back to the native field with a debugPrint.

Material is unchanged; form_field.dart is untouched.

Visible changes

On iOS, an explicit border: "outline" or border: "underline" now renders the native grey hairline instead of a 1 dp black line, and underline no longer has the white fill. Apps that want the old look can set border_color: "black", border_width: 1:

text_field(border: "outline", border_color: "black", border_width: 1)

Fields without a border keyword, and Material, look exactly as before.

Tests

test/widgets/ruby_text_field_border_test.dart (6 tests):

  • iOS none:
    • CupertinoTextField.decoration == null, and no DecoratedBox with a border or fill is painted. This holds for disabled fields too.
    • Same field size and 7 dp text inset as the native field.
  • iOS none + background: bgcolor, filled and fill_color paint a fill with no border.
  • iOS outline:
    • The default is the native hairline, radius 5 and white fill.
    • border_color/border_width: 2 give a red 2 dp border, which grows the field by 4 dp and insets the text by 2 dp. A BoxDecoration border adds to layout padding.
    • border_width: 0 removes the border, and border_radius is honored.
  • iOS underline: bottom rule only, BorderRadius.zero, no fill. A 1 dp rule grows the field by 1 dp versus the hairline; filled adds the fill.
  • iOS Border map: still honored on the native field.
  • Material, no regression: absent/outline → OutlineInputBorder, underline → UnderlineInputBorder, none → InputBorder.none, and filled + fill_color still fill. No Cupertino widgets render on Android.

Before the fix, the 4 string-border iOS tests failed (none kept the native decoration; outline/underline were 1 dp black). The map and Material tests passed before and after.

Form-row check (not committed): on a throwaway merge of this branch with origin/feat/form-row (#21), form_row(prefix: "Name", content: text_field(border: "none", expand: 1)) on iOS renders CupertinoFormRow with no field box, and the text vertically aligned with and right of the prefix. The same test on #21 alone fails with the native BoxDecoration. The two branches merge cleanly.

verify_pr.sh (Flutter 3.41.2):

PASS engine:ruflet flutter test         +701: All tests passed!
PASS engine:ruflet analyze              No issues found!
RESULT: PASS

On iOS, border: "none" still drew the native rounded border and white
fill: the string reached the Border-map parser, which threw, and a null
border left CupertinoTextField's default decoration in place. This broke
form_row(text_field(border: "none"), ...) layouts.

Resolve the border style explicitly. none paints nothing (decoration
null, so disabled fields get no gray box either); outline and underline
use the native hairline unless border_color/border_width are given
(width 0 removes the line) instead of a hard-coded 1 dp black line;
underline has square corners and no fill; absent or a Border map keeps
the native field. filled/fill_color now paint a background on iOS too.
Material is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant