Flutter Listview使用

import 'package:flutter/material.dart';

void main() {
  runApp(MsgPage());
}

class MsgPage extends StatelessWidget {
  const MsgPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'ListView Demo',
      home: Scaffold(
          appBar: AppBar(
            title: Text('ListView Demo'),
            backgroundColor: Colors.red,
          ),
          body: new ListView.builder(
            itemCount: 30,
            itemBuilder: (context, index) {
              return Text(
                'item $index',
                textAlign: TextAlign.center,
                style: TextStyle(
                  fontSize: 20.0,
                  color: Colors.pink,
                ),
              );
            },
          )),
    );
  }
}
View Code

 

posted @ 2022-07-19 14:43  KingWang588  阅读(13)  评论(0编辑  收藏  举报