Thanks to visit codestin.com
Credit goes to github.com

Skip to content

backfill custom painter semantics properties #166375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions packages/flutter/lib/src/material/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/// @docImport 'list_tile.dart';
library;

import 'dart:ui';

import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

Expand Down Expand Up @@ -615,16 +617,19 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
leadingWidth: widget.delegate.leadingWidth,
automaticallyImplyLeading: widget.delegate.automaticallyImplyLeading ?? true,
leading: widget.delegate.buildLeading(context),
title: TextField(
controller: widget.delegate._queryTextController,
focusNode: focusNode,
style: widget.delegate.searchFieldStyle ?? theme.textTheme.titleLarge,
textInputAction: widget.delegate.textInputAction,
autocorrect: widget.delegate.autocorrect,
enableSuggestions: widget.delegate.enableSuggestions,
keyboardType: widget.delegate.keyboardType,
onSubmitted: (String _) => widget.delegate.showResults(context),
decoration: InputDecoration(hintText: searchFieldLabel),
title: Semantics(
inputType: SemanticsInputType.search,
child: TextField(
controller: widget.delegate._queryTextController,
focusNode: focusNode,
style: widget.delegate.searchFieldStyle ?? theme.textTheme.titleLarge,
textInputAction: widget.delegate.textInputAction,
autocorrect: widget.delegate.autocorrect,
enableSuggestions: widget.delegate.enableSuggestions,
keyboardType: widget.delegate.keyboardType,
onSubmitted: (String _) => widget.delegate.showResults(context),
decoration: InputDecoration(hintText: searchFieldLabel),
),
),
flexibleSpace: widget.delegate.buildFlexibleSpace(context),
actions: widget.delegate.buildActions(context),
Expand Down
21 changes: 21 additions & 0 deletions packages/flutter/lib/src/rendering/custom_paint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1017,12 +1017,33 @@ class RenderCustomPaint extends RenderProxyBox {
if (properties.hint != null) {
config.hint = properties.hint!;
}
if (properties.identifier != null) {
config.identifier = properties.identifier!;
}
if (properties.tooltip != null) {
config.tooltip = properties.tooltip!;
}
if (properties.hintOverrides != null) {
config.hintOverrides = properties.hintOverrides;
}
if (properties.tagForChildren != null) {
config.addTagForChildren(properties.tagForChildren!);
}
if (properties.controlsNodes != null) {
config.controlsNodes = properties.controlsNodes;
}
if (properties.hint != null) {
config.hint = properties.hint!;
}
if (properties.textDirection != null) {
config.textDirection = properties.textDirection;
}
if (config.validationResult != properties.validationResult) {
config.validationResult = properties.validationResult;
}
if (properties.inputType != null) {
config.inputType = properties.inputType!;
}
if (properties.onTap != null) {
config.onTap = properties.onTap;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/semantics/semantics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,7 @@ class SemanticsProperties extends DiagnosticableTree {
this.role,
this.controlsNodes,
this.inputType,
this.validationResult = SemanticsValidationResult.none,
this.onTap,
this.onLongPress,
this.onScrollLeft,
Expand All @@ -1317,7 +1318,6 @@ class SemanticsProperties extends DiagnosticableTree {
this.onFocus,
this.onDismiss,
this.customSemanticsActions,
this.validationResult = SemanticsValidationResult.none,
}) : assert(
label == null || attributedLabel == null,
'Only one of label or attributedLabel should be provided',
Expand Down
5 changes: 4 additions & 1 deletion packages/flutter/test/cupertino/text_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@Tags(<String>['reduced-test-set'])
library;

import 'dart:ui' as ui show BoxHeightStyle, BoxWidthStyle, Color;
import 'dart:ui' as ui show BoxHeightStyle, BoxWidthStyle, Color, SemanticsInputType;

import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -566,6 +566,7 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 4,
inputType: ui.SemanticsInputType.text,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
Expand Down Expand Up @@ -9757,6 +9758,7 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 4,
inputType: ui.SemanticsInputType.text,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
Expand Down Expand Up @@ -9823,6 +9825,7 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 4,
inputType: ui.SemanticsInputType.text,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
Expand Down
5 changes: 5 additions & 0 deletions packages/flutter/test/material/bottom_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter_test/flutter_test.dart';
import '../widgets/semantics_tester.dart';

Expand Down Expand Up @@ -868,6 +869,7 @@ void main() {
TestSemantics(
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.dismiss],
label: 'Scrim',
hintOverrides: const SemanticsHintOverrides(onTapHint: 'Close Bottom Sheet'),
textDirection: TextDirection.ltr,
),
],
Expand Down Expand Up @@ -1040,6 +1042,7 @@ void main() {
TestSemantics(
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.dismiss],
label: 'Scrim',
hintOverrides: const SemanticsHintOverrides(onTapHint: 'Close Bottom Sheet'),
textDirection: TextDirection.ltr,
),
],
Expand Down Expand Up @@ -1117,6 +1120,7 @@ void main() {
TestSemantics(
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.dismiss],
label: 'Scrim',
hintOverrides: const SemanticsHintOverrides(onTapHint: 'Close Bottom Sheet'),
textDirection: TextDirection.ltr,
),
],
Expand Down Expand Up @@ -1189,6 +1193,7 @@ void main() {
TestSemantics(
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.dismiss],
label: 'Scrim',
hintOverrides: const SemanticsHintOverrides(onTapHint: 'Close Bottom Sheet'),
textDirection: TextDirection.ltr,
),
],
Expand Down
2 changes: 2 additions & 0 deletions packages/flutter/test/material/dropdown_menu_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4174,6 +4174,7 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 5,
inputType: SemanticsInputType.text,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
Expand All @@ -4182,6 +4183,7 @@ void main() {
],
actions: <SemanticsAction>[SemanticsAction.focus],
textDirection: TextDirection.ltr,
currentValueLength: 0,
children: <TestSemantics>[
TestSemantics(
id: 6,
Expand Down
10 changes: 10 additions & 0 deletions packages/flutter/test/material/search_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -677,6 +679,8 @@ void main() {
SemanticsAction.paste,
],
label: 'Search',
currentValueLength: 0,
inputType: SemanticsInputType.search,
textDirection: TextDirection.ltr,
textSelection: const TextSelection(baseOffset: 0, extentOffset: 0),
),
Expand All @@ -702,6 +706,8 @@ void main() {
SemanticsAction.paste,
],
label: 'Search',
currentValueLength: 0,
inputType: SemanticsInputType.search,
textDirection: TextDirection.ltr,
textSelection: const TextSelection(baseOffset: 0, extentOffset: 0),
);
Expand Down Expand Up @@ -877,6 +883,8 @@ void main() {
SemanticsAction.paste,
],
label: 'Search',
inputType: SemanticsInputType.search,
currentValueLength: 0,
textDirection: TextDirection.ltr,
textSelection: const TextSelection(baseOffset: 0, extentOffset: 0),
),
Expand All @@ -902,6 +910,8 @@ void main() {
SemanticsAction.paste,
],
label: 'Search',
inputType: SemanticsInputType.search,
currentValueLength: 0,
textDirection: TextDirection.ltr,
textSelection: const TextSelection(baseOffset: 0, extentOffset: 0),
);
Expand Down
Loading