'Flutter increase height and width of Switch?
I creating game with single and two players. for selection i want slide look so i have tried with switch method but its look very small. how to increase height and width of switch? is there any way creating look like this is welcome?
new Center(
child:
new Padding(padding:EdgeInsets.all(50.00),
child:
new Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Switch(value: _value, onChanged: (bool value1)
{
_value=value1;
},
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
activeThumbImage: new AssetImage("assets/Images/1.png"),
inactiveThumbImage: new AssetImage("assets/Images/1.png"),
)
],
) ,
),
)
Solution 1:[1]
You could wrap your Switch inside a Transform widget and change the scale.
Transform.scale(scale: 2.0,
child: Switch(
value: true,
onChanged: (bool value1){},
),
)
Scale = 1 is the default size , 0.5 half size , 2.0 double size, you can play with the values :)
UPDATE
Now you can also do it using SizedBox + FittedBox
SizedBox(
width: 150,
height: 40,
child: FittedBox(
fit: BoxFit.fill,
child: Switch(
value: true,
onChanged: (bool value1) {},
),
),
),
Don't forget the BoxFit.fill value :)
Solution 2:[2]
You can wrapper your Switch widget inside a SizedBox and set width and height to it.
SizedBox(
width: 80,
height: 40,
child: Switch(
value: isChecked,
onChanged: (value) {
//Do you things
}
)
)
Solution 3:[3]
The accepted answer using a scale will increase both height and width, if you want to control both height and width
Use it like this
SizedBox(
width: 50,
height: 30,
child: FittedBox(
fit: BoxFit.fill,
child: Switch(
onChanged: (bool value) {
},
),
),
)
Solution 4:[4]
You should put your switch inside a container and give it both a height and a width as per your requirement.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Dongsheng Sun Noah |
| Solution 3 | ajay prabhakar |
| Solution 4 | Stphane |

