torch_compat 1.0.2 copy "torch_compat: ^1.0.2" to clipboard
torch_compat: ^1.0.2 copied to clipboard

Plugin to turn on / off the torch (or flash of the camera) on all supported versions of Android (4.1+) and iOS

example/lib/main.dart

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

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

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

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Torch plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              RaisedButton(
                  child: Text('Turn on'),
                  onPressed: () {
                    TorchCompat.turnOn();
                  }),
              RaisedButton(
                  child: Text('Turn off'),
                  onPressed: () {
                    TorchCompat.turnOff();
                  })
            ],
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    // Mandatory for Camera 1 on Android
    TorchCompat.dispose();
    super.dispose();
  }
}
32
likes
40
pub points
77%
popularity

Publisher

verified publisherdaad.mobi

Plugin to turn on / off the torch (or flash of the camera) on all supported versions of Android (4.1+) and iOS

Repository (GitHub)
View/report issues

License

Apache-2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on torch_compat