material_switch 0.0.6

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new13

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

Example

To use this package :

dependencies:
  flutter:
    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";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Material Switch Demo"),
      ),
      body: Column(children: <Widget>[
         MaterialSwitch(
          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 <kunal.dodiya1@gmail.com>

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

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
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

example/example.dart

import 'package:flutter/material.dart';
import 'package:material_switch/material_switch.dart';

class Example extends StatefulWidget {
  @override
  _ExampleState createState() => new _ExampleState();
}

class _ExampleState extends State<Example> {
  List<String> switchOptions = <String>['Male', 'Female'];
  String selectedSwitchOption = 'Male';
  String appTitle = 'Material Switch Demo';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(appTitle),
      ),
      body: Column(children: <Widget>[
        MaterialSwitch(
          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;
            });
          },
        ),
      ]),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  material_switch: ^0.0.6

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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';
  
Version Uploaded Documentation Archive
0.0.6 Aug 17, 2018 Go to the documentation of material_switch 0.0.6 Download material_switch 0.0.6 archive
0.0.5 Aug 15, 2018 Go to the documentation of material_switch 0.0.5 Download material_switch 0.0.5 archive
0.0.4 Aug 13, 2018 Go to the documentation of material_switch 0.0.4 Download material_switch 0.0.4 archive
0.0.3 Aug 13, 2018 Go to the documentation of material_switch 0.0.3 Download material_switch 0.0.3 archive
0.0.2 Aug 12, 2018 Go to the documentation of material_switch 0.0.2 Download material_switch 0.0.2 archive
0.0.1 Aug 12, 2018 Go to the documentation of material_switch 0.0.1 Download material_switch 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
25
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
13
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

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