Skip to content

Commit 2de929d

Browse files
committed
fixed readme
1 parent 915fe49 commit 2de929d

3 files changed

Lines changed: 225 additions & 5 deletions

File tree

README.md

Lines changed: 221 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,226 @@
11
# flutter_switch
22

3-
A new Flutter package project.
3+
A Custom Switch package created for Flutter.
4+
5+
## Give the repo some :heart: and :star: to support the project
6+
7+
[![GitHub followers](https://img.shields.io/github/followers/boringdeveloper.svg?style=social&label=Follow)](https://github.com/boringdeveloper)
8+
9+
## Installation
10+
11+
In the `dependencies:` section of your `pubspec.yaml`, add the following line:
12+
13+
```yaml
14+
flutter_switch: <latest_version>
15+
```
16+
17+
Import in your project:
18+
```dart
19+
import 'package:flutter_switch/flutter_switch.dart';
20+
```
21+
22+
## Sample Usage
23+
```dart
24+
class MyHomePage extends StatefulWidget {
25+
@override
26+
_MyHomePageState createState() => _MyHomePageState();
27+
}
28+
29+
class _MyHomePageState extends State<MyHomePage> {
30+
bool status = false;
31+
bool status2 = false;
32+
bool status3 = false;
33+
bool status4 = false;
34+
bool status5 = false;
35+
36+
@override
37+
Widget build(BuildContext context) {
38+
return Scaffold(
39+
appBar: AppBar(
40+
title: Text("FlutterSwitch Demo"),
41+
),
42+
body: Container(
43+
padding: EdgeInsets.all(10.0),
44+
child: Column(
45+
crossAxisAlignment: CrossAxisAlignment.start,
46+
children: <Widget>[
47+
Text("Default"),
48+
SizedBox(height: 10.0),
49+
Row(
50+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
51+
children: <Widget>[
52+
FlutterSwitch(
53+
value: status1,
54+
onToggle: (val) {
55+
setState(() {
56+
status1 = val;
57+
});
58+
},
59+
),
60+
Container(
61+
alignment: Alignment.centerRight,
62+
child: Text(
63+
"Value: $status1",
64+
),
65+
),
66+
],
67+
),
68+
SizedBox(height: 20.0),
69+
Text("Custom Colors"),
70+
SizedBox(height: 10.0),
71+
Row(
72+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
73+
children: <Widget>[
74+
FlutterSwitch(
75+
activeColor: Colors.red,
76+
inactiveColor: Colors.red[200],
77+
value: status2,
78+
onToggle: (val) {
79+
setState(() {
80+
status2 = val;
81+
});
82+
},
83+
),
84+
Container(
85+
alignment: Alignment.centerRight,
86+
child: Text(
87+
"Value: $status2",
88+
),
89+
),
90+
],
91+
),
92+
SizedBox(height: 20.0),
93+
Text("With 'On' and 'Off' text and custom text colors"),
94+
SizedBox(height: 10.0),
95+
Row(
96+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
97+
children: <Widget>[
98+
FlutterSwitch(
99+
showOnOff: true,
100+
activeTextColor: Colors.black,
101+
inactiveTextColor: Colors.blue[50],
102+
value: status3,
103+
onToggle: (val) {
104+
setState(() {
105+
status3 = val;
106+
});
107+
},
108+
),
109+
Container(
110+
alignment: Alignment.centerRight,
111+
child: Text(
112+
"Value: $status3",
113+
),
114+
),
115+
],
116+
),
117+
SizedBox(height: 20.0),
118+
Text("Custom size"),
119+
SizedBox(height: 10.0),
120+
Row(
121+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
122+
children: <Widget>[
123+
FlutterSwitch(
124+
width: 55.0,
125+
height: 25.0,
126+
valueFontSize: 12.0,
127+
toggleSize: 18.0,
128+
value: status4,
129+
onToggle: (val) {
130+
setState(() {
131+
status4 = val;
132+
});
133+
},
134+
),
135+
Container(
136+
alignment: Alignment.centerRight,
137+
child: Text(
138+
"Value: $status4",
139+
),
140+
),
141+
],
142+
),
143+
SizedBox(height: 20.0),
144+
Text("Custom border radius and padding"),
145+
SizedBox(height: 10.0),
146+
Row(
147+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
148+
children: <Widget>[
149+
FlutterSwitch(
150+
width: 125.0,
151+
height: 55.0,
152+
valueFontSize: 25.0,
153+
toggleSize: 45.0,
154+
value: status5,
155+
borderRadius: 30.0,
156+
padding: 8.0,
157+
showOnOff: true,
158+
onToggle: (val) {
159+
setState(() {
160+
status5 = val;
161+
});
162+
},
163+
),
164+
Container(
165+
alignment: Alignment.centerRight,
166+
child: Text(
167+
"Value: $status5",
168+
),
169+
),
170+
],
171+
),
172+
],
173+
),
174+
),
175+
);
176+
}
177+
}
178+
```
179+
## Demo
180+
181+
![flutter_switch]()
182+
183+
184+
## Developed By
185+
186+
```
187+
Nichole John Romero
188+
```
189+
190+
<a href="https://www.linkedin.com/in/nichole-john-talban-romero/"><img src="https://image.flaticon.com/icons/svg/174/174848.svg" width="60"></a>
191+
<a href="https://www.facebook.com/nickrgamer04/"><img src="https://image.flaticon.com/icons/svg/174/174857.svg" width="60"></a>
192+
193+
# 📃 License
194+
195+
BSD 3-Clause License
196+
197+
Copyright (c) 2020, Nichole John Romero
198+
All rights reserved.
199+
200+
Redistribution and use in source and binary forms, with or without
201+
modification, are permitted provided that the following conditions are met:
202+
203+
1. Redistributions of source code must retain the above copyright notice, this
204+
list of conditions and the following disclaimer.
205+
206+
2. Redistributions in binary form must reproduce the above copyright notice,
207+
this list of conditions and the following disclaimer in the documentation
208+
and/or other materials provided with the distribution.
209+
210+
3. Neither the name of the copyright holder nor the names of its
211+
contributors may be used to endorse or promote products derived from
212+
this software without specific prior written permission.
213+
214+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
215+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
216+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
217+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
218+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
219+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
220+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
221+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
222+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
223+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4224

5225
## Getting Started
6226

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: example
2-
description: A new Flutter project.
2+
description: FlutterSwitch Demo App
33

44
# The following defines the version and build number for your application.
55
# A version number is three numbers separated by dots, like 1.2.43

pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: flutter_switch
2-
description: A new Flutter package project.
2+
description: A Custom Switch package created for Flutter.
33
version: 0.0.1
4-
author:
5-
homepage:
4+
author: Nichole John Romero <romero.nicholejohn@gmail.com>
5+
homepage: https://github.com/boringdeveloper/CustomSwitch
66

77
environment:
88
sdk: ">=2.1.0 <3.0.0"

0 commit comments

Comments
 (0)