Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
leanback android tv
  • Add software leanback feature in AndroidManifest
<uses-feature android:name="android.software.leanback" android:required="false" />
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  • Add banner icon xhdpi 320x180 px for banner
<application .... android:banner="@mipmap/banner">
  • Add LEANBACK_LAUNCHER intent filter
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
  • At flutter app use Shotcut widget for use a remote control for navigation
  @override
  Widget build(BuildContext context) {
    return Shortcuts(
      shortcuts: {
        LogicalKeySet(LogicalKeyboardKey.select): ActivateIntent(),
      },
      child: MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
          visualDensity: VisualDensity.adaptivePlatformDensity,
        ),
        home: MyHomePage(title: 'Flutter Demo Home Page'),
      ),
    );
  }
@langziyang

This comment has been minimized.

Copy link

@langziyang langziyang commented Mar 22, 2021

if page have TextField() widget,the button always can not focus, you can try it:
`
import 'dart:developer';

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

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Shortcuts(
shortcuts: {
LogicalKeySet(LogicalKeyboardKey.select): ActivateIntent(),
},
child: MaterialApp(
home: HomePage(),
),
);
}
}

class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}

class _HomePageState extends State {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
child: Text("Button 1"),
onPressed: () {
log('button 1 pressed');
},
),
ElevatedButton(
child: Text("Button 2"),
onPressed: () {
log('button 2 pressed');
},
),
TextField(
focusNode: ,
)
],
),
),
));
}
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment