Flutter series overall directory
Switch control a switch.
Attributes | Explanation |
---|---|
value | true: open false: Off |
onChanged | Callback change |
activeColor | Open state color |
activeTrackColor | Color open state track |
inactiveThumbColor | Off thumb colors |
inactiveTrackColor | Off track color |
activeThumbImage | Open state thumb picture |
inactiveThumbImage | Off thumb picture |
materialTapTargetSize | Click area |
track and thumb position:
example:
import 'package:flutter/material.dart';
class SwitchDemo extends StatefulWidget {
@override
State<StatefulWidget> createState() => _SwitchDemo();
}
class _SwitchDemo extends State<SwitchDemo> {
bool _value = true;
@override
Widget build(BuildContext context) {
// TODO: implement build
return Column(
children: <Widget>[
Switch(
value: _value,
onChanged: (newValue) {
setState(() {
_value = newValue;
});
},
activeColor: Colors.red,
activeTrackColor:Colors.black,
inactiveThumbColor:Colors.green,
inactiveTrackColor: Colors.blue,
activeThumbImage: AssetImage(
'images/1.png',
),
),
],
);
}
}