加载页面时图像的ListView冻结

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

我在ContrainedBox小部件内的Card小部件中只有一张图像列表。我想添加更多。当我单击并加载页面时,应用程序冻结。

这是我的小部件

 @override
  Widget build(BuildContext context) {
    return DevScaffold(
      title: "Team",
      body: ListView.builder(
        shrinkWrap: true,
        itemCount: teams.length,
        itemBuilder: (BuildContext context, int index) {
        return Card(
            elevation: 0.0,
            child: Padding(
                padding: const EdgeInsets.all(12.0),
                child: Row(
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    ConstrainedBox(
                      constraints: BoxConstraints.expand(
                        height: MediaQuery.of(context).size.height * 0.2,
                        width: MediaQuery.of(context).size.width * 0.3,
                      ),
                      child: CachedNetworkImage(
                        fit: BoxFit.cover,
                        imageUrl: teams[index].image,
                      ),
                    ),
                    SizedBox(
                      width: 20,
                    ),...

这是我的数据类:

List<Sponsor> sponsors = [
  Sponsor(
    name: "Google Developer Groups",
    image: "https://devfestflorida.org/images/logos/gdg-logo-new.svg",
    desc: "Platinum Sponsor",
    url: 'https://developers.google.com/community/gdg/',
  ),
  Sponsor(
    name: "Neoware Studios",
    image: "https://devfestflorida.org/images/logos/STUDIOSLOGO_WITHTM.png",
    desc: "Platinum Sponsor",
    url: 'https://www.neowarestudios.com/',
  ),
];...

在有意义的事情上,没有任何真正的异常扑朔迷离,但这是日志:

C:\Users\javier.carrion\OneDrive\CodeVista\TechEvents\DevFest\DevFest2019Nov\devfestcenfl\devfestcenfl>flutter analyze
Analyzing devfestcenfl...
No issues found! (ran in 17.4s)

C:\Users\javier.carrion\OneDrive\CodeVista\TechEvents\DevFest\DevFest2019Nov\devfestcenfl\devfestcenfl>
C:\Users\javier.carrion\OneDrive\CodeVista\TechEvents\DevFest\DevFest2019Nov\devfestcenfl\devfestcenfl>
C:\Users\javier.carrion\OneDrive\CodeVista\TechEvents\DevFest\DevFest2019Nov\devfestcenfl\devfestcenfl>
C:\Users\javier.carrion\OneDrive\CodeVista\TechEvents\DevFest\DevFest2019Nov\devfestcenfl\devfestcenfl>

Flutter Doctor:

[√] Flutter (Channel stable, v1.9.1+hotfix.5, on Microsoft Windows [Version 10.0.16299.1087], locale en-US)
    • Flutter version 1.9.1+hotfix.5 at C:\src\flutter
    • Framework revision 1aedbb1835 (13 days ago), 2019-10-17 08:37:27 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0


[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\Users\javier.carrion\AppData\Local\Android\Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[√] Android Studio (version 3.4)
    • Android Studio at C:\Program Files\Android\Android Studio1
    • Flutter plugin version 35.3.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[√] VS Code, 64-bit edition (version 1.39.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.5.1

[√] Connected device (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

• No issues found!
flutter dart
1个回答
0
投票

如注释中所示,CachedNetworkImage不呈现svg。 Flutter不支持SVG,但是您可以使用提供flutter_svg之类支持的软件包。

这里是有关svg支持的更多信息

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