diff --git a/README.md b/README.md
index f91b50f..80bde75 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
[](https://pub.dev/packages/flutter_switch) [](https://pub.dev/packages/flutter_switch/score) [](https://pub.dev/packages/flutter_switch/score) [](https://pub.dev/packages/flutter_switch/score)
-An easy to implement custom switch created for Flutter. Give it a custom height and width, border for the switch and toggle, border radius, colors, toggle size, a choice to display an 'On' and 'Off' text and able to add an icon inside the toggle.
+An easy to implement custom switch created for Flutter. Give it a custom height and width, border for the switch and toggle, border radius, colors, toggle size, a choice to display an 'On' and 'Off' text and able to add an icon inside the toggle. You can also use your own custom widget to display instead of displaying an 'On' and 'Off' text.
[](https://github.com/boringdeveloper)
@@ -22,7 +22,7 @@ Add this to your package's `pubspec.yaml` file:
```yaml
dependencies:
- flutter_switch: ^0.3.1
+ flutter_switch: ^0.3.3
```
You can install packages from the command line with Flutter:
@@ -77,10 +77,10 @@ class _MyHomePageState extends State {
## Want to Contribute?
-Contributions to this project is very much welcome. Let's work together to maintain and improve the project
+Contributions to this project is very much welcome. Let's work together to maintain and improve this project.
Simply Fork the repository, Commit and Push your changes and create a new Pull Request.
-Don't forget to try out the example project under the ./example folder.
+Don't forget to try out the example project under the [./example](https://github.com/boringdeveloper/FlutterSwitch/tree/master/example) folder.
Also test your changes by running this command.
```bash
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index 0f6a5e5..3f46a61 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
- compileSdkVersion 28
+ compileSdkVersion 31
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
@@ -40,7 +40,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 16
- targetSdkVersion 28
+ targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 8bc6007..1751bb6 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -6,7 +6,7 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
diff --git a/example/android/build.gradle b/example/android/build.gradle
index 3100ad2..604cfa3 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -1,12 +1,12 @@
buildscript {
- ext.kotlin_version = '1.3.50'
+ ext.kotlin_version = '1.6.21'
repositories {
google()
- jcenter()
+ mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.5.0'
+ classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@@ -14,18 +14,17 @@ buildscript {
allprojects {
repositories {
google()
- jcenter()
+ mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
-}
-subprojects {
project.evaluationDependsOn(':app')
}
+
task clean(type: Delete) {
delete rootProject.buildDir
}
diff --git a/example/android/gradle.properties b/example/android/gradle.properties
index 38c8d45..94adc3a 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -1,4 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
-android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index 296b146..b776d4b 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 61cb3d7..69b821e 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -29,6 +29,7 @@ class _MyHomePageState extends State {
bool status6 = false;
bool status7 = false;
bool status8 = false;
+ bool status9 = false;
bool isSwitchOn = false;
Color _textColor = Colors.black;
@@ -129,16 +130,40 @@ class _MyHomePageState extends State {
],
),
SizedBox(height: 20.0),
- Text("With 'On' and 'Off' text and custom text colors"),
+ Text("Custom Decoration"),
SizedBox(height: 10.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
FlutterSwitch(
- showOnOff: true,
- activeTextColor: Colors.black,
- inactiveTextColor: Colors.blue[50],
+ width: 100.0,
+ height: 55.0,
+ toggleSize: 45.0,
value: status3,
+ padding: 2.0,
+ toggleColor: Color.fromRGBO(225, 225, 225, 1),
+ toggleBorder: Border.all(
+ color: Color.fromRGBO(2, 107, 206, 1),
+ width: 5.0,
+ ),
+ activeDecoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(30),
+ gradient: LinearGradient(
+ colors: [
+ Colors.red,
+ Colors.orange,
+ ],
+ ),
+ ),
+ inactiveDecoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(30),
+ gradient: LinearGradient(
+ colors: [
+ Colors.blue,
+ Colors.orange,
+ ],
+ ),
+ ),
onToggle: (val) {
setState(() {
status3 = val;
@@ -154,6 +179,31 @@ class _MyHomePageState extends State {
],
),
SizedBox(height: 20.0),
+ Text("With 'On' and 'Off' text and custom text colors"),
+ SizedBox(height: 10.0),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ FlutterSwitch(
+ showOnOff: true,
+ activeTextColor: Colors.black,
+ inactiveTextColor: Colors.blue.shade50,
+ value: status4,
+ onToggle: (val) {
+ setState(() {
+ status4 = val;
+ });
+ },
+ ),
+ Container(
+ alignment: Alignment.centerRight,
+ child: Text(
+ "Value: $status4",
+ ),
+ ),
+ ],
+ ),
+ SizedBox(height: 20.0),
Text("Custom size"),
SizedBox(height: 10.0),
Row(
@@ -164,17 +214,17 @@ class _MyHomePageState extends State {
height: 25.0,
valueFontSize: 12.0,
toggleSize: 18.0,
- value: status4,
+ value: status5,
onToggle: (val) {
setState(() {
- status4 = val;
+ status5 = val;
});
},
),
Container(
alignment: Alignment.centerRight,
child: Text(
- "Value: $status4",
+ "Value: $status5",
),
),
],
@@ -190,20 +240,20 @@ class _MyHomePageState extends State {
height: 55.0,
valueFontSize: 25.0,
toggleSize: 45.0,
- value: status5,
+ value: status6,
borderRadius: 30.0,
padding: 8.0,
showOnOff: true,
onToggle: (val) {
setState(() {
- status5 = val;
+ status6 = val;
});
},
),
Container(
alignment: Alignment.centerRight,
child: Text(
- "Value: $status5",
+ "Value: $status6",
),
),
],
@@ -217,21 +267,21 @@ class _MyHomePageState extends State {
FlutterSwitch(
activeText: "All Good. Negative.",
inactiveText: "Under Quarantine.",
- value: status6,
+ value: status7,
valueFontSize: 10.0,
width: 110,
borderRadius: 30.0,
showOnOff: true,
onToggle: (val) {
setState(() {
- status6 = val;
+ status7 = val;
});
},
),
Container(
alignment: Alignment.centerRight,
child: Text(
- "Value: $status6",
+ "Value: $status7",
),
),
],
@@ -253,7 +303,7 @@ class _MyHomePageState extends State {
width: 100.0,
height: 55.0,
toggleSize: 45.0,
- value: status7,
+ value: status8,
borderRadius: 30.0,
padding: 2.0,
activeToggleColor: Color(0xFF6E40C9),
@@ -278,8 +328,7 @@ class _MyHomePageState extends State {
),
onToggle: (val) {
setState(() {
- status7 = val;
-
+ status8 = val;
if (val) {
_textColor = Colors.white;
_appBarColor = Color.fromRGBO(22, 27, 34, 1);
@@ -294,7 +343,7 @@ class _MyHomePageState extends State {
),
Container(
alignment: Alignment.centerRight,
- child: Text("Value: $status7"),
+ child: Text("Value: $status8"),
),
],
),
@@ -308,7 +357,7 @@ class _MyHomePageState extends State {
width: 100.0,
height: 55.0,
toggleSize: 45.0,
- value: status8,
+ value: status9,
borderRadius: 30.0,
padding: 2.0,
activeToggleColor: Color(0xFF0082C8),
@@ -331,13 +380,13 @@ class _MyHomePageState extends State {
),
onToggle: (val) {
setState(() {
- status8 = val;
+ status9 = val;
});
},
),
Container(
alignment: Alignment.centerRight,
- child: Text("Value: $status8"),
+ child: Text("Value: $status9"),
),
],
),
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 30eb4a3..f8a8bc4 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.5.0"
+ version: "2.8.2"
boolean_selector:
dependency: transitive
description:
@@ -21,14 +21,14 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0"
+ version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
- version: "1.2.0"
+ version: "1.3.1"
clock:
dependency: transitive
description:
@@ -42,21 +42,21 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
- version: "1.15.0"
+ version: "1.16.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
- version: "0.1.3"
+ version: "1.0.4"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
- version: "1.2.0"
+ version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
@@ -68,7 +68,7 @@ packages:
path: ".."
relative: true
source: path
- version: "0.3.1"
+ version: "0.3.3"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -80,21 +80,28 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.10"
+ version: "0.12.11"
+ material_color_utilities:
+ dependency: transitive
+ description:
+ name: material_color_utilities
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.4"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
- version: "1.3.0"
+ version: "1.7.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.0"
+ version: "1.8.1"
sky_engine:
dependency: transitive
description: flutter
@@ -106,7 +113,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.0"
+ version: "1.8.2"
stack_trace:
dependency: transitive
description:
@@ -141,20 +148,13 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.19"
- typed_data:
- dependency: transitive
- description:
- name: typed_data
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.3.0"
+ version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.0"
+ version: "2.1.2"
sdks:
- dart: ">=2.12.0 <3.0.0"
+ dart: ">=2.17.1 <3.0.0"
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index 98fde15..199c78a 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -1,6 +1,6 @@
name: example
description: FlutterSwitch Demo App
-
+publish_to: none
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
@@ -14,7 +14,7 @@ description: FlutterSwitch Demo App
version: 1.0.0+1
environment:
- sdk: ">=2.1.0 <3.0.0"
+ sdk: ">=2.17.0 <3.0.0"
dependencies:
flutter:
@@ -22,7 +22,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
- cupertino_icons: ^0.1.2
+ cupertino_icons: ^1.0.4
flutter_switch:
path: ../
diff --git a/lib/flutter_switch.dart b/lib/flutter_switch.dart
index e30ca12..97cdc2a 100644
--- a/lib/flutter_switch.dart
+++ b/lib/flutter_switch.dart
@@ -10,11 +10,12 @@ class FlutterSwitch extends StatefulWidget {
/// * [value] determines whether this switch is on or off.
/// * [onToggle] is called when the user toggles the switch on or off.
///
-
const FlutterSwitch({
Key? key,
required this.value,
required this.onToggle,
+ this.activeDecoration,
+ this.inactiveDecoration,
this.activeColor = Colors.blue,
this.inactiveColor = Colors.grey,
this.activeTextColor = Colors.white70,
@@ -29,6 +30,8 @@ class FlutterSwitch extends StatefulWidget {
this.borderRadius = 20.0,
this.padding = 4.0,
this.showOnOff = false,
+ this.activeTrackWidget,
+ this.inactiveTrackWidget,
this.activeText,
this.inactiveText,
this.activeTextFontWeight,
@@ -41,8 +44,12 @@ class FlutterSwitch extends StatefulWidget {
this.inactiveToggleBorder,
this.activeIcon,
this.inactiveIcon,
+ this.activeTextAlignment = Alignment.centerLeft,
+ this.inactiveTextAlignment = Alignment.centerRight,
this.duration = const Duration(milliseconds: 200),
this.disabled = false,
+ this.togglePadding = const EdgeInsets.all(4),
+ this.toggleRatio = 1,
}) : assert(
(switchBorder == null || activeSwitchBorder == null) &&
(switchBorder == null || inactiveSwitchBorder == null),
@@ -94,6 +101,21 @@ class FlutterSwitch extends StatefulWidget {
///
/// Defaults to 'On' if no value was given.
///
+ /// The custom widget to display on a tack when it is active.
+ /// This parameter is only necessary when [showOnOff] property is true.
+ ///
+ /// This property overrides the [activeText] property, so when this property
+ /// is used, the properties related to [activeText] are not usable
+ final Widget? activeTrackWidget;
+
+ /// The custom widget to display on a tack when it is inactive.
+ /// This parameter is only necessary when [showOnOff] property is true.
+ ///
+ /// This property overrides the [inactiveText] property, so when this property
+ /// is used, the properties related to [inactiveText] are not usable
+ final Widget? inactiveTrackWidget;
+
+ /// This parameter is not necessary when [activeTrackWidget] property is used.
/// To change value style, the following properties are available
///
/// [activeTextColor] - The color to use on the text value when the switch is on.
@@ -111,7 +133,17 @@ class FlutterSwitch extends StatefulWidget {
/// [inactiveTextFontWeight] - The font weight to use on the text value when the switch is off.
final String? inactiveText;
- /// The color to use on the switch when the switch is on.
+ /// The decoration to use on the switch when the switch is on.
+ /// If null the other values like [activeColor], [borderRadius]
+ /// and [activeSwitchBorder] will be used.
+ final Decoration? activeDecoration;
+
+ /// The decoration to use on the switch when the switch is off.
+ /// If null the other values like [inactiveColor], [borderRadius]
+ /// and [inactiveSwitchBorder] will be used.
+ final Decoration? inactiveDecoration;
+
+ /// The color to use on the switch when the switch is off.
///
/// Defaults to [Colors.blue].
final Color activeColor;
@@ -141,6 +173,7 @@ class FlutterSwitch extends StatefulWidget {
/// The font weight to use on the text value when the switch is off.
/// This parameter is only necessary when [showOnOff] property is true.
+
///
/// Defaults to [FontWeight.w900].
final FontWeight? inactiveTextFontWeight;
@@ -241,6 +274,16 @@ class FlutterSwitch extends StatefulWidget {
/// This property is optional.
final Widget? inactiveIcon;
+ /// The alignment of the text when the given value is true.
+ ///
+ /// Defaults to [Alignment.centerLeft].
+ final Alignment activeTextAlignment;
+
+ /// The alignment of the text when the given value is false.
+ ///
+ /// Defaults to [Alignment.centerRight].
+ final Alignment inactiveTextAlignment;
+
/// The duration in milliseconds to change the state of the switch
///
/// Defaults to the value of 200 milliseconds.
@@ -251,6 +294,18 @@ class FlutterSwitch extends StatefulWidget {
/// Defaults to the value of false.
final bool disabled;
+ /// The padding of the toggle.
+ ///
+ /// Defaults to `EdgeInsets.all(4)`
+ final EdgeInsets togglePadding;
+
+ /// The toggle will be a rounded rectangle when the value is not 1.
+ ///
+ /// Width = Size * toggleRatio, Height = Size.
+ ///
+ /// Defaults to the value of 1.
+ final double toggleRatio;
+
@override
_FlutterSwitchState createState() => _FlutterSwitchState();
}
@@ -303,7 +358,8 @@ class _FlutterSwitchState extends State
Color _switchColor = Colors.white;
Border? _switchBorder;
Border? _toggleBorder;
-
+ Decoration? decoration =
+ widget.value ? widget.activeDecoration : widget.inactiveDecoration;
if (widget.value) {
_toggleColor = widget.activeToggleColor ?? widget.toggleColor;
_switchColor = widget.activeColor;
@@ -325,96 +381,96 @@ class _FlutterSwitchState extends State
return AnimatedBuilder(
animation: _animationController,
builder: (context, child) {
- return Container(
- width: widget.width,
- child: Align(
- child: GestureDetector(
- onTap: () {
- if (!widget.disabled) {
- if (widget.value)
- _animationController.forward();
- else
- _animationController.reverse();
-
- widget.onToggle(!widget.value);
- }
- },
- child: Opacity(
- opacity: widget.disabled ? 0.6 : 1,
- child: Container(
- width: widget.width,
- height: widget.height,
- padding: EdgeInsets.all(widget.padding),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(widget.borderRadius),
- color: _switchColor,
- border: _switchBorder,
- ),
- child: Stack(
- children: [
- AnimatedOpacity(
- opacity: widget.value ? 1.0 : 0.0,
+ return Align(
+ child: GestureDetector(
+ onTap: () {
+ if (!widget.disabled) {
+ if (widget.value)
+ _animationController.forward();
+ else
+ _animationController.reverse();
+
+ widget.onToggle(!widget.value);
+ }
+ },
+ child: Opacity(
+ opacity: widget.disabled ? 0.6 : 1,
+ child: Container(
+ width: widget.width,
+ height: widget.height,
+ padding: EdgeInsets.all(widget.padding),
+ decoration: decoration ??
+ BoxDecoration(
+ borderRadius: BorderRadius.circular(widget.borderRadius),
+ color: _switchColor,
+ border: _switchBorder,
+ ),
+ child: Stack(
+ children: [
+ AnimatedOpacity(
+ opacity: widget.value ? 1.0 : 0.0,
+ duration: widget.duration,
+ child: Container(
+ width: _textSpace,
+ padding: EdgeInsets.symmetric(horizontal: 4.0),
+ alignment: widget.activeTextAlignment,
+ child: _activeTrackItem,
+ ),
+ ),
+ Align(
+ alignment: Alignment.centerRight,
+ child: AnimatedOpacity(
+ opacity: !widget.value ? 1.0 : 0.0,
duration: widget.duration,
child: Container(
width: _textSpace,
padding: EdgeInsets.symmetric(horizontal: 4.0),
- alignment: Alignment.centerLeft,
- child: _activeText,
+ alignment: widget.inactiveTextAlignment,
+ child: _inactiveTrackItem,
),
),
- Align(
- alignment: Alignment.centerRight,
- child: AnimatedOpacity(
- opacity: !widget.value ? 1.0 : 0.0,
- duration: widget.duration,
- child: Container(
- width: _textSpace,
- padding: EdgeInsets.symmetric(horizontal: 4.0),
- alignment: Alignment.centerRight,
- child: _inactiveText,
+ ),
+ Container(
+ child: Align(
+ alignment: _toggleAnimation.value,
+ child: Container(
+ width: widget.toggleSize * widget.toggleRatio,
+ height: widget.toggleSize,
+ padding: widget.togglePadding,
+ decoration: BoxDecoration(
+ shape: widget.toggleRatio == 1
+ ? BoxShape.circle
+ : BoxShape.rectangle,
+ color: _toggleColor,
+ borderRadius: widget.toggleRatio == 1
+ ? null
+ : BorderRadius.circular(widget.borderRadius),
+ border: _toggleBorder,
),
- ),
- ),
- Container(
- child: Align(
- alignment: _toggleAnimation.value,
- child: Container(
- width: widget.toggleSize,
- height: widget.toggleSize,
- padding: EdgeInsets.all(4.0),
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: _toggleColor,
- border: _toggleBorder,
- ),
- child: FittedBox(
- fit: BoxFit.contain,
- child: Container(
- child: Stack(
- children: [
- Center(
- child: AnimatedOpacity(
- opacity: widget.value ? 1.0 : 0.0,
- duration: widget.duration,
- child: widget.activeIcon,
- ),
- ),
- Center(
- child: AnimatedOpacity(
- opacity: !widget.value ? 1.0 : 0.0,
- duration: widget.duration,
- child: widget.inactiveIcon,
- ),
- ),
- ],
- ),
+ child: FittedBox(
+ fit: BoxFit.contain,
+ child: Container(
+ child: Stack(
+ alignment: Alignment.center,
+ children: [
+ AnimatedOpacity(
+ opacity: widget.value ? 1.0 : 0.0,
+ duration: widget.duration,
+ child: widget.activeIcon,
+ ),
+ AnimatedOpacity(
+ opacity: !widget.value ? 1.0 : 0.0,
+ duration: widget.duration,
+ child: widget.inactiveIcon,
+ ),
+ ],
),
),
),
),
),
- ],
- ),
+ ),
+ ],
),
),
),
@@ -426,35 +482,38 @@ class _FlutterSwitchState extends State
FontWeight get _activeTextFontWeight =>
widget.activeTextFontWeight ?? FontWeight.w900;
+
FontWeight get _inactiveTextFontWeight =>
widget.inactiveTextFontWeight ?? FontWeight.w900;
- Widget get _activeText {
+ Widget get _activeTrackItem {
if (widget.showOnOff) {
- return Text(
- widget.activeText ?? "On",
- style: TextStyle(
- color: widget.activeTextColor,
- fontWeight: _activeTextFontWeight,
- fontSize: widget.valueFontSize,
- ),
- );
+ return widget.activeTrackWidget ??
+ Text(
+ widget.activeText ?? "On",
+ style: TextStyle(
+ color: widget.activeTextColor,
+ fontWeight: _activeTextFontWeight,
+ fontSize: widget.valueFontSize,
+ ),
+ );
}
return Text("");
}
- Widget get _inactiveText {
+ Widget get _inactiveTrackItem {
if (widget.showOnOff) {
- return Text(
- widget.inactiveText ?? "Off",
- style: TextStyle(
- color: widget.inactiveTextColor,
- fontWeight: _inactiveTextFontWeight,
- fontSize: widget.valueFontSize,
- ),
- textAlign: TextAlign.right,
- );
+ return widget.inactiveTrackWidget ??
+ Text(
+ widget.inactiveText ?? "Off",
+ style: TextStyle(
+ color: widget.inactiveTextColor,
+ fontWeight: _inactiveTextFontWeight,
+ fontSize: widget.valueFontSize,
+ ),
+ textAlign: TextAlign.right,
+ );
}
return Text("");
diff --git a/pubspec.lock b/pubspec.lock
index 49a0ce6..4eb53b0 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "2.5.0"
+ version: "2.8.2"
boolean_selector:
dependency: transitive
description:
@@ -21,14 +21,14 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
- version: "1.1.0"
+ version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
- version: "1.2.0"
+ version: "1.3.1"
clock:
dependency: transitive
description:
@@ -42,14 +42,14 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
- version: "1.15.0"
+ version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
- version: "1.2.0"
+ version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
@@ -66,21 +66,28 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.10"
+ version: "0.12.11"
+ material_color_utilities:
+ dependency: transitive
+ description:
+ name: material_color_utilities
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.1.4"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
- version: "1.3.0"
+ version: "1.7.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.0"
+ version: "1.8.1"
sky_engine:
dependency: transitive
description: flutter
@@ -92,7 +99,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
- version: "1.8.0"
+ version: "1.8.2"
stack_trace:
dependency: transitive
description:
@@ -127,20 +134,13 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
- version: "0.2.19"
- typed_data:
- dependency: transitive
- description:
- name: typed_data
- url: "https://pub.dartlang.org"
- source: hosted
- version: "1.3.0"
+ version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
- version: "2.1.0"
+ version: "2.1.2"
sdks:
- dart: ">=2.12.0 <3.0.0"
+ dart: ">=2.17.1 <3.0.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index 5080e03..a89ca23 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,10 +1,10 @@
name: flutter_switch
description: A custom switch widget that can have a custom height and width, borders, border radius, colors, toggle size, custom text and icons inside the toggle.
-version: 0.3.1
+version: 0.3.3
homepage: https://github.com/boringdeveloper/FlutterSwitch
environment:
- sdk: '>=2.12.0 <3.0.0'
+ sdk: '>=2.17.1 <3.0.0'
dependencies:
flutter: