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

outdated

A controller to manage torch/flash device resource. We give you access to native resources to toggle flashlight, to natively check torch status and more!

example/lib/main.dart

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

void main() {
  TorchController().initialize();
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  final controller = TorchController();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: [
              FutureBuilder<bool?>(
                  future: controller.isTorchActive,
                  builder: (_, snapshot) {
                    final snapshotData = snapshot.data ?? false;

                    if (snapshot.connectionState == ConnectionState.done)
                      return Text(
                          'Is torch on? ${snapshotData ? 'Yes!' : 'No :('}');

                    return Container();
                  }),
              MaterialButton(
                  child: Text('Toggle'),
                  onPressed: () {
                    controller.toggle(intensity: 1);
                    setState(() {});
                  }),
            ],
          ),
        ),
      ),
    );
  }
}
25
likes
0
pub points
88%
popularity

Publisher

unverified uploader

A controller to manage torch/flash device resource. We give you access to native resources to toggle flashlight, to natively check torch status and more!

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on torch_controller