Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 52 additions & 9 deletions lib/widgets/response_body_success.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:apidash_core/apidash_core.dart';
import 'package:apidash_design_system/apidash_design_system.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:apidash/utils/utils.dart';
import 'package:apidash/widgets/widgets.dart';
import 'package:apidash/consts.dart';
Expand Down Expand Up @@ -38,6 +39,7 @@ class ResponseBodySuccess extends StatefulWidget {

class _ResponseBodySuccessState extends State<ResponseBodySuccess> {
int segmentIdx = 0;
bool _enableFormatting = true;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -143,16 +145,57 @@ class _ResponseBodySuccessState extends State<ResponseBodySuccess> {
),
),
ResponseBodyView.answer => Expanded(
child: Container(
width: double.maxFinite,
padding: kP8,
decoration: textContainerdecoration,
child: SingleChildScrollView(
child: SelectableText(
widget.formattedBody ?? widget.body,
style: kCodeStyle,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
ADCheckBox(
keyId: 'format-markdown-checkbox',
value: _enableFormatting,
onChanged: (value) {
setState(() {
_enableFormatting = value ?? false;
});
},
),
kHSpacer4,
Text(
'Format Markdown',
style: Theme.of(context).textTheme.bodyMedium,
),
],
),
),
kVSpacer8,
Expanded(
child: Container(
width: double.maxFinite,
padding: kP8,
decoration: textContainerdecoration,
child: _enableFormatting
? Markdown(
data: widget.formattedBody ?? widget.body,
selectable: true,
styleSheet: MarkdownStyleSheet.fromTheme(
Theme.of(context),
).copyWith(
p: Theme.of(context).textTheme.bodyMedium,
code: kCodeStyle.copyWith(
backgroundColor: Theme.of(context)
.colorScheme
.surfaceContainerHighest,
),
),
)
: SingleChildScrollView(
child: SelectableText(
widget.formattedBody ?? widget.body,
style: kCodeStyle,
),
),
),
),
],
),
),
ResponseBodyView.raw => Expanded(
Expand Down