there is simple code snippet
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: InAppWebView(
initialUrlRequest: URLRequest(url: Uri.parse('https://github.com')),
),
),
),
);
}
I created an android tv emulator and run this code.
It shows loaded google site but I can't change focus by pressing Tab button on my phisycal keyboard and dpad doesn't work either.
Also I tried on the real android tv device.
Anyone know how to fix it?
I think I'm missing something trivial here.
I'm using RawKeyboard.instance.addListener(_keyboardListener);
void _keyboardListener(RawKeyEvent event) {
if (event.runtimeType != RawKeyDownEvent) return;
if (LogicalKeyboardKey.arrowLeft == event.logicalKey) {
\\
} else if (LogicalKeyboardKey.arrowRight == event.logicalKey) {
\\
} else if (LogicalKeyboardKey.arrowUp == event.logicalKey) {
index = index - 1;
} else if (LogicalKeyboardKey.arrowDown == event.logicalKey) {
index = index + 1;
index = index.clamp(0, maxIndex);
_controller?.evaluateJavascript(
source: ''
'var arr = document.querySelectorAll("[tabindex]:not([tabindex=\\"-1\\"])");'
'arr[$index].focus();'
'var ss = arr[$index];'
'console.log("---!!--" + $index);',
);
}
Where int index = 0;
is index of focused html element.
On emulator I have to click somewhere on web page background and after that I'm able to move focus down and up.
The main issue is I can't do it on real device :)
UPDATE: ok, there is new info
before I tested it with some url then I can't show here. But for example I specified goodle url. And it works. Even I don't need to add listeners and run scripts.
But then I tried with https://github.com
and it won't work.