【问题标题】:Flutter web : Textfield with editorFlutter web:带有编辑器的文本字段
【发布时间】:2020-08-13 12:48:09
【问题描述】:

我用这样的编辑器搜索了 5 个小时后的文本字段:

如此多行并带有编辑器。

编辑:

我的临时解决方案:

final _commentMarkdownTextContributorCreateMissionView = Padding(
      padding: EdgeInsets.only(top: 24.0),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text("Tout comprendre sur le "),
          InkWell(
            child: Text(
              "Markdown",
              style: TextStyle(color: IneatColors.pink),
            ),
            onTap: () async {
              if (await canLaunch("https://fr.wikipedia.org/wiki/Markdown")) {
                await launch("https://fr.wikipedia.org/wiki/Markdown");
              }
            },
          ),
        ],
      ),
    );

final _contextMissionMarkdownTextInputContributorCreateMissionView =
        Padding(
      padding: EdgeInsets.only(top: 24.0, bottom: 12.0),
      child: MarkdownTextInput(
        (String value) => model.setOnTextChangedContext(value),
        model.contextMarkdownTextInput,
        label: 'Contexte',
      ),
    );

    final _contextMissionMarkdownBodyContributorCreateMissionView = Padding(
      padding: EdgeInsets.only(top: 24.0, left: 12.0),
      child: MarkdownBody(
        data: model.contextMarkdownTextInput,
      ),
    );

flutter_markdown: # #Markdown : https://pub:dev/packages/flutter_markdown:

markdown_editable_textinput: # 文字输入:https://pub:dev/packages/markdown_editable_textinput#-example-tab-:

文本字段中的 Markdown 语言有效,但目前还不是工具,所以如果您有解决方案。

你能治愈我吗?兼容flutter web

【问题讨论】:

  • 请帮忙!这对我很重要!
  • 你试过这个叫做zefyr的包吗..! pub.dev/packages/zefyr。它仍处于早期预览阶段,但可能会有所帮助,您可以根据需要分叉和添加所需的功能。也关注这个issue
  • @MayuriXx 嘿,您是否找到了解决方案。我也需要 Flutter-web 中类似的文本编辑器。我找不到任何解决方案。
  • @SivaPerumal 我编辑了我的帖子并给出了解决方案
  • 非常好用的编辑器。令人耳目一新。

标签: flutter web flutter-web


【解决方案1】:

我希望这个插件能帮到你。 我在这里复制了插件的示例代码。 [flutter_markdown][1]

import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';

const String _markdownData = """
# Markdown Example
Markdown allows you to easily include formatted text, images, and even formatted Dart code in your app.

## Titles

Setext-style

这是一个 H1

这是一个 H2


Atx-style

这是一个 H1

这是一个 H2

这是H6

Select the valid headers:

- [x] `# hello`
- [ ] `#hello`

## Links

[Google's Homepage][Google]

inline-style

[参考风格][谷歌]


## Images

![Flutter logo](/dart-lang/site-shared/master/src/_assets/image/flutter/icon/64.png)

## Tables

|Syntax                                 |Result                               |
|---------------------------------------|-------------------------------------|
|`*italic 1*`                           |*italic 1*                           |
|`_italic 2_`                           | _italic 2_                          |
|`**bold 1**`                           |**bold 1**                           |
|`__bold 2__`                           |__bold 2__                           |
|`This is a ~~strikethrough~~`          |This is a ~~strikethrough~~          |
|`***italic bold 1***`                  |***italic bold 1***                  |
|`___italic bold 2___`                  |___italic bold 2___                  |
|`***~~italic bold strikethrough 1~~***`|***~~italic bold strikethrough 1~~***|
|`~~***italic bold strikethrough 2***~~`|~~***italic bold strikethrough 2***~~|

## Styling
Style text as _italic_, __bold__, ~~strikethrough~~, or `inline code`.

- Use bulleted lists
- To better clarify
- Your points

## Code blocks
Formatted Dart code looks really pretty too:

无效的主要(){ 运行应用程序(材料应用程序( 家:脚手架( 正文:Markdown(数据:markdownData), ), )); }


## Markdown widget

This is an example of how to create your own Markdown widget:

    Markdown(data: 'Hello _world_!');

Enjoy!

[Google]: https://www.google.com/
""";

void main() {
  final controller = ScrollController();

  runApp(
    MaterialApp(
      title: "Markdown Demo",
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Markdown Demo'),
        ),
        body: SafeArea(
          child: Markdown(
            controller: controller,
            selectable: true,
            data: _markdownData,
            imageDirectory: 'https://raw.githubusercontent.com',
          ),
        ),
        floatingActionButton: FloatingActionButton(
          child: Icon(Icons.arrow_upward),
          onPressed: () => controller.animateTo(0,
              duration: Duration(seconds: 1), curve: Curves.easeOut),
        ),
      ),
    ),
  );
}


  [1]: https://pub.dev/packages/flutter_markdown

【讨论】:

  • 感谢您的帮助。我不知道。当我只是尝试 Markdown 时,它不起作用。通过 cons MarkdownBody 效果很好,但我看不出它如何在 TextField 中工作?
  • 您可以制作一个普通的文本字段并在容器中显示上下文,就像堆栈溢出一样。看到有一个容器在文本字段中显示您正确的所有内容。
  • 这周我会试试 :)
  • 我用 markdownTextInput 和 MarkdownBody 打印结果
猜你喜欢
  • 2019-12-25
  • 2020-04-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-15
  • 2021-09-19
  • 2015-02-03
相关资源
最近更新 更多