lamp 0.0.2

  • Example
  • Installing
  • Versions
  • 77


pub package A Flutter plugin to access the device's lamp/torch on Android and iOS.


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


// Import package
import 'package:lamp/lamp.dart';

// Turn the lamp on:

// Turn the lamp off:

// Turn the lamp with a specific intensity (only affects iOS as of now):
Lamp.turnOn(intensity: 0.4);

// Check if the device has a lamp:
bool hasLamp = await Lamp.hasLamp;

[0.0.1] - January 23rd, 2018.

  • Initial release


import 'package:flutter/material.dart';
import 'package:lamp/lamp.dart';
import 'dart:async';

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

class MyApp extends StatefulWidget {
  _MyAppState createState() => new _MyAppState();

class _MyAppState extends State<MyApp> {
  bool _hasFlash = false;
  bool _isOn = false;
  double _intensity = 1.0;

  initState() {

  initPlatformState() async {
    bool hasFlash = await Lamp.hasLamp;
    print("Device has flash ? $hasFlash");
    setState(() { _hasFlash = hasFlash; });

  Widget build(BuildContext context) {
    return new MaterialApp(
      theme: new ThemeData(primarySwatch:,
      home: new Scaffold(
        appBar: new AppBar(title: new Text('Lamp plugin example')),
        body: new Center(
          child: new Column(
              children: <Widget>[
            new Text('Device has flash: $_hasFlash\n Flash is on: $_isOn'),
            new Slider(value: _intensity, onChanged: _isOn ? _intensityChanged : null)
        floatingActionButton: new FloatingActionButton(
          child: new Icon(_isOn ? Icons.flash_off : Icons.flash_on),
          onPressed: _turnFlash),

  Future _turnFlash() async {
    _isOn ? Lamp.turnOff() : Lamp.turnOn(intensity: _intensity);
    var f = await Lamp.hasLamp;
      _hasFlash = f;
      _isOn = !_isOn;

  _intensityChanged(double intensity) {
    Lamp.turnOn(intensity : intensity);
      _intensity = intensity;


1. Depend on it

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

  lamp: "^0.0.2"

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:lamp/lamp.dart';
Version Uploaded Documentation Archive
0.0.2 Jan 23, 2018 Go to the documentation of lamp 0.0.2 Download lamp 0.0.2 archive
0.0.1 Jan 23, 2018 Go to the documentation of lamp 0.0.1 Download lamp 0.0.1 archive


We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.49.0
  • pana: 0.10.6
  • Flutter: 0.3.2


Describes how popular the package is relative to other packages. [more]
59 / 100
Code health derived from static analysis. [more]
90 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run flutter format to format lib/lamp.dart.


Package Constraint Resolved Available
Direct dependencies
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.9
meta 1.1.2
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6