Torch App Using Flutter

Bilal Rehman
2 min readApr 10, 2021

--

Building a beginner level torch application using flutter.

Introduction

In this Article, you will learn about how to create torch app using flutter step by step.

This is a single screen application which consists of Button and Icon through which you can turn on and turn off mobile torch.

Getting Started

  1. First of all you just need to create a new flutter project:
flutter create torch_app

2. After creating project we are using this package: torch 0.1.1

torch 0.1.1

3. Add torch 0.1.1 or latest version in pubspec.yaml file:

4. After adding package, install the package using flutter pub get in terminal:

flutter pub get

5. After all paste the following code in main.dart file:

Explanation

Explanation of above code

In Home class we make one variable isVisible, Which is use as a condition of true and false like when we open app, isVisible will be true but when we press button then the value of isVisible becomes false and torch will on.

Similarly we make another variable name textt, whose default value is Turn on like this textt=”Turn On” and we make two functions named toff and ton;
In toff, textt becomes “Turn Off”
In ton, textt becomes “Turn On”

Github Link: https://github.com/BilalRehman08/Flutter_Torch_App.git

--

--

Bilal Rehman

Mentored 1000's of Careers | Providing Software Consultancy | Sr. Software Engineer | Flutter Expert