相关疑难解决方法(0)

如何在Flutter中在图像上显示文本?

我想在中的图像上显示文本Listview。我能够看到图像和文本,但文本将显示在左上角。我想在每个图像的每个文本上显示它。下面是我的代码。请帮我

import 'dart:async';
import 'dart:convert';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;

Future<List<Photo>> fetchPhotos(http.Client client) async {
  final response = await client.get('url here');
  return compute(parsePhotos, response.body);
}

// A function that will convert a response body into a List<Photo>
List<Photo> parsePhotos(String responseBody) {
  final parsed = json.decode(responseBody);
  return (parsed["data"]["categoryList"] as List)
      .map<Photo>((json) => new Photo.fromJson(json))
      .toList();
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    SystemChrome.setEnabledSystemUIOverlays([]);
    return new MyHomePage();
  }
} …
Run Code Online (Sandbox Code Playgroud)

android flutter

7
推荐指数
4
解决办法
1万
查看次数

标签 统计

android ×1

flutter ×1