diff --git a/packages/flutter/lib/src/material/about.dart b/packages/flutter/lib/src/material/about.dart index 14a7861cd8..8b7c36f4b8 100644 --- a/packages/flutter/lib/src/material/about.dart +++ b/packages/flutter/lib/src/material/about.dart @@ -611,41 +611,40 @@ class _PackagesViewState extends State<_PackagesView> { return FutureBuilder<_LicenseData>( future: licenses, builder: (BuildContext context, AsyncSnapshot<_LicenseData> snapshot) { - return AnimatedSwitcher( - transitionBuilder: (Widget child, Animation animation) => FadeTransition(opacity: animation, child: child), - duration: kThemeAnimationDuration, - child: LayoutBuilder( - key: ValueKey(snapshot.connectionState), - builder: (BuildContext context, BoxConstraints constraints) { - switch (snapshot.connectionState) { - case ConnectionState.done: - _initDefaultDetailPage(snapshot.data, context); - return ValueListenableBuilder( - valueListenable: widget.selectedId, - builder: (BuildContext context, int selectedId, Widget _) { - return Center( - child: Material( - color: Theme.of(context).cardColor, - elevation: 4.0, - child: Container( - constraints: BoxConstraints.loose(const Size.fromWidth(600.0)), - child: _packagesList(context, selectedId, snapshot.data, widget.isLateral), - ), + return LayoutBuilder( + key: ValueKey(snapshot.connectionState), + builder: (BuildContext context, BoxConstraints constraints) { + switch (snapshot.connectionState) { + case ConnectionState.done: + _initDefaultDetailPage(snapshot.data, context); + return ValueListenableBuilder( + valueListenable: widget.selectedId, + builder: (BuildContext context, int selectedId, Widget _) { + return Center( + child: Material( + color: Theme.of(context).cardColor, + elevation: 4.0, + child: Container( + constraints: BoxConstraints.loose(const Size.fromWidth(600.0)), + child: _packagesList(context, selectedId, snapshot.data, widget.isLateral), ), - ); - }, - ); - default: - return Column( + ), + ); + }, + ); + default: + return Material( + color: Theme.of(context).cardColor, + child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ widget.about, const Center(child: CircularProgressIndicator()), ], - ); - } - }, - ), + ), + ); + } + }, ); }, ); diff --git a/packages/flutter/test/material/about_test.dart b/packages/flutter/test/material/about_test.dart index 8cffd2a8ec..9c717528e4 100644 --- a/packages/flutter/test/material/about_test.dart +++ b/packages/flutter/test/material/about_test.dart @@ -664,6 +664,53 @@ void main() { expect(box.localToGlobal(Offset.zero), equals(originalOffset.translate(0.0, -20.0))); }); + + testWidgets("LicensePage's color must be same whether loading or done", (WidgetTester tester) async { + const Color scaffoldColor = Color(0xFF123456); + const Color cardColor = Color(0xFF654321); + + await tester.pumpWidget(MaterialApp( + theme: ThemeData.light().copyWith( + scaffoldBackgroundColor: scaffoldColor, + cardColor: cardColor, + ), + home: Scaffold( + body: Center( + child: Builder( + builder: (BuildContext context) => GestureDetector( + child: const Text('Show licenses'), + onTap: () { + showLicensePage( + context: context, + applicationName: 'MyApp', + applicationVersion: '1.0.0', + ); + } + ), + ), + ), + ), + )); + + await tester.tap(find.text('Show licenses')); + await tester.pump(); + await tester.pump(); + + // Check color when loading. + final List materialLoadings = tester.widgetList(find.byType(Material)).toList(); + expect(materialLoadings.length, equals(4)); + expect(materialLoadings[1].color, scaffoldColor); + expect(materialLoadings[2].color, cardColor); + + await tester.pumpAndSettle(); + + // Check color when done. + expect(find.byKey(const ValueKey(ConnectionState.done)), findsOneWidget); + final List materialDones = tester.widgetList(find.byType(Material)).toList(); + expect(materialDones.length, equals(3)); + expect(materialDones[0].color, scaffoldColor); + expect(materialDones[1].color, cardColor); + }); } class FakeLicenseEntry extends LicenseEntry {