如何在 ListView.builder 中的最后一项下方添加一些白色 space?以便我可以正确点击最后一个复选框?
How can I add some white space beneath the last item in a ListView.builder? so that I can properly tap the last checkbox?
我的 ListView
的最后一项落后于 FloatingActionButton
。我怎样才能让 ListView
向上滚动或者添加一个空的 Container
作为它的最后一项?
我认为 padding
是您要找的:
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
home: HomePage(),
),
);
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView.builder(
padding: EdgeInsets.only(bottom: 80.0),
itemCount: 20,
itemBuilder: (context, index) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Label $index'),
Checkbox(value: false, onChanged: (_) {}),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
);
}
}
我的 ListView
的最后一项落后于 FloatingActionButton
。我怎样才能让 ListView
向上滚动或者添加一个空的 Container
作为它的最后一项?
我认为 padding
是您要找的:
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
home: HomePage(),
),
);
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView.builder(
padding: EdgeInsets.only(bottom: 80.0),
itemCount: 20,
itemBuilder: (context, index) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Label $index'),
Checkbox(value: false, onChanged: (_) {}),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
);
}
}