Flutter SwitchListTile


简介

Switch 的一个衍生组件

基本用法与Switch相同.具体参考Switch, 支持各种自定义样式.

实例演示

import 'package:flutter/material.dart';

class SwitchListTileDemo extends StatefulWidget {
  _Demo createState() => _Demo();
}

class _Demo extends State<SwitchListTileDemo> {
  bool _lights = false;
  Widget build(BuildContext context) {
    return  SwitchListTile(
      title: const Text('Lights'),
      value: _lights,
      onChanged: (bool value) { setState(() { _lights = value; }); },
      secondary: const Icon(Icons.lightbulb_outline),
    );
  }
}