Flutter – ListView,

  • ListView 및 ListWidget이란 무엇입니까?

->ListView와 ListTile을 함께 사용하여 사이드 메뉴 목록을 추가할 수 있습니다.

목록보기

– 목록 표시용 위젯

– ListTile 위젯과 함께 사용하면 편리합니다.

-scrollDirection: 스크롤 방향

-어린이: 목록 콘텐츠

타일 ​​목록

– Leading, Title, Subtitle 및 Traling 속성을 사용하여 왼쪽, 중앙 또는 오른쪽에 아이콘이나 텍스트를 쉽게 배치할 수 있습니다.

– 탭할 때 동작을 설정하려면 onTap 속성을 사용하십시오.

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        // This method is rerun every time setState is called, for instance as done
        // by the _incrementCounter method above.
        //
        // The Flutter framework has been optimized to make rerunning build methods
        // fast, so that you can just rebuild anything that needs updating rather
        // than having to individually change instances of widgets.
        home: Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: const Text("제목"),
      ),
      body: ListView(
        scrollDirection: Axis.vertical,
        children: <Widget>(
          ListTile(
            leading: Icon(Icons.home),
            title: Text("홈"),
            trailing: Icon(Icons.navigate_next),
            onTap: () {},
          ),
          ListTile(
            leading: Icon(Icons.info),
            title: Text("정보"),
            trailing: Icon(Icons.navigate_next),
            onTap: () {},
          ),
          ListTile(
            leading: Icon(Icons.person),
            title: Text("마이페이지"),
            subtitle: Text("로그인 후 이용해주세요."),
            trailing: Icon(Icons.navigate_next),
            onTap: () {},
          )
        ),
      ),
    ));
  }
}