Skip to content

Commit b44137f

Browse files
authored
Fix: CupertinoSheetTransition moves SystemUIOverlayStyle to outside of delegatedTransition and only changes top bar (flutter#164680)
Fix: CupertinoSheetTransition should set the SystemUIOverlayStyle in init state fixes: flutter#164633 Fixes flutter#164134 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
1 parent e5cd67b commit b44137f

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

packages/flutter/lib/src/cupertino/sheet.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ class CupertinoSheetTransition extends StatefulWidget {
258258
final Animation<double> scaleAnimation = curvedAnimation.drive(_kScaleTween);
259259
curvedAnimation.dispose();
260260

261-
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
262-
263261
final bool isDarkMode = CupertinoTheme.brightnessOf(context) == Brightness.dark;
264262
final Color overlayColor = isDarkMode ? const Color(0xFFc8c8c8) : const Color(0xFF000000);
265263

@@ -350,6 +348,12 @@ class _CupertinoSheetTransitionState extends State<CupertinoSheetTransition> {
350348
@override
351349
void initState() {
352350
super.initState();
351+
SystemChrome.setSystemUIOverlayStyle(
352+
const SystemUiOverlayStyle(
353+
statusBarBrightness: Brightness.dark,
354+
statusBarIconBrightness: Brightness.light,
355+
),
356+
);
353357
_setupAnimation();
354358
}
355359

packages/flutter/test/cupertino/sheet_test.dart

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'package:flutter/cupertino.dart';
66
import 'package:flutter/material.dart';
7+
import 'package:flutter/services.dart';
78
import 'package:flutter_localizations/flutter_localizations.dart';
89
import 'package:flutter_test/flutter_test.dart';
910

@@ -1212,4 +1213,38 @@ void main() {
12121213
expect(finalPosition, equals(initialPosition));
12131214
});
12141215
});
1216+
1217+
testWidgets('CupertinoSheetTransition handles SystemUiOverlayStyle changes', (
1218+
WidgetTester tester,
1219+
) async {
1220+
final AnimationController controller = AnimationController(
1221+
duration: const Duration(milliseconds: 100),
1222+
vsync: const TestVSync(),
1223+
);
1224+
addTearDown(controller.dispose);
1225+
1226+
final Animation<double> secondaryAnimation = Tween<double>(
1227+
begin: 1,
1228+
end: 0,
1229+
).animate(controller);
1230+
1231+
await tester.pumpWidget(
1232+
CupertinoApp(
1233+
home: AnimatedBuilder(
1234+
animation: controller,
1235+
builder: (BuildContext context, Widget? child) {
1236+
return CupertinoSheetTransition(
1237+
primaryRouteAnimation: controller,
1238+
secondaryRouteAnimation: secondaryAnimation,
1239+
linearTransition: false,
1240+
child: const SizedBox(),
1241+
);
1242+
},
1243+
),
1244+
),
1245+
);
1246+
1247+
expect(SystemChrome.latestStyle!.statusBarBrightness, Brightness.dark);
1248+
expect(SystemChrome.latestStyle!.statusBarIconBrightness, Brightness.light);
1249+
});
12151250
}

0 commit comments

Comments
 (0)