focusnode_widgets 0.0.9

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

focusnode_widgets #

Reusable focus node widgets. Can be controlled with keyboard or Remote Control (e.g. on Android TV).

Usage #

To use this plugin, add focusnode_widgets as a dependency in your pubspec.yaml file.

Example #

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

void main() => runApp(MenuForAndroidTV());

class MenuForAndroidTV extends StatefulWidget {
  State<StatefulWidget> createState() {
    return _MenuForAndroidTV();

class _MenuForAndroidTV extends State<MenuForAndroidTV> {
  final String _title = 'focusnode_widgets example for Android TV';
  final String _instructions =
      'Use DPAD up down arrow keyss to navigate and DPAD center key to open the URL';

  bool checked = false;

  Widget build(BuildContext context) {
    final TextTheme textTheme = Theme.of(context).textTheme;

    void launchUrl(BuildContext context) {
      // put code to launch the URL here
      // on android TV url needs to be launched in WebView as per guidelines,
      // browser can't be used

    HyperLinkMenuItem flutterLink = HyperLinkMenuItem(
      displayText: 'Flutter - Beautiful native apps in record time',
      launchUrl: launchUrl,
      autoFocus: true,

    void _onChanged(BuildContext context, bool selected) {
      checked = selected;
      setState(() {});

    CheckboxListTileMenuItem checkboxListTileMenuItem =
      title: DefaultTextStyle(
          style: textTheme.headline,
          child: Text('I accept Terms and Conditions')),
      enterTapActionCallback: _onChanged,
      value: checked,
      controlAffinity: ListTileControlAffinity.leading,

    Text nonFocusableText2 = Text('Non focusable text item 2');

    void _handleEnterTapAction(BuildContext context) {
      final snackBar = SnackBar(
        content: Text('Yay! A SnackBar!'),
        action: SnackBarAction(
          label: 'Undo',
          onPressed: () {
            // Some code to undo the change.

    FocusableSimpleMenuItem focusableSimpleMenuItem = FocusableSimpleMenuItem(
      child: Text('Click, Tap or Press Enter/ OK to show SnackBar'),
      enterTapActionCallback: _handleEnterTapAction,

    Text instructions = Text(_instructions);

    VerticalMenuForAndroidTV verticalMenuForAndroidTV =
      menuItems: [
//        keyPrintMenuItem,
//        keyLogShort,
      focusedBackgroundDecoration: BoxDecoration(
        border: Border.all(color: Colors.amber[900], width: 2),
      constraints: BoxConstraints(
        maxHeight: 40,
        maxWidth: 700,
        minHeight: 10,
        minWidth: 100,

    DefaultTextStyle menu = DefaultTextStyle(
      style: textTheme.headline,
      child: verticalMenuForAndroidTV,

    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: Text(_title)),
        body: menu,

[0.0.9] - 4 Sep 2019

  • Modified HyperLinkMenuItem to not to call the launchUrl internally, provided callback for the same, on android TV url needs to be launched in WebView as per guidelines,

[0.0.8] - 2 Sep 2019

  • Bug fix : D-PAD - center (logical select key was not handled)

[0.0.7] - 2 Sep 2019

  • Support of KeyPrintMenuItem

[0.0.6] - 1 Sep 2019

  • It should be possible to accept any Widget in VerticalMenuForAndroidTV

[0.0.5] - 1 Sep 2019

  • Support of CheckboxListTileMenuItem

[0.0.4] - 1 Sep 2019

  • Support of adding any StatelessWidget to VerticalMenu, It won't receive focus.

  • VerticalMenuForAndroidTV now accepts list of StatelessWidget as menu items

  • Support of FocusableSimpleMenuItem which can be added to VerticalMenuForAndroidTV

  • Support of adding any widget to VerticalMenuForAndroidTV, it won't get focused

  • Added example code in

[0.0.3] - 1 Sep 2019

  • Bug fix, VerticalMenuItem needs to extend from StatelessWidget

[0.0.2] - 31 Aug 2019

  • VerticalMenuForAndroidTV and HyperLinkMenuItem supported,

  • Container parameters are passed to VerticalMenuForAndroidTV which are used to display the MenuItem

  • Example updated

[0.0.1] - 31 Aug 2019

  • Initial Open Source release.


example #

focusnode_widgets package example

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  focusnode_widgets: ^0.0.9

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:focusnode_widgets/focusnode_widgets.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 25, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies