Created
July 12, 2019 13:31
-
-
Save flutter-devs/d90d25721a9e8e53d65d5f69ddd58b2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:custom_switch/custom_switch.dart'; | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.deepOrange | |
), | |
home: HomeScreen(), | |
); | |
} | |
} | |
class HomeScreen extends StatefulWidget { | |
@override | |
_HomeScreenState createState() => _HomeScreenState(); | |
} | |
class _HomeScreenState extends State<HomeScreen> { | |
bool status = false; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Custom Switch Example'), | |
), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
CustomSwitch( | |
activeColor: Colors.pinkAccent, | |
value: status, | |
onChanged: (value) { | |
print("VALUE : $value"); | |
setState(() { | |
status = value; | |
}); | |
}, | |
), | |
SizedBox(height: 12.0,), | |
Text('Value : $status', style: TextStyle( | |
color: Colors.black, | |
fontSize: 20.0 | |
),) | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment