Skip to content

Commit 2e7f4eb

Browse files
committed
增加页面旋转支持
1 parent 566b774 commit 2e7f4eb

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

lib/page/code_detail_page_web.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,9 @@ class _CodeDetailPageState extends State<CodeDetailPageWeb> {
8383
@override
8484
Widget build(BuildContext context) {
8585
return new Scaffold(
86-
appBar: isLand == false
87-
? new AppBar(
88-
title: GSYTitleBar(widget.title),
89-
)
90-
: null,
86+
appBar: new AppBar(
87+
title: GSYTitleBar(widget.title),
88+
),
9189
body: FutureBuilder<String>(
9290
initialData: widget.data,
9391
future: _getData(),
@@ -123,17 +121,19 @@ class _CodeDetailPageState extends State<CodeDetailPageWeb> {
123121
child: Icon(
124122
isLand ? Icons.screen_lock_landscape : Icons.screen_lock_portrait),
125123
onPressed: () {
126-
if (isLand) {
127-
isLand = false;
128-
SystemChrome.setPreferredOrientations([
129-
DeviceOrientation.portraitUp,
130-
]);
131-
} else {
132-
isLand = true;
133-
SystemChrome.setPreferredOrientations([
134-
DeviceOrientation.landscapeLeft,
135-
]);
136-
}
124+
setState(() {
125+
if (isLand) {
126+
isLand = !isLand;
127+
SystemChrome.setPreferredOrientations([
128+
DeviceOrientation.portraitUp,
129+
]);
130+
} else {
131+
isLand = !isLand;
132+
SystemChrome.setPreferredOrientations([
133+
DeviceOrientation.landscapeLeft,
134+
]);
135+
}
136+
});
137137
},
138138
),
139139
);

0 commit comments

Comments
 (0)