mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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>
Flutter
Flutter is a new way to build high-performance, cross-platform mobile, web, and desktop apps. Flutter is optimized for today's — and tomorrow's — mobile and desktop devices. We are focused on low-latency input and high frame rates on all platforms.
See the getting started guide for information about using Flutter.