@@ -1836,7 +1836,7 @@ void main() {
18361836 });
18371837
18381838 testWidgets ('ListTile horizontalTitleGap = 0.0' , (WidgetTester tester) async {
1839- Widget buildFrame (TextDirection textDirection) {
1839+ Widget buildFrame (TextDirection textDirection, { double ? themeHorizontalTitleGap, double ? widgetHorizontalTitleGap } ) {
18401840 return MediaQuery (
18411841 data: const MediaQueryData (
18421842 padding: EdgeInsets .zero,
@@ -1845,13 +1845,16 @@ void main() {
18451845 child: Directionality (
18461846 textDirection: textDirection,
18471847 child: Material (
1848- child: Container (
1849- alignment: Alignment .topLeft,
1850- child: const ListTile (
1851- horizontalTitleGap: 0.0 ,
1852- leading: Text ('L' ),
1853- title: Text ('title' ),
1854- trailing: Text ('T' ),
1848+ child: ListTileTheme (
1849+ horizontalTitleGap: themeHorizontalTitleGap,
1850+ child: Container (
1851+ alignment: Alignment .topLeft,
1852+ child: ListTile (
1853+ horizontalTitleGap: widgetHorizontalTitleGap,
1854+ leading: const Text ('L' ),
1855+ title: const Text ('title' ),
1856+ trailing: const Text ('T' ),
1857+ ),
18551858 ),
18561859 ),
18571860 ),
@@ -1862,15 +1865,29 @@ void main() {
18621865 double left (String text) => tester.getTopLeft (find.text (text)).dx;
18631866 double right (String text) => tester.getTopRight (find.text (text)).dx;
18641867
1865- await tester.pumpWidget (buildFrame (TextDirection .ltr));
1868+ await tester.pumpWidget (buildFrame (TextDirection .ltr, widgetHorizontalTitleGap: 0 ));
1869+ expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 56.0 ));
1870+ expect (left ('title' ), 56.0 );
18661871
1872+ await tester.pumpWidget (buildFrame (TextDirection .ltr, themeHorizontalTitleGap: 0 ));
18671873 expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 56.0 ));
1868- expect (left ('title' ), 56.0 ); // horizontalTitleGap: 0
1874+ expect (left ('title' ), 56.0 );
18691875
1870- await tester.pumpWidget (buildFrame (TextDirection .rtl));
1876+ await tester.pumpWidget (buildFrame (TextDirection .ltr, themeHorizontalTitleGap: 10 , widgetHorizontalTitleGap: 0 ));
1877+ expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 56.0 ));
1878+ expect (left ('title' ), 56.0 );
18711879
1880+ await tester.pumpWidget (buildFrame (TextDirection .rtl, widgetHorizontalTitleGap: 0 ));
18721881 expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 56.0 ));
1873- expect (right ('title' ), 744.0 ); // horizontalTitleGap: 0
1882+ expect (right ('title' ), 744.0 );
1883+
1884+ await tester.pumpWidget (buildFrame (TextDirection .rtl, themeHorizontalTitleGap: 0 ));
1885+ expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 56.0 ));
1886+ expect (right ('title' ), 744.0 );
1887+
1888+ await tester.pumpWidget (buildFrame (TextDirection .rtl, themeHorizontalTitleGap: 10 , widgetHorizontalTitleGap: 0 ));
1889+ expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 56.0 ));
1890+ expect (right ('title' ), 744.0 );
18741891 });
18751892
18761893 testWidgets ('ListTile horizontalTitleGap = (default) && ListTile minLeadingWidth = (default)' , (WidgetTester tester) async {
@@ -1913,7 +1930,7 @@ void main() {
19131930 });
19141931
19151932 testWidgets ('ListTile minVerticalPadding = 80.0' , (WidgetTester tester) async {
1916- Widget buildFrame (TextDirection textDirection) {
1933+ Widget buildFrame (TextDirection textDirection, { double ? themeMinVerticalPadding, double ? widgetMinVerticalPadding } ) {
19171934 return MediaQuery (
19181935 data: const MediaQueryData (
19191936 padding: EdgeInsets .zero,
@@ -1922,13 +1939,16 @@ void main() {
19221939 child: Directionality (
19231940 textDirection: textDirection,
19241941 child: Material (
1925- child: Container (
1926- alignment: Alignment .topLeft,
1927- child: const ListTile (
1928- minVerticalPadding: 80.0 ,
1929- leading: Text ('L' ),
1930- title: Text ('title' ),
1931- trailing: Text ('T' ),
1942+ child: ListTileTheme (
1943+ minVerticalPadding: themeMinVerticalPadding,
1944+ child: Container (
1945+ alignment: Alignment .topLeft,
1946+ child: ListTile (
1947+ minVerticalPadding: widgetMinVerticalPadding,
1948+ leading: const Text ('L' ),
1949+ title: const Text ('title' ),
1950+ trailing: const Text ('T' ),
1951+ ),
19321952 ),
19331953 ),
19341954 ),
@@ -1937,21 +1957,29 @@ void main() {
19371957 }
19381958
19391959
1940- await tester.pumpWidget (buildFrame (TextDirection .ltr));
1941-
1942- // minVerticalPadding: 80.0
1960+ await tester.pumpWidget (buildFrame (TextDirection .ltr, widgetMinVerticalPadding: 80 ));
19431961 // 80 + 80 + 16(Title) = 176
19441962 expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 176.0 ));
19451963
1946- await tester.pumpWidget (buildFrame (TextDirection .rtl));
1964+ await tester.pumpWidget (buildFrame (TextDirection .ltr, themeMinVerticalPadding: 80 ));
1965+ expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 176.0 ));
19471966
1948- // minVerticalPadding: 80.0
1967+ await tester.pumpWidget (buildFrame (TextDirection .ltr, themeMinVerticalPadding: 0 , widgetMinVerticalPadding: 80 ));
1968+ expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 176.0 ));
1969+
1970+ await tester.pumpWidget (buildFrame (TextDirection .rtl, widgetMinVerticalPadding: 80 ));
19491971 // 80 + 80 + 16(Title) = 176
19501972 expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 176.0 ));
1973+
1974+ await tester.pumpWidget (buildFrame (TextDirection .rtl, themeMinVerticalPadding: 80 ));
1975+ expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 176.0 ));
1976+
1977+ await tester.pumpWidget (buildFrame (TextDirection .rtl, themeMinVerticalPadding: 0 , widgetMinVerticalPadding: 80 ));
1978+ expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 176.0 ));
19511979 });
19521980
19531981 testWidgets ('ListTile minLeadingWidth = 60.0' , (WidgetTester tester) async {
1954- Widget buildFrame (TextDirection textDirection) {
1982+ Widget buildFrame (TextDirection textDirection, { double ? themeMinLeadingWidth, double ? widgetMinLeadingWidth } ) {
19551983 return MediaQuery (
19561984 data: const MediaQueryData (
19571985 padding: EdgeInsets .zero,
@@ -1960,13 +1988,16 @@ void main() {
19601988 child: Directionality (
19611989 textDirection: textDirection,
19621990 child: Material (
1963- child: Container (
1964- alignment: Alignment .topLeft,
1965- child: const ListTile (
1966- minLeadingWidth: 60.0 ,
1967- leading: Text ('L' ),
1968- title: Text ('title' ),
1969- trailing: Text ('T' ),
1991+ child: ListTileTheme (
1992+ minLeadingWidth: themeMinLeadingWidth,
1993+ child: Container (
1994+ alignment: Alignment .topLeft,
1995+ child: ListTile (
1996+ minLeadingWidth: widgetMinLeadingWidth,
1997+ leading: const Text ('L' ),
1998+ title: const Text ('title' ),
1999+ trailing: const Text ('T' ),
2000+ ),
19702001 ),
19712002 ),
19722003 ),
@@ -1977,18 +2008,31 @@ void main() {
19772008 double left (String text) => tester.getTopLeft (find.text (text)).dx;
19782009 double right (String text) => tester.getTopRight (find.text (text)).dx;
19792010
1980- await tester.pumpWidget (buildFrame (TextDirection .ltr));
1981-
2011+ await tester.pumpWidget (buildFrame (TextDirection .ltr, widgetMinLeadingWidth: 60 ));
19822012 expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 56.0 ));
1983- // minLeadingWidth: 60.0
19842013 // 92.0 = 16.0(Default contentPadding) + 16.0(Default horizontalTitleGap) + 60.0
19852014 expect (left ('title' ), 92.0 );
19862015
1987- await tester.pumpWidget (buildFrame (TextDirection .rtl));
2016+ await tester.pumpWidget (buildFrame (TextDirection .ltr, themeMinLeadingWidth: 60 ));
2017+ expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 56.0 ));
2018+ expect (left ('title' ), 92.0 );
2019+
2020+ await tester.pumpWidget (buildFrame (TextDirection .ltr, themeMinLeadingWidth: 0 , widgetMinLeadingWidth: 60 ));
2021+ expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 56.0 ));
2022+ expect (left ('title' ), 92.0 );
2023+
19882024
2025+ await tester.pumpWidget (buildFrame (TextDirection .rtl, widgetMinLeadingWidth: 60 ));
19892026 expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 56.0 ));
1990- // minLeadingWidth: 60.0
19912027 // 708.0 = 800.0 - (16.0(Default contentPadding) + 16.0(Default horizontalTitleGap) + 60.0)
19922028 expect (right ('title' ), 708.0 );
2029+
2030+ await tester.pumpWidget (buildFrame (TextDirection .rtl, themeMinLeadingWidth: 60 ));
2031+ expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 56.0 ));
2032+ expect (right ('title' ), 708.0 );
2033+
2034+ await tester.pumpWidget (buildFrame (TextDirection .rtl, themeMinLeadingWidth: 0 , widgetMinLeadingWidth: 60 ));
2035+ expect (tester.getSize (find.byType (ListTile )), const Size (800.0 , 56.0 ));
2036+ expect (right ('title' ), 708.0 );
19932037 });
19942038}
0 commit comments