flutter - 带有黑色容器的 ListView 在它们之间显示一条 1 px 的白线
问题描述
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Listview Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
body: ListWidget(),
),
);
}
}
class ListWidget extends StatelessWidget {
const ListWidget({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final width = MediaQuery.of(context).size.width;
final height = MediaQuery.of(context).size.height;
return ListView(
children: <Widget>[
Container(
width: width,
height: height,
color: Colors.black,
),
Container(
width: width,
height: height,
color: Colors.black,
),
Container(
width: width,
height: height,
color: Colors.black,
),
Container(
width: width,
height: height,
color: Colors.black,
),
],
);
}
}
当我在模拟器中运行上述代码时,有时两个容器之间会出现一条细白线,如下所示。
这种情况几乎总是发生,并且在我为 Web 构建应用程序并在 chrome 上运行时更加明显。即使是生产版本也有这些生产线。
我无法弄清楚发生了什么,我什至尝试将 ListView 替换为 SingleChildScrollView,并将子元素作为列。但它仍然是一样的。
解决方案
推荐阅读
- regex - 用于匹配前向参考练习的正则表达式
- ios - 使用 CloudKit 共享时如何正确使用数据库订阅
- linux - bash -c 变量没有被分配
- json - Spring API 应该返回 JSON 而不是转义的 String
- gulp - 通过 Gulp 编译 SASS 时出现 Compass Failed 错误
- verilog - 不允许对非寄存器 trig_i_a 进行 Synth 8-2576 程序分配
- vb.net - 如何修复这个关于列表框的逻辑错误
- html - 如何使用 d3 和 geojson 路径数据缩放我的地图以适合我的 svg 大小
- android - 刷新前查看延迟
- c# - 有没有办法播种 3+ 层级(一对多),包括与 JSON 的自引用关系?