You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Persistent CupertinoListTile leading and trailing (flutter#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](flutter#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>
0 commit comments