diff --git a/packages/flutter_markdown/CHANGELOG.md b/packages/flutter_markdown/CHANGELOG.md index 9d901df3fa7..7b19e96b64a 100644 --- a/packages/flutter_markdown/CHANGELOG.md +++ b/packages/flutter_markdown/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.20+1 + +* Updates minimum supported SDK version to Flutter 3.19. + ## 0.6.20 * Adds `textScaler` to `MarkdownStyleSheet`, and deprecates `textScaleFactor`. diff --git a/packages/flutter_markdown/lib/src/_functions_web.dart b/packages/flutter_markdown/lib/src/_functions_web.dart index 7adf81654be..abf23453225 100644 --- a/packages/flutter_markdown/lib/src/_functions_web.dart +++ b/packages/flutter_markdown/lib/src/_functions_web.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:html'; // ignore: avoid_web_libraries_in_flutter +import 'dart:js_interop'; import 'package:flutter/cupertino.dart' show CupertinoTheme; import 'package:flutter/material.dart' show Theme; @@ -50,20 +50,14 @@ final MarkdownStyleSheet Function(BuildContext, MarkdownStyleSheetBaseTheme?) BuildContext context, MarkdownStyleSheetBaseTheme? baseTheme, ) { - MarkdownStyleSheet result; - switch (baseTheme) { - case MarkdownStyleSheetBaseTheme.platform: - final String userAgent = window.navigator.userAgent; - result = userAgent.contains('Mac OS X') - ? MarkdownStyleSheet.fromCupertinoTheme(CupertinoTheme.of(context)) - : MarkdownStyleSheet.fromTheme(Theme.of(context)); - case MarkdownStyleSheetBaseTheme.cupertino: - result = - MarkdownStyleSheet.fromCupertinoTheme(CupertinoTheme.of(context)); - case MarkdownStyleSheetBaseTheme.material: - default: // ignore: no_default_cases - result = MarkdownStyleSheet.fromTheme(Theme.of(context)); - } + final MarkdownStyleSheet result = switch (baseTheme) { + MarkdownStyleSheetBaseTheme.platform + when _userAgent.toDart.contains('Mac OS X') => + MarkdownStyleSheet.fromCupertinoTheme(CupertinoTheme.of(context)), + MarkdownStyleSheetBaseTheme.cupertino => + MarkdownStyleSheet.fromCupertinoTheme(CupertinoTheme.of(context)), + _ => MarkdownStyleSheet.fromTheme(Theme.of(context)), + }; return result.copyWith( textScaler: MediaQuery.textScalerOf(context), @@ -84,3 +78,6 @@ Widget _handleDataSchemeUri( } return const SizedBox(); } + +@JS('window.navigator.userAgent') +external JSString get _userAgent; diff --git a/packages/flutter_markdown/lib/src/builder.dart b/packages/flutter_markdown/lib/src/builder.dart index 5d3cb10a8e4..91371dd1c6e 100644 --- a/packages/flutter_markdown/lib/src/builder.dart +++ b/packages/flutter_markdown/lib/src/builder.dart @@ -2,14 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// ignore: unnecessary_import, see https://github.com/flutter/flutter/pull/138881 -import 'dart:ui'; - import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:markdown/markdown.dart' as md; -import '_functions_io.dart' if (dart.library.html) '_functions_web.dart'; +import '_functions_io.dart' if (dart.library.js_interop) '_functions_web.dart'; import 'style_sheet.dart'; import 'widget.dart'; diff --git a/packages/flutter_markdown/pubspec.yaml b/packages/flutter_markdown/pubspec.yaml index 0a3c89d24e7..c5b8d4706f1 100644 --- a/packages/flutter_markdown/pubspec.yaml +++ b/packages/flutter_markdown/pubspec.yaml @@ -4,11 +4,11 @@ description: A Markdown renderer for Flutter. Create rich text output, formatted with simple Markdown tags. repository: https://github.com/flutter/packages/tree/main/packages/flutter_markdown issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_markdown%22 -version: 0.6.20 +version: 0.6.20+1 environment: - sdk: ^3.2.0 - flutter: ">=3.16.0" + sdk: ^3.3.0 + flutter: ">=3.19.0" dependencies: flutter: