Home > Blockchain >  How to create native Android switches on Flutter?
How to create native Android switches on Flutter?

Time:09-05

The default switch for stock Android looks as follows:

enter image description here

However, on some Android flavors such as MIUI, the switch looks like this in their native apps:

enter image description here

How can I achieve this native behavior for all Android flavors (Samsung, MIUI, Huawei, Sony, etc.) with Flutter?

CodePudding user response:

You can use the below snippet for Switch Button like Android:

Flexible(
        child: SwitchListTile(
                                title: const Text(
                                    '<Put Your Text>',
                                    style: TextStyle(
                                        fontSize: 12,
                                        fontWeight: FontWeight.bold)),
                                value: isSwitch,
                                onChanged: (value) {
                                  setState(() {
                                    isSwitch = value;
                                  });
                                },
                                activeColor: Colors.white,
                                activeTrackColor:
                                    CustomColors.switchActiveColor,
                                inactiveThumbColor:
                                    CustomColors.switchDisableCircleColor,
                                inactiveTrackColor:
                                    CustomColors.switchDisableColor,
                                contentPadding: const EdgeInsets.all(0),
                              ),
                              flex: 1)

isSwitch is bool flag to manage on/off

CodePudding user response:

Can you help me add payment to Huawei app

  • Related