lite_switch 1.0.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 82

Lite Switch #

Lite Switch is a customized switch which you can add or change text and icon for "On" and "Off". You can also set the width and height for the switch in your app. Check github: https://github.com/galacticpuffin/lite_switch

Features #

  • [New] Trigger the switch to change through the ValueNotifier
  • Get the switch value change through implementing the onChanged.
  • Set iWidth and iHeight to get the right size for your switch.
  • Customize your text and icon for switch "On" and "Off".

Screenshot #

Usage #

To use this plugin :

Add the dependency to your pubspec.yaml file.
  dependencies:
    flutter:
      sdk: flutter
      lite_switch:

Example #

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

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _LiteSwitchState createState() => new _LiteSwitchState();
}

class _LiteSwitchState extends State<MyApp> {
  final ValueNotifier<bool> SwitchState = new ValueNotifier<bool>(true);
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            LiteSwitch(
              switchState: SwitchState,
              initValue: true,
              textSize: 14.0,
              iWidth: 140,
              iHeight: 60,
              textOn: 'Sound ON',
              textOff: 'Sound Off',
              colorOn: Colors.deepOrange,
              colorOff: Colors.black,
              iconOn: Icons.volume_up,
              iconOff: Icons.volume_off,
              onChanged: (bool state) {
                setState(() {
                  SwitchState.value = !SwitchState.value;
                  print('turned ${(state) ? 'on' : 'off'}');
                });
              },
            ),
            RaisedButton(
              onPressed: () {
                setState(() {
                  SwitchState.value = !SwitchState.value;
                  print(
                      'onPressed ${(SwitchState.value) ? 'on' : 'off'}');
                });
              },
              child: Text("On/Off"),
            ),
            Text("State:${(SwitchState.value) ? 'on' : 'off'}"),
          ],
        ),
      ),
    );
  }
}

[1.0.6] Apri 16, 2020 #

  • Add new ValueNotifier

[1.0.5] Apri 14, 2020 #

  • Fix the value change event bug.

[1.0.4] Apri 14, 2020 #

  • Change class name using UpperCamelName
  • Update Package description
  • fix screenshot link bug
  • Update License
  • Add Example

[1.0.3] Apri 14, 2020 #

  • Fix screenshot link bug

[1.0.2] Apri 14, 2020 #

  • Fix screenshot link

[1.0.1] Apri 14, 2020 #

  • Add screenshot

[1.0.0] Apri 13, 2020 #

  • Init the Customized Switch

example/example.dart

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

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _LiteSwitchState createState() => new _LiteSwitchState();
}

class _LiteSwitchState extends State<MyApp> {
  final ValueNotifier<bool> SwitchState = new ValueNotifier<bool>(true);
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            LiteSwitch(
              switchState: SwitchState,
              initValue: true,
              textSize: 14.0,
              iWidth: 140,
              iHeight: 60,
              textOn: 'Sound ON',
              textOff: 'Sound Off',
              colorOn: Colors.deepOrange,
              colorOff: Colors.black,
              iconOn: Icons.volume_up,
              iconOff: Icons.volume_off,
              onChanged: (bool state) {
                setState(() {
                  SwitchState.value = !SwitchState.value;
                  print('turned ${(state) ? 'on' : 'off'}');
                });

              },
            ),
            RaisedButton(
              onPressed: () {
                setState(() {
                  SwitchState.value = !SwitchState.value;
                  print(
                      'onPressed ${(SwitchState.value) ? 'on' : 'off'}');
                });
              },
              child: Text("On/Off"),
            ),
            Text("State:${(SwitchState.value) ? 'on' : 'off'}"),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  lite_switch: ^1.0.6

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:lite_switch/lite_switch.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
64
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
82
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • lite_switch that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test