Last active
August 2, 2023 21:23
-
-
Save yjbanov/26d2772e6a3afcdf0742436177599e2b to your computer and use it in GitHub Desktop.
Demonstrates an issue in semantic node focusability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:ui_web' as ui_web; | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/rendering.dart'; | |
import 'package:web/web.dart' as web; | |
void main() async { | |
_registerFactory(); | |
runApp(const MyApp()); | |
if (kIsWeb) { | |
SemanticsBinding.instance.ensureSemantics(); | |
} | |
await Future<void>.delayed(const Duration(seconds: 2)); | |
debugDumpSemanticsTree(); | |
} | |
void _registerFactory() { | |
ui_web.platformViewRegistry.registerViewFactory('dom_button', (int viewId) { | |
final web.HTMLElement htmlElement = | |
web.document.createElement('button') as web.HTMLDivElement; | |
htmlElement.innerText = 'Button 2'; | |
htmlElement.style | |
..setProperty('width', '100%') | |
..setProperty('height', '100%'); | |
return htmlElement; | |
}); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return const MaterialApp( | |
title: 'Focusable platform view', | |
home: Scaffold( | |
body: SizedBox( | |
height: 100.0, | |
child: HtmlElementView(viewType: 'dom_button'), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The semantics tree for this UI: