如何将api的html响应转换为简单文本,但它们的标签质量

问题描述 投票:0回答:1

获取 html 中的请求响应,我访问的属性基本上是与 HTML 一起出现的文本

here is output 我们得到数组,然后我们在 json 中解析我的 fetchAllQuotes 方法

fetchAllQuotes() async {
    final response =
        await http.get(Uri.parse('https://quotes.limpidsol.com/api/quotes'));
    // final quotesData = jsonDecode(response.body);

    final quotesData = quoteModelFromJson(response.body);
    data = quotesData.dataArr.data;

    // print(data);
  }

这里我得到单引号

Iterable<Widget>? plainText() {
    // final quotePlanText1 = data?.map((v) => convertQuoteToPlainStr(v.qoute));
    final quotePlanText = data?.map(
      (v) => Container(
        child: Center(
          child: Text(
            '${v.qoute}',
            style: TextStyle(
              fontSize: 22,
              fontFamily: 'Poppins',
            ),
          ),
        ),
      ),
    );
    return quotePlanText;
  }

显示构建方法: little and complete code of build method 我期待这样的输出: i expecting the output like this

flutter dart
1个回答
0
投票

使用 Flutter_HTML 包按原样显示带有 html 标签的数据,这样您就可以按照从 api 获取报价的确切方式显示报价/它们是“预期的”。 或者使用 HTML 包中的解析器并从其 html 元素中剥离数据,这样您就可以得到纯文本形式的引号,并且可以根据需要编辑和显示它们。

© www.soinside.com 2019 - 2024. All rights reserved.