ToggleButton (Select Unselect) In Flutter

ToggleButton (Select Unselect) In Flutter :

ToggleButton (Select Unselect) In Flutter
  ToggleButton(
                            buttonName: "Lesson 1",
                            buttonColor: AppTheme.Colors.flatOrange,
                            isPressed: true,
                          ),

import 'package:flutter/material.dart';
import 'package:education_app/utils/Theme.dart' as AppTheme;

class ToggleButton extends StatefulWidget {
  String buttonName;
  Color buttonColor;
  bool isPressed;

  ToggleButton({this.buttonColor, this.buttonName, this.isPressed});

  @override
  _ToggleButtonState createState() => _ToggleButtonState();
}

class _ToggleButtonState extends State<ToggleButton> {
  @override
  Widget build(BuildContext context) {
    return Padding(
        padding: const EdgeInsets.only(top: 10, bottom: 10, right: 10),
        child: InkWell(
          onTap: () {
            this.setState(() {
              widget.isPressed = !widget.isPressed;
            });
          },
          child: Container(
            foregroundDecoration: !widget.isPressed
                ? BoxDecoration(
                    borderRadius: BorderRadius.circular(8),
                    color: Colors.white.withOpacity(0.7),
                  )
                : null,
            padding: EdgeInsets.symmetric(horizontal: 20),
            child: Align(
              alignment: Alignment.center,
              child: Text(
                widget.buttonName,
                style: AppTheme.TextTheme.regularTextWhite,
              ),
            ),
            decoration: BoxDecoration(
                color: widget.buttonColor,
                borderRadius: BorderRadius.circular(8),
                boxShadow: [
                  BoxShadow(
                      color: widget.buttonColor.withOpacity(0.4),
                      blurRadius: 8,
                      offset: Offset(0.0, 3))
                ]),
          ),
        ));
  }
}

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in