Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks
How to Create Checkbox in Flutter

How to Create Checkbox in Flutter?

Aman Jain, September 12, 2022March 16, 2024

In this tutorial we will learn to create checkbox in flutter application. Checkbox is used to provide multiple options to users and they can select multiple value for same input. Usage of checkbox input can be for remember me, check terms and condition, multiple answers questions choices and etc.

Flutter providers most of the widgets and input like checkbox, text field, password, textarea and in this article we will create the simple checkbox with check and uncheck values.

You can simple create checkbox as follow

Checkbox(
      value: rememberMe,
      onChanged:(bool newValue){
        setState((){
        rememberMe=newValue;
        });
      }
);

Checkbox with label in flutter

In flutter we can also create checkbox with label using the CheckboxListTile widget. CheckboxListTile accepts title in which we can define the text of label as follow

 CheckboxListTile(
    title: Text("title text"),  
    value: checkedValue,
    onChanged: (newValue) { ... },
  )

Let’s understand create checkbox in Flutter Application with an example

Step 1 : Create flutter project

Very first step is to create the fluter application using command line tool or in Android studio.

flutter create example_app

This will create a new project with name my_app then go in to the folder .

Step 2 : Create a simple widget

Now, Create a simple statefull widget to create the checkbox

File : lib/checkboxexample.dart


class CheckBoxExample extends StatefulWidget {
  const CheckBoxExample({Key? key}) : super(key: key);

  @override
  State<CheckBoxExample> createState() => _CheckBoxExampleState();
}

class _CheckBoxExampleState extends State<CheckBoxExample> {
  bool checkedValue=false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Checkbox Example '),
      ),
      body:Center(
        child: Checkbox(
          value: checkedValue,
          activeColor: Colors.greenAccent,
          checkColor: Colors.black,


          onChanged: (bool ?value){
            setState(() {
              checkedValue=value!;
            });
          },

        ),
      ),
    );
  }
}

Step 3: Import and use the widget in main

We just created a new widget with name CheckBoxExample, now we are going to use it in our main.dart file as below

import 'package:flutter/material.dart'; 
import 'package:example_app/checkboxexample.dart';;

void main() {
  runApp(const AppRouter());
}

class AppRouter extends StatelessWidget {
  const AppRouter({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'Remove Banner',
        home:  CheckBoxExample()
    );

  }
}

Step 4 : Update main.dart file

Now, open the main.dart file and add the debugShowCheckedModeBanner with value false to Material App

File : lib/main.dart

import 'package:example_app/assetimagedemo.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,  // <-- add this
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const  Container(child:Text("Test")),
    );
  }
}

Step 5: Run the project

Simply run the project using command line or in android studio to check the implementation.

flutter run lib/main.dart

Screenshot :

checkbox example flutter
checkbox example flutter

Read Also : How to create routing in flutter and pass parameters to routes ?

Related

Dart Flutter checkboxcustomFluttter

Post navigation

Previous post
Next post

Related Posts

Dart How to add one side border to container widget flutter

How to add one side border to container widget flutter?

September 17, 2022March 16, 2024

In this tutorial we will learn to add add one side border to container widget flutter. Border is used to create border around the widget or container and using the border we can style it in different way like adding the width of border, color of border and one side…

Read More
Dart Create Drawer in flutter

How to create drawer in flutter with example ?

January 3, 2022January 15, 2022

Flutter itself provides various widgets to create the industry level standard layout. One of the feature of flutter is creating default drawer in flutter with Scaffold. Using the drawer we can show our application menus list and hide show in sidebar. In this s tutorial i will create a simple…

Read More
Dart How to add rounded border radius to image in flutter

How to add rounded border radius to image in flutter ?

September 19, 2022March 16, 2024

In this article we will learn to add rounded border radius to image in flutter. In flutter rounded corner border can be added using borderRadius but to add the rounded border to image is not same because by adding the border radius to container it won’t apply to child image….

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • The Transformative Power of Education in the Digital Age
  • Understanding High Vulnerabilities: A Closer Look at the Week of July 14, 2025
  • Exploring Fresh Resources for Web Designers and Developers
  • The Intersection of Security and Technology: Understanding Vulnerabilities
  • Mapping Together: The Vibrant Spirit of OpenStreetMap Japan
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version