ListTileSwitch is simple widget that combines ListTile with a switch.

Overview

ListTileSwitch

Build Status Codemagic build status Coverage Status

ListTileSwitch is a simple widget that combines ListTile with a switch. Offering 3 types of switch widgets:

  1. Switch: Material Switch from Material library on Flutter SDK.
  2. CupertinoSwitch: CupertinoSwitch from Cupertino library on Flutter SDK.
  3. A custom switch.

Demo

Tested on Android and Web but not iOS. Theoritacially it should work on iOS devices too, since this package contains nothing but pure Dart and Flutter components.

Installation

Add dependency for package on your pubspec.yaml:

dependencies:
    list_tile_switch: 
   

   

Usage

Use it as a regular ListTile widget with a bonus: the trailing widget is a switch. Covering all aspects of the ListTile and adding more with a custom switch.

Parameter Definition
double switchScale Adjusting the scale of the switch widget.
Color switchActiveColor The color of the switch when the switch is active.
bool toggleSelectedOnValueChange Deciding whether to color the ListTile when switch value is true, the selected color will be the switchActiveColor.
Color switchInactiveColor Color when the switch is inactive.
SwitchType switchType Indicating the type of switch to be displayed.
bool value Current state of the switch value.
onChanged(bool) Toggle callback for the widget.
Widget leading, Widget title, Widget subtitle, Widget isThreeLine, EdgeInsetsGeometry contentPadding, VoidCallback onLongPress, VisualDensity visualDesnsity, bool dense, bool enabled, FocusNode focusNode, bool autoFocus, bool selected, Color focusColor, Color hoverColor, MouseCursor mouseCursor Referring to the original implementation of ListTile from Flutter SDK, all of the values are mapped directly to the ListTile widget internally.

Example

import 'package:flutter/material.dart';  
import 'package:list_tile_switch/list_tile_switch.dart';  
  
void main() {  
  runApp(MyApp());  
}  
  
class MyApp extends StatelessWidget {  
  @override  
  Widget build(BuildContext context) {  
  return MaterialApp(  
  title: 'Flutter ListTileSwitch Demo',  
  debugShowCheckedModeBanner: false,  
  theme: ThemeData(  
  primarySwatch: Colors.blue,  
  visualDensity: VisualDensity.adaptivePlatformDensity,  
 ),  home: ListTileSwitchExample(title: 'Flutter ListTileSwitch Demo'),  
 ); }}  
  
class ListTileSwitchExample extends StatefulWidget {  
  ListTileSwitchExample({Key key, this.title}) : super(key: key);  
  final String title;  
  @override  
  _ListTileSwitchExampleState createState() => _ListTileSwitchExampleState();  
}  
  
class _ListTileSwitchExampleState extends State
   
     {  
  bool _value = false;  
  @override  
  Widget build(BuildContext context) {  
    return Scaffold(  
	  appBar: AppBar(  
		title: Text(widget.title),  
	  ),
	  body: ListTileSwitch(  
	    value: _value,  
		leading: Icon(Icons.access_alarms),  
		onChanged: (value) {  
		  setState(() {  
			_value = value;  
		  });
		},
		visualDensity: VisualDensity.comfortable,
		switchType: SwitchType.cupertino,
		switchActiveColor: Colors.indigo,  
		title: Text('Default Custom Switch'),  
	 ),
   );
}}

   

Todo

The list of additional features that are considered to be implemented in the future.

  • Creating more tests
  • Add interactivity to custom switch widget
  • Make custom switch more configurable
    • Configurable thumb shape
    • Configurable track shape
    • Scaling animation on value change

Contribution

Contributions are accepted via pull requests. For more information about how to contribute to this package, please check the contribution guide.

License

This project is licensed under the MIT license, additional knowledge about the license can be found here.

You might also like...

A Flutter widget that will give a Glitch Animation Effect to it's child widget.

A Flutter widget that will give a Glitch Animation Effect to it's child widget.

GlitchEffect A Flutter widget that will give a Glitch Animation Effect to it's child widget. Installation Add the latest version of package to your pu

Nov 25, 2022

A simple Flutter widget library that helps us to select days in a week.

