Port to TV

Port to TV #

Here are instructions on how to port you Flutter application to Android TV and Google TV.

Based on How to create TV app using Flutter

Code snippets #

To make select key work on Chromecast with Google TV you need to wrap you App widget like this:

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Shortcuts(
      shortcuts: <LogicalKeySet, Intent>{
        LogicalKeySet(LogicalKeyboardKey.select): const ActivateIntent(),
      },
      child: MaterialApp( /* ... */ ),
    );
  }
}

Then change your android/app/src/main/AndroidManifest.xml to include:

<manifest ...>
    <uses-feature android:name="android.software.leanback" android:required="false" />
    <uses-feature android:name="android.hardware.touchscreen" android:required="false" />

    <application
        ...
        android:banner="@drawable/banner"
        ...
    >
        <activity ...>
            <intent-filter>
                ...
                <category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

Where banner is a 320x180px PNG located at android/app/src/main/res/drawable/banner.png.