facebook twitter hatena line email

「Flutter/UI/ListView/基本」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
行30: 行30:
 
<pre>
 
<pre>
 
class _MyHomePageState extends State<MyHomePage> {
 
class _MyHomePageState extends State<MyHomePage> {
 
 
   @override
 
   @override
 
   Widget build(BuildContext context) {
 
   Widget build(BuildContext context) {

2019年4月30日 (火) 01:59時点における版

枠線なし

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    const data = [
      "taro", "jiro", "saburo",
    ];
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ListView.builder(
        itemCount: data.length,
        itemBuilder: (context, int index) {
          return Padding(
              padding: EdgeInsets.all(8.0),
              child: Text(
                data[index],
              ));
        },
      ),
    );
  }

https://nzigen.com/flutter-reference/2018-04-17-list-view.html

枠線あり

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    const data = [
      "taro", "jiro", "saburo",
    ];
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ListView.builder(
        itemCount: data.length,
        itemBuilder: (context, int index) {
          return Card(
            child: Padding(
              child: Text(data[index],),
              padding: EdgeInsets.all(20.0),),
          );
        },
      ),
    );
  }
}