A simple Flutter widget library that helps us to select days in a week.

A simple Flutter widget library that helps us to select days in a week.

Oct 9, 2022

A sliding up panel widget which can be used to show or hide content, beautiful and simple.

A sliding up panel widget which can be used to show or hide content, beautiful and simple.

flutter_sliding_up_panel A sliding up panel widget which can be used to show or hide content, beautiful and simple. demo Getting Started dependencies:

Dec 12, 2022

Global loading widget, which can be used through simple configuration.

Global loading widget, which can be used through simple configuration.

load Global loading widget, which can be used through simple configuration. Pure flutter library, not use native code. It is similar to OKToast in use

Nov 4, 2022

A simple zoomable image/content widget for Flutter.

A simple zoomable image/content widget for Flutter.

📸 Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interacive images and other stuff such as SVG.

Jan 1, 2023

A popup simple topModalSheet menu button widget with handsome design and easy to use

A popup simple topModalSheet menu button widget with handsome design and easy to use

top_modal_sheet A popup simple topModalSheet menu button widget with handsome design and easy to use. Installations Add top_modal_sheet: ^1.0.0 in you

Jul 29, 2022

React hooks for Flutter. Hooks are a new kind of object that manages a Widget life-cycles. They are used to increase code sharing between widgets and as a complete replacement for StatefulWidget.

English | Português Flutter Hooks A Flutter implementation of React hooks: https://medium.com/@dan_abramov/making-sense-of-react-hooks-fdbde8803889 Ho

Dec 29, 2022

A credit card widget for Flutter application.

A credit card widget for Flutter application.

A credit card widget for Flutter application.

Dec 27, 2022

Flutter debug helper widget with common and custom actions

Flutter debug helper widget with common and custom actions

Flutter debug helper widget with common and custom actions

Dec 7, 2022
Comments
Owner
Fırat Çetiner
Computer Engineer
Fırat Çetiner
An advanced switch widget, that can be fully customized with size, text, color, radius of corners.

flutter_advanced_switch An advanced switch widget, that can be fully customized with size, text, color, radius of corners. Switch Light Switch Dark Ge

Alex Melnyk 13 Dec 15, 2022
A highly customizable toggle switch with a loading state.

A highly customizable toggle switch with a loading state.

null 6 Dec 30, 2022
A simple Flutter widget to add in the widget tree when you want to show nothing, with minimal impact on performance.

nil A simple widget to add in the widget tree when you want to show nothing, with minimal impact on performance. Why? Sometimes, according to a condit

Romain Rastel 127 Dec 22, 2022
A flutter carousel widget, support infinite scroll, and custom child widget.

carousel_slider A carousel slider widget. Features Infinite scroll Custom child widgets Auto play Supported platforms Flutter Android Flutter iOS Flut

Bart T 1 Nov 25, 2021
A Flutter Widget to make interactive timeline widget.

Bubble Timeline Package A Flutter Widget to make interactive timeline widget. This widget can be used to make Event Timelines, or Timelines for certai

Vansh Goel 12 Sep 22, 2022
Widget, that can make any static located widget hidable

Installing See the official installing guidline from hidable/install Usage & Overview To start using Hidable widget, we have to create a ScrollControl

Anon 18 Dec 16, 2022
📸 Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget.

?? Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interacive images and other stuff such as SVG.

Blue Fire 1.7k Jan 7, 2023
A widget that allow user resize the widget with drag

Flutter-Resizable-Widget A widget that allow user resize the widget with drag Note: this widget uses Getx Example bandicam.2021-11-11.12-34-41-056.mp4

MohammadAminZamani.afshar 22 Dec 13, 2022
A widget lib that the widget in this lib can react to flutter ScrollController's offset

Language: English | 中文简体 linked_scroll_widgets A lib full of widgets that can react to the scrollController's offset change,to custom your UI effect.

WenJingRui 8 Oct 16, 2022
Progress Dialog widget for flutter projects with ability to customize loading widget, background color and background blur.

DISCONTINUED Checkout ArsDialog ars_progress_dialog Customizable progress dialog for Flutter applications with smooth animation for background dim col

Arsam 8 Apr 15, 2022