본문 바로가기
웹공뷰/flutter

flutter button widget 버튼 위젯들

by 이노키_ 2023. 7. 15.
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget{

  @override
  Widget build(BuildContext context){
    return MaterialApp(
      home: Scaffold(
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Center(
              child: const Text('hello',
                style: TextStyle(
                  fontSize: 16.0,
                  fontWeight: FontWeight.w700,
                  color: Colors.blue,
                ),
              ),
            ),
            TextButton(
              onPressed: (){},
              style: TextButton.styleFrom(
                foregroundColor: Colors.green,
              ),
              child: const Text('text button'),
            ),
            OutlinedButton(
                onPressed: (){},
                style: OutlinedButton.styleFrom(
                  foregroundColor: Colors.red,
                ),
                child: const Text('outlined button')
            ),
            ElevatedButton(
                onPressed: (){},
                style: ElevatedButton.styleFrom(
                  backgroundColor: Colors.pink,
                  foregroundColor: Colors.black,
                ),
                child: const Text('Elevated button')
            ),
            IconButton(
              onPressed: (){},
              icon: Icon(Icons.home),
            ),
            GestureDetector(
              onTap: (){
                print('on tap');
              },
              onDoubleTap: (){
                print('on double tap');
              },
              onLongPress: (){
                print('on long press');
              },
              child: Container(
                decoration: BoxDecoration(
                  color: Colors.red,
                ),
                width: 100.0,
                height: 100.0,
              ),
            )
          ],
        )
      )
    );
  }
}

댓글