system_shortcuts 1.0.0 copy "system_shortcuts: ^1.0.0" to clipboard
system_shortcuts: ^1.0.0 copied to clipboard

ANDROID & IOS flutter plugin to use system shortcuts like pressing home, back, volume Up, volume Down keys and toggle wifi, and bluetooth as well.

example/lib/main.dart

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

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

class Main extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('System Shortcuts'),
        ),
        body: MyApp(),
      ),
    );
  }
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Body();
  }
}

class Body extends StatelessWidget {
  const Body({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
        child: ListView(
      children: <Widget>[
        FlatButton(
          child: Text("Home"),
          onPressed: () async {
            await SystemShortcuts.home();
          },
        ),
        FlatButton(
          child: Text("Back"),
          onPressed: () async {
            await SystemShortcuts.back();
          },
        ),
        FlatButton(
          child: Text("VolDown"),
          onPressed: () async {
            await SystemShortcuts.volDown();
          },
        ),
        FlatButton(
          child: Text("VolUp"),
          onPressed: () async {
            await SystemShortcuts.volUp();
          },
        ),
        FlatButton(
          child: Text("Landscape"),
          onPressed: () async {
            await SystemShortcuts.orientLandscape();
          },
        ),
        FlatButton(
          child: Text("Portrait"),
          onPressed: () async {
            await SystemShortcuts.orientPortrait();
          },
        ),
        FlatButton(
          child: Text("Wifi"),
          onPressed: () async {
            await SystemShortcuts.wifi();
          },
        ),
        FlatButton(
          child: Text("Check Wifi"),
          onPressed: () async {
            bool b = await SystemShortcuts.checkWifi;
            Scaffold.of(context).showSnackBar(
              SnackBar(
                content: Text("Wifi Turned On Check - $b"),
                duration: Duration(seconds: 2),
              ),
            );
          },
        ),
        FlatButton(
          child: Text("Bluetooth"),
          onPressed: () async {
            await SystemShortcuts.bluetooth();
          },
        ),
        FlatButton(
          child: Text("Check Bluetooth"),
          onPressed: () async {
            bool b = await SystemShortcuts.checkBluetooth;
            Scaffold.of(context).showSnackBar(
              SnackBar(
                content: Text("Bluetooth Turned On Check - $b"),
                duration: Duration(seconds: 2),
              ),
            );
          },
        ),
      ],
    ));
  }
}
35
likes
40
pub points
72%
popularity

Publisher

unverified uploader

ANDROID & IOS flutter plugin to use system shortcuts like pressing home, back, volume Up, volume Down keys and toggle wifi, and bluetooth as well.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on system_shortcuts