-
Taha Tesser authored
fixes [AnimatedList does not take SafeArea into account when building the list ](https://github.com/flutter/flutter/issues/129539) ### Description This PR fixes an issue for `AnimatedList` & `AnimatedGrid` where `MediaQuery` padding isn't applied. See the [source](https://github.com/flutter/flutter/blob/a20db068dd9f72e2e4a35a3ce64f22d47b3d20f7/packages/flutter/lib/src/widgets/scroll_view.dart#L803-L833). While the `ListView` or `GridView` applies `MediaQuery` padding to its inner `SliverPadding`. This is missing from `AnimatedList` & `AnimatedGrid`.  The fix applies `MediaQuery` padding to the inner `SliverPadding` in `AnimatedList` & `AnimatedGrid`.  ### Code sample <details> <summary>expand to view the code sample</summary> ```dart import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData(useMaterial3: true), home: const Example(), ); } } class Example extends StatelessWidget { const Example({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Sample'), ), body: Row( children: <Widget>[ Expanded( child: Column( children: <Widget>[ const Text('ListView'), Expanded( child: ListView.builder( itemCount: 50, itemBuilder: (_, int index) { return ColoredBox( color: Theme.of(context).colorScheme.primaryContainer, child: Center( child: Text('$index', textAlign: TextAlign.center), ), ); }, ), ), ], ), ), const VerticalDivider(width: 4), Expanded( child: Column( children: <Widget>[ const Text('AnimatedList'), Expanded( child: AnimatedList( initialItemCount: 50, itemBuilder: (_, int index, __) { return ColoredBox( color: Theme.of(context).colorScheme.primaryContainer, child: Center( child: Text('$index', textAlign: TextAlign.center), ), ); }, ), ), ], ), ), const VerticalDivider(width: 4), Expanded( child: Column( children: <Widget>[ const Text('AnimatedGrid'), Expanded( child: AnimatedGrid( initialItemCount: 50, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, ), itemBuilder: (_, int index, __) { return ColoredBox( color: Theme.of(context).colorScheme.primaryContainer, child: Center( child: Text('$index', textAlign: TextAlign.center), ), ); }, ), ), ], )) ], ), ); } } ``` </details> ### Before  ### After 