android - flutter :ListWheelScrollView放大镜不起作用

标签 android flutter listview dart

ListWheelScrollView的放大镜为空(只是一个白色容器)

ListWheelScrollView(
  itemExtent: 60,
  magnification: 2,
  useMagnifier: true,
  children: List.generate(
     100,
      (index) => Card(
          key: ValueKey(index),
          color: Colors.blue,
          child: ListTile(
            title: Text(index.toString()),
          ))).toList(),
),
我究竟做错了什么?
(当运行flutter run -vflutter doctor -v未发现任何问题时,不会显示任何错误)
enter image description here

最佳答案

  • 您可以使用Container代替Card并为其设置水平padding:
  • ListWheelScrollView(
      itemExtent: 60,
      magnification: 1.5,
      useMagnifier: true,
      squeeze: 0.7,
      children: List.generate(
        100,
        (index) => Container(
          key: ValueKey(index),
          padding: EdgeInsets.symmetric(horizontal: 100),
          decoration: BoxDecoration(
            color: Colors.blue,
            borderRadius: BorderRadius.circular(8),
          ),
          child: ListTile(
            title: Text(index.toString()),
          ),
        )).toList(),
    ),
    
    结果:
    res
  • 您可以将文本放在ListTile小部件中,而不是使用padding和水平Center,而该部件直接放在Container内:
  • ListWheelScrollView(
      itemExtent: 60,
      magnification: 1.5,
      useMagnifier: true,
      squeeze: 0.7,
      children: List.generate(
        100,
        (index) => Container(
          key: ValueKey(index),
          decoration: BoxDecoration(
            color: Colors.blue,
            borderRadius: BorderRadius.circular(8),
          ),
          child: Center(
            child: Text(index.toString()),
          ),
        )).toList(),
    ),
    
    结果:
    res2

    关于android - flutter :ListWheelScrollView放大镜不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63545893/

    相关文章:

    android - 为 Flickr 身份验证创建签名(Android SDK)

    android - 同一 Appengine 版本中的多个 Google Cloud Endpoint API 版本

    android-studio - 等待应用程序在 flutter 中启动超时(android studio)

    JavaFX ListView 为文本着色

    android - 适用于 Android 的 PostFinance 支付网关集成

    Android Fragments 在方向更改时复制 TextView

    android - 从APK/发行版/文件夹安装哪个Flutter APK

    flutter - 为什么在构建 flutter web 时出现白屏

    Android 自定义节标题 View

    xml - Android -- 帮助处理 ListView 中 "complex"行的 XML