material_switch 0.0.9

  • Readme
  • Changelog
  • Example
  • Installing
  • 43

material_switch #

A new Flutter package for both android and iOS which helps developers in creating material switch widget using button.

Show some ❤️ and star the repo to support the project

Screenshots #

Material Switch

Usage #


To use this package :

    sdk: flutter

material_switch: ^0.0.5:

How to use #

import 'package:material_switch/material_switch.dart';

class _ExampleState extends State<Example> {
  List<String> switchOptions = ["Male", "Female"];
  String selectedSwitchOption = "Male";

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Material Switch Demo"),
      body: Column(children: <Widget>[
          padding: const EdgeInsets.all(5.0),
          margin: const EdgeInsets.all(5.0),
          selectedOption: selectedSwitchOption,
          options: switchOptions,
          selectedBackgroundColor: Colors.indigo,
          selectedTextColor: Colors.white,
          onSelect: (String selectedOption) {
            setState(() {
              selectedSwitchOption = selectedOption;

Pull Requests #

I welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request. Here are some basic rules to follow to ensure timely addition of your request:

  1. Match coding style (braces, spacing, etc.) This is best achieved using Reformat Code feature of Android Studio CMD+Option+L on Mac and CTRL + ALT + L on Linux + Windows .
  2. If its a feature, bugfix, or anything please only change code to what you specify.
  3. Please keep PR titles easy to read and descriptive of changes, this will make them easier to merge :)
  4. Pull requests must be made against develop branch. Any other branch (unless specified by the maintainers) will get rejected.
  5. Check for existing issues first, before filing an issue.
  6. Make sure you follow the set standard as all other projects in this repo do
  7. Have fun!

Created & Maintained By

Github - Krunal Dodiya Twitter - @kunaldodiya

If you found this project helpful or you learned something from the source code and want to thank me, consider buying me a cup of ☕

License #

Copyright 2018 Krunal dodiya <>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.

Getting Started #

For help getting started with Flutter, view our online documentation.

For help on editing package code, view the documentation.

[0.0.1] - Release

  • A custom switch using (button widget) to toggle between options.

[0.0.2] - Release

  • Updated manual color theme

[0.0.3] - Release

  • Give margin property to adjust switch

[0.0.4] - Release

  • Give padding property to adjust switch

[0.0.5] - Release

  • Typos in example

[0.0.6] - Release

  • Added type checking & dart analyzer

[0.0.7] - Release

  • Added flexible styling

[0.0.8] - Release

  • fixed bugs

[0.0.9] - Release

  • improved performance


example #

A new Flutter project.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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

  material_switch: ^0.0.9

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:material_switch/material_switch.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 20, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running flutter pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.7.0.
 Because material_switch requires SDK version >=1.19.0 <2.1.0, version solving failed.

Health suggestions

Format lib/material_switch.dart.

Run flutter format to format lib/material_switch.dart.

Maintenance issues and suggestions

Support future stable Dart 2 SDKs in pubspec.yaml. (-20 points)

The SDK constraint in pubspec.yaml doesn't allow future stable Dart 2.x SDK releases.

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Package is getting outdated. (-5.21 points)

The package was last published 54 weeks ago.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <2.1.0