Skip to content

Commit f669f16

Browse files
committed
platform: Use Flutter "target" platform, not actual Platform
This makes it possible to test this sort of logic. See docs for [defaultTargetPlatform]: https://api.flutter.dev/flutter/foundation/defaultTargetPlatform.html
1 parent 9b92676 commit f669f16

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/widgets/message_list.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'dart:io' show Platform;
21
import 'package:flutter/material.dart';
32
import 'package:intl/intl.dart';
43

@@ -172,12 +171,13 @@ class _MessageListState extends State<MessageList> {
172171
// TODO: Offer `ScrollViewKeyboardDismissBehavior.interactive` (or
173172
// similar) if that is ever offered:
174173
// https://github.com/flutter/flutter/issues/57609#issuecomment-1355340849
175-
keyboardDismissBehavior: Platform.isIOS
174+
keyboardDismissBehavior: switch (Theme.of(context).platform) {
176175
// This seems to offer the only built-in way to close the keyboard
177176
// on iOS. It's not ideal; see TODO above.
178-
? ScrollViewKeyboardDismissBehavior.onDrag
177+
TargetPlatform.iOS => ScrollViewKeyboardDismissBehavior.onDrag,
179178
// The Android keyboard seems to have a built-in close button.
180-
: ScrollViewKeyboardDismissBehavior.manual,
179+
_ => ScrollViewKeyboardDismissBehavior.manual,
180+
},
181181

182182
itemCount: length,
183183
// Setting reverse: true means the scroll starts at the bottom.

lib/widgets/text.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final TextStyle kMonospaceTextStyle = TextStyle(
1919

2020
// Oddly, iOS doesn't handle 'monospace':
2121
// https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20monospace.20font.20fallback/near/1570622
22+
// TODO use Theme.of, not Platform, so that this is testable (needs a BuildContext)
2223
fontFamilyFallback: Platform.isIOS ? ['Menlo', 'Courier'] : ['monospace'],
2324

2425
inherit: true,

0 commit comments

Comments
 (0)