chore: update markdown dependency and configuration
- Replaced `gpt_markdown` with `flutter_markdown_plus` in `pubspec.yaml`. - Updated `pubspec.lock` to reflect the new dependency version. - Modified `markdown_config.dart` to generalize styling configuration. - Updated `streaming_markdown_widget.dart` to utilize `MarkdownBody` for rendering markdown content.
This commit is contained in:
@@ -4,7 +4,7 @@ import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:conduit/shared/theme/theme_extensions.dart';
|
||||
import 'package:conduit/l10n/app_localizations.dart';
|
||||
|
||||
/// Configuration for GptMarkdown styling
|
||||
/// Configuration for markdown styling
|
||||
class ConduitMarkdownStyleConfig {
|
||||
final TextStyle textStyle;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gpt_markdown/gpt_markdown.dart';
|
||||
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
|
||||
import 'package:conduit/shared/theme/theme_extensions.dart';
|
||||
import 'package:conduit/shared/widgets/markdown/markdown_config.dart';
|
||||
|
||||
class StreamingMarkdownWidget extends StatefulWidget {
|
||||
@@ -107,13 +108,44 @@ class _StreamingMarkdownWidgetState extends State<StreamingMarkdownWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final config = ConduitMarkdownConfig.getStyleConfig(context: context);
|
||||
final theme = Theme.of(context);
|
||||
final styleSheet = MarkdownStyleSheet.fromTheme(
|
||||
theme,
|
||||
).copyWith(p: config.textStyle);
|
||||
final conduitTheme = context.conduitTheme;
|
||||
|
||||
if (_renderedContent.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
// GptMarkdown handles both streaming and static content elegantly
|
||||
return GptMarkdown(_renderedContent, style: config.textStyle);
|
||||
// MarkdownBody handles both streaming and static content elegantly
|
||||
return MarkdownBody(
|
||||
data: _renderedContent,
|
||||
styleSheet: styleSheet,
|
||||
softLineBreak: true,
|
||||
selectable: true,
|
||||
imageBuilder: (uri, title, alt) {
|
||||
final scheme = uri.scheme;
|
||||
|
||||
if (scheme == 'data') {
|
||||
return ConduitMarkdownConfig.buildBase64Image(
|
||||
uri.toString(),
|
||||
context,
|
||||
conduitTheme,
|
||||
);
|
||||
}
|
||||
|
||||
if (scheme.isEmpty || scheme == 'http' || scheme == 'https') {
|
||||
return ConduitMarkdownConfig.buildNetworkImage(
|
||||
uri.toString(),
|
||||
context,
|
||||
conduitTheme,
|
||||
);
|
||||
}
|
||||
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
90
pubspec.lock
90
pubspec.lock
@@ -443,14 +443,14 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_math_fork:
|
||||
dependency: transitive
|
||||
flutter_markdown_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_math_fork
|
||||
sha256: "6d5f2f1aa57ae539ffb0a04bb39d2da67af74601d685a161aff7ce5bda5fa407"
|
||||
name: flutter_markdown_plus
|
||||
sha256: "7f349c075157816da399216a4127096108fd08e1ac931e34e72899281db4113c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.4"
|
||||
version: "1.0.5"
|
||||
flutter_native_splash:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -531,14 +531,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.3"
|
||||
flutter_svg:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_svg
|
||||
sha256: b9c2ad5872518a27507ab432d1fb97e8813b05f0fc693f9d40fad06d073e0678
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@@ -597,14 +589,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.8.1"
|
||||
gpt_markdown:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: gpt_markdown
|
||||
sha256: "8174983f2ed7d8576d25810913e3afe3f8ffdaa3172c0c823b7cfc289b67f380"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.4"
|
||||
graphs:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -805,6 +789,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
markdown:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: markdown
|
||||
sha256: "935e23e1ff3bc02d390bad4d4be001208ee92cc217cb5b5a6c19bc14aaa318c1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.3.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -845,14 +837,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.5.0"
|
||||
nested:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: nested
|
||||
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
node_preamble:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -901,14 +885,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.1"
|
||||
path_parsing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_parsing
|
||||
sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
path_provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -997,14 +973,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.3"
|
||||
provider:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: provider
|
||||
sha256: "4e82183fa20e5ca25703ead7e05de9e4cceed1fbd1eadc1ac3cb6f565a09f272"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.5+1"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1490,14 +1458,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
tuple:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: tuple
|
||||
sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1586,30 +1546,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.5.1"
|
||||
vector_graphics:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_graphics
|
||||
sha256: a4f059dc26fc8295b5921376600a194c4ec7d55e72f2fe4c7d2831e103d461e6
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.19"
|
||||
vector_graphics_codec:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_graphics_codec
|
||||
sha256: "99fd9fbd34d9f9a32efd7b6a6aae14125d8237b10403b422a6a6dfeac2806146"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.13"
|
||||
vector_graphics_compiler:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_graphics_compiler
|
||||
sha256: d354a7ec6931e6047785f4db12a1f61ec3d43b207fc0790f863818543f8ff0dc
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.19"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -28,7 +28,7 @@ dependencies:
|
||||
shared_preferences: ^2.3.2
|
||||
|
||||
# UI Components - Enhanced Markdown
|
||||
gpt_markdown: ^1.1.4
|
||||
flutter_markdown_plus: ^1.0.5
|
||||
cached_network_image: ^3.3.1
|
||||
socket_io_client: ^3.1.2
|
||||
yaml: ^3.1.2
|
||||
|
||||
Reference in New Issue
Block a user