Victor Sanni 77c42fbd22
Persistent CupertinoListTile leading and trailing (#166799)
The bug occurs because the background color passed into the underlying
`Container` changes from null to `backgroundColorActivated`. Under the
hood, the `Container` wraps its child in a `ColoredBox` only if the
color is non-null. So the extra wrapping with a `ColoredBox` happening
mid-animation breaks reparenting, causing the widgets to be
replaced/inflated instead of updated.

### Before



https://github.com/user-attachments/assets/ca0b657a-1340-405f-8c1d-34b34366b994



### After



https://github.com/user-attachments/assets/8445c55c-0d5d-4b5f-96d2-4f12d908bdec





Fixes [CupertinoListTile animations are not running when pressing
longer](https://github.com/flutter/flutter/issues/153225)

<details>
<summary>Sample code</summary>

```dart

import 'package:flutter/cupertino.dart';

void main() => runApp(const ListTileApp());

class ListTileApp extends StatelessWidget {
  const ListTileApp({super.key});

  @override
  Widget build(BuildContext context) {
    return CupertinoApp(home: const ListTileExample());
  }
}

class ListTileExample extends StatefulWidget {
  const ListTileExample({super.key});

  @override
  State<ListTileExample> createState() => _ListTileExampleState();
}

class _ListTileExampleState extends State<ListTileExample> {
  bool _pushedToggle = false;

  void _toggle() {
    setState(() {
      _pushedToggle = !_pushedToggle;
    });
  }

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      child: Center(
        child: SizedBox(
          height: 40,
          child: CupertinoListTile(
              onTap: _toggle,
              title: Center(
                child: Text(
                  'Toggle',
                ),
              ),
              leading: CupertinoSwitch(
                value: _pushedToggle,
                onChanged: (_) {},
              ),
              trailing: CupertinoSwitch(
                value: _pushedToggle,
                onChanged: (_) {},
              )),
        ),
      ),
    );
  }
}


```

</details>
2025-04-15 01:04:00 +00:00
..