Flutter - 입력용 위젯
2023. 3. 4. 14:45ㆍFlutter
- TextField
-Textfield는 글자를 받는 입력용 위젯입니다.
-InputDecoration 클래스와 함께 사용하면 힌트 메세지나 외곽선등의 꾸밈 효과를 간단히 추가할수있다.
1. 로그인 화면 구현해보기.
import 'dart:ffi';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Cßolors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Flutter"),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(30.0),
child: Image.network("https://i.ibb.co/CwzHq4z/trans-logo-512.png"
, width:80,),
),
Padding(
padding: EdgeInsets.only(bottom: 30),
child: TextField(
decoration: InputDecoration(labelText: "이메일",
border: OutlineInputBorder()),
),
),
TextField(
decoration: InputDecoration(labelText: "비밀번호",
border: OutlineInputBorder()),
),
Container(
width: double.infinity,
margin: EdgeInsets.only(top: 20),
child: ElevatedButton(onPressed: () {}, child: Text("로그인"))),
Icon(Icons.facebook_outlined,
color: Colors.indigoAccent,),
],
),
),
),
);
}
}
'Flutter' 카테고리의 다른 글
Flutter - InkWell 과 GestureDetector (0) | 2023.03.07 |
---|---|
Flutter - WebView Widget (0) | 2023.03.06 |
Flutter - StatelessWidget, StatefulWidget이란? (0) | 2023.03.05 |
Flutter - AppBar, TabBar, TabBarView, BottomNavigationBar (0) | 2023.03.04 |
Flutter - Colum,Row 위젯 (0) | 2023.03.04 |