FLUTTER ECOSYSTEM

AlakbarHeyderov/hardware_buttons_find_flutter

Em dispositivos móveis com diferentes botões, escute o nome do botão quando os botões forem pressionados.

Capa do projeto hardware_buttons_find_flutter
Stars
11
Forks
1
Último push (UTC)
17 de jan. de 2023
Status do projeto
Ativo
Alakbar GitHub avatar
GITHUB User

Alakbar ↗

MenzilPark LLCAzerbaijan Baku
LinguagensDartJava

Pacotes publicados por este repositório

Dependências usadas

Lista de dependências 4 itens
  • flutter{"sdk":"flutter"}
  • plugin_platform_interface^2.0.2
  • flutter_testDesenvolvimento{"sdk":"flutter"}
  • flutter_lintsDesenvolvimento^2.0.0

README original

Texto original em inglês. Visite o GitHub para a versão atual.

Expandir / recolher README

Hardware Buttons Find Flutter

  • [x] Android

Overview

It is necessary to learn the feedback of buttons on different types of reading devices and take steps based on it. This plugin will help you. This code, written with Stream, always listens to the native code, returning the name of the button to you when the button is pressed. Based on the answer you get, write down the functions you envision.


logo

How to use it

class _MyAppState extends State<MyApp> {
  String? _latestHardwareButtonEvent;

  StreamSubscription<String>? _buttonSubscription;

  @override
  void initState() {
    super.initState();
    _buttonSubscription = HardwareButtons.buttonEvents?.listen((event) {
      setState(() {
        _latestHardwareButtonEvent = event.toString();
      });
    });
  }

  @override
  void dispose() {
    super.dispose();
    _buttonSubscription?.cancel();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Hardware buttons find'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Text('Button name: $_latestHardwareButtonEvent\n'),
            ],
          ),
        ),
      ),
    );
  }
}