Created with <3 with dartpad.dev.
Last active
October 10, 2023 13:21
-
-
Save hongsw/aa328d7f566282a17fb5822a381c68a5 to your computer and use it in GitHub Desktop.
사용자의 이름을 입력받아 화면에 출력하는 앱
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: NameApp(), | |
); | |
} | |
} | |
class NameApp extends StatelessWidget { | |
final TextEditingController _nameController = TextEditingController(); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Enter Your Name'), | |
), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
TextField( | |
decoration: InputDecoration(labelText: 'Enter your name'), | |
controller: _nameController, | |
), | |
SizedBox(height: 20), | |
ElevatedButton( | |
onPressed: () { | |
showDialog( | |
context: context, | |
builder: (BuildContext context) { | |
return AlertDialog( | |
content: Text('Hello, ${_nameController.text}'), | |
); | |
}, | |
); | |
}, | |
child: Text('Submit'), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment