본문 바로가기

Flutter/튜토리얼

Flutter Button

버튼의 종류

TextButton: 텍스트 버튼

IconButton: 아이콘 버튼

ElevatedButton: 예쁜 버튼 

 

속성

 child:  Text같은거 지정

 onPressed: 버튼이 눌렸을 때, 어떻게 동작하는가

 style: 버튼의 스타일

 

예제 코드:

 

import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            appBar: AppBar(title: const Text('My App'),),
            body: SizedBox(
              child: ElevatedButton(child: Text('example button'), onPressed: (){},),
              ),
            ));
  }
}

 

 

 

 

참고 자료:

 

https://www.youtube.com/watch?v=ShmXbPpmIMU 

 

'Flutter > 튜토리얼' 카테고리의 다른 글

Flutter Dart 함수  (0) 2022.02.02
Flutter - Isolates / Thread  (0) 2022.02.02
배치와 Scaffold  (0) 2022.01.31
기본 위젯 구현하기  (0) 2022.01.31
Flutter 설치하기(Windows)  (0) 2022.01.30