如何解决在 Flutter web 中使用语义小部件?
如何在 Flutter Web 中使用 Semantics 小部件,是否可以将其与自定义小部件一起使用,例如定制的 Button、Text 或一些带有 GestureDetector 的定制容器?我尝试在应用程序中包装几个小部件,但似乎都不起作用。唯一可用的小部件是 TextFormFiled 小部件,但它也有一些问题。
某些小部件是否应该可以聚焦以便语义工作?我也试过增加焦点,但同样没有进展。
这在 Flutter web 中是否可行?
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
// showSemanticsDebugger: true,home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[
Semantics(
label: "Text Widget",hint: "Some text",child: Text('Lorem Ipsum'),),SizedBox(height: 50),Semantics(
button: true,label: "Button Widget",hint: "Click Button",child: TextButton(
onPressed: () => {},child: Text('Click me'),Semantics(
textField: true,label: "Input Widget",hint: "Enter text",child: Container(
width: 200,child: TextFormField(
decoration: InputDecoration(
labelText: "Label",Semantics(
label: "Custom Container Widget",hint: "Custom Container",height: 50,decoration: BoxDecoration(
color: Colors.grey,],);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。