Flutter Listview

Flutter Listview

main.dart

import 'package:flutter/material.dart';

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

Tambahkan Stateless Widget dengan nama App

class App extends StatelessWidget {

  final String title = "ListView";
  final Color bgColor = Colors.green;
  final Color fgColor = Colors.white70;
  final IconData icLogo = Icons.star_border;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: title,
      home: Scaffold(
        backgroundColor: fgColor,
        appBar: new AppBar(
          backgroundColor: bgColor,
          leading: Icon(icLogo),
          title: Text(title),
        ),
        body: _WidgetList(),
      ),
    );
  }

}

Buat Stateless widget untuk menampung ListView

class _WidgetList extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return new ListView(
      children: <Widget>[
        
        //ROW 1
          SizedBox(height: 10.0),
          ListTile(
            leading: Text("1."),
            title: Text("Flutter"),
            trailing: Icon(Icons.star),
          ),

        //ROW 2
          SizedBox(height: 10.0),
          ListTile(
            leading: Text("2."),
            title: Text("Kotlin"),
            trailing: Icon(Icons.star_half),
          ),

        //ROW 3
          SizedBox(height: 10.0),
          ListTile(
            leading: Text("3."),
            title: Text("Java"),
            trailing: Icon(Icons.star_border),
          ),

      ],
    );
  }

}

Silahkan jalankan flutter di emulator atau device

Flutter Developer