From 04943773177d4b8206244d5d778a73ba9af64cd9 Mon Sep 17 00:00:00 2001 From: brownglasses Date: Mon, 1 Jan 2024 19:50:02 +0900 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20checkbox=5Ftext=5Frow=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit checkbox 와 택스트 일렬로 배치되어있는 부분들이 많아 컴포넌트로 작성해보았습니다. resolves: #1 --- .../login/component/checkbox_text_row.dart | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 front/lib/domain/presentation/login/component/checkbox_text_row.dart diff --git a/front/lib/domain/presentation/login/component/checkbox_text_row.dart b/front/lib/domain/presentation/login/component/checkbox_text_row.dart new file mode 100644 index 0000000..ea7a0fa --- /dev/null +++ b/front/lib/domain/presentation/login/component/checkbox_text_row.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; + +class CheckboxTextRow extends StatelessWidget { + const CheckboxTextRow( + {super.key, this.onChanged, required this.text, required this.value}); + final Function(bool?)? onChanged; + final bool value; + final String text; + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.fromLTRB(0, 4, 0, 4), + child: Row( + children: [ + Checkbox(value: value, onChanged: onChanged), + const SizedBox( + width: 4, + ), + Text( + text, + style: const TextStyle(color: Colors.black, fontSize: 12), + ) + ], + ), + ); + } +} From 5f0a300747243132b97be61d280eacb05bec89c3 Mon Sep 17 00:00:00 2001 From: brownglasses Date: Mon, 1 Jan 2024 19:54:56 +0900 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20hinted=5Ftextfield=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 텍스트필드를 앱에 맞게 작성해보았습니다. label, hintText 가 공통적으로 나타나 속성값으로 넣었고 또한 validate 와 데이터 저장을 구현하기 위해 onSaved 와 Validator 속성을 추가하였습니다. 그리고 비밀번호 확인과 재확인을 구현할 때 입력된 비밀번호를 변화될 때마다 얻어와야하기 때문에 onChanged 속성을 추가하였습니다. resolves: #1 --- .../login/component/hinted_textfield.dart | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 front/lib/domain/presentation/login/component/hinted_textfield.dart diff --git a/front/lib/domain/presentation/login/component/hinted_textfield.dart b/front/lib/domain/presentation/login/component/hinted_textfield.dart new file mode 100644 index 0000000..54be53a --- /dev/null +++ b/front/lib/domain/presentation/login/component/hinted_textfield.dart @@ -0,0 +1,50 @@ +import 'package:flutter/material.dart'; + +class HintedTextField extends StatelessWidget { + final String? title; + final String hintText; + final FormFieldSetter onSaved; + final FormFieldValidator validator; + final void Function(String?)? onChanged; + const HintedTextField( + {super.key, + this.title, + required this.hintText, + required this.onSaved, + required this.validator, + this.onChanged}); + + @override + Widget build(BuildContext context) { + TextStyle textStyle = const TextStyle( + fontSize: 12, + color: Colors.black, + ); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + title != null + ? Text( + title!, + style: textStyle, + ) + : Container(), + Padding( + padding: const EdgeInsets.fromLTRB(0, 6, 0, 6), + child: TextFormField( + onChanged: onChanged, + onSaved: onSaved, + validator: validator, + decoration: InputDecoration( + border: InputBorder.none, + filled: true, + fillColor: Colors.grey[300], + hintText: hintText, + hintStyle: textStyle, + ), + ), + ) + ], + ); + } +} From fdd9c138eaea4011ddc609fceb51c14bdc752e41 Mon Sep 17 00:00:00 2001 From: brownglasses Date: Mon, 1 Jan 2024 19:59:58 +0900 Subject: [PATCH 3/7] =?UTF-8?q?feat:=20rounded=5Felvatedbutton=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 둥근 모서리 버튼이 앱에 자주 나타나 컴포넌트로 작성하였습니다. String text, VoidCallback onPressed 을 받습니다. resolves: #1 --- .../component/rounded_elvatedbutton.dart | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 front/lib/domain/presentation/login/component/rounded_elvatedbutton.dart diff --git a/front/lib/domain/presentation/login/component/rounded_elvatedbutton.dart b/front/lib/domain/presentation/login/component/rounded_elvatedbutton.dart new file mode 100644 index 0000000..0b10fb9 --- /dev/null +++ b/front/lib/domain/presentation/login/component/rounded_elvatedbutton.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; + +class RoundedElevatedButton extends StatelessWidget { + const RoundedElevatedButton( + {super.key, required this.text, required this.onPressed}); + final String text; + final VoidCallback onPressed; + @override + Widget build(BuildContext context) { + TextStyle textStyle = const TextStyle(color: Colors.black, fontSize: 12); + return SizedBox( + width: double.infinity, + child: ElevatedButton( + onPressed: onPressed, + style: ElevatedButton.styleFrom( + elevation: 0, + shadowColor: Colors.transparent, + backgroundColor: Colors.grey[300], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20.0), // 원하는 둥근 모서리 반지름 값 지정 + ), + padding: const EdgeInsets.symmetric( + horizontal: 16.0, vertical: 12.0), // 원하는 패딩 값 지정 + ), + child: Text( + text, + style: textStyle, + ), + ), + ); + } +} From 591eb2e540a4f0235afd4d09cf0136553727a18f Mon Sep 17 00:00:00 2001 From: brownglasses Date: Mon, 1 Jan 2024 20:10:29 +0900 Subject: [PATCH 4/7] =?UTF-8?q?feat:=20=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20UI=20=EB=B0=B0=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 로그인 페이지의 UI 를 배치하였습니다. UI 가 많이 수정될 예정이니 디테일하게 구성하지는 않았습니다. 체크박스 컴포넌트, 텍스트 필드 컴포넌트를 사용하였습니다. 후에 텍스트 필드에 onSaved 와 validate 를 required 속성으로 추가하여서 구색을 맞춰놓기 위해 id, password, rememberMe 등의 변수를 추가하고 함수를 채워넣었습니다 ! UI배치와는 관계없으므로 나중에 마음껏 수정하시거나 지워도 문제 없을 것 같습니다! resolves: #1 --- .../lib/domain/presentation/login/login.dart | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 front/lib/domain/presentation/login/login.dart diff --git a/front/lib/domain/presentation/login/login.dart b/front/lib/domain/presentation/login/login.dart new file mode 100644 index 0000000..2e4ccef --- /dev/null +++ b/front/lib/domain/presentation/login/login.dart @@ -0,0 +1,129 @@ +import 'package:flutter/material.dart'; +import 'package:front/domain/presentation/login/component/checkbox_text_row.dart'; +import 'package:front/domain/presentation/login/component/hinted_textfield.dart'; +import 'package:front/domain/presentation/login/component/rounded_elvatedbutton.dart'; + +class LoginScreen extends StatefulWidget { + const LoginScreen({super.key}); + + @override + State createState() => _LoginScreenState(); +} + +class _LoginScreenState extends State { + TextStyle textStyle = const TextStyle( + fontSize: 12, + color: Colors.black, + ); + String? id; + String? password; + bool? rememberMe = false; + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + body: Center( + child: Padding( + padding: const EdgeInsets.fromLTRB(20, 10, 20, 10), + child: Column(children: [ + const Text("로그인"), + const SizedBox( + height: 20, + ), + HintedTextField( + title: "아이디", + hintText: "아이디를 입력하세요", + onSaved: (String? val) { + id = val; + }, + validator: idValidator), + HintedTextField( + title: "비밀번호", + hintText: "비밀번호를 입력하세요", + onSaved: (String? val) { + password = val; + }, + validator: passwordValidator), + CheckboxTextRow( + text: '자동로그인', + value: rememberMe!, + onChanged: (value) { + setState(() { + rememberMe = value; + }); + }, + ), + RoundedElevatedButton( + text: "로그인", + onPressed: () {}, + ), + TextButton( + onPressed: () { + Navigator.pushNamed(context, '/signIn'); + }, + child: Text("회원가입", style: textStyle)), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton( + onPressed: () {}, + child: Text("아이디 찾기", style: textStyle), + ), + Text("|", style: textStyle), + TextButton( + onPressed: () {}, + child: Text("비밀번호 찾기", style: textStyle), + ) + ], + ), + const Padding( + padding: EdgeInsets.all(16), + child: Divider( + color: Colors.black, + ), + ), + Text("SNS 로그인", style: textStyle), + const SizedBox( + height: 16, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 50, // 원의 너비 + height: 50, // 원의 높이 + decoration: BoxDecoration( + shape: BoxShape.circle, // 동그라미 모양 + color: Colors.grey[300], // 회색 + ), + ), + const SizedBox( + width: 20, + ), + Container( + width: 50, // 원의 너비 + height: 50, // 원의 높이 + decoration: BoxDecoration( + shape: BoxShape.circle, // 동그라미 모양 + color: Colors.grey[300], // 회색 + ), + ), + ], + ) + ]), + ), + ), + ), + ); + } + + void onSaved() {} + + String? idValidator(String? val) { + return null; + } + + String? passwordValidator(String? val) { + return null; + } +} From 497dad408bfb8dbf7dc0a2018924865f18a11687 Mon Sep 17 00:00:00 2001 From: brownglasses Date: Mon, 1 Jan 2024 20:13:14 +0900 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=ED=8E=98=EC=9D=B4=EC=A7=80=20UI=20=EB=B0=B0?= =?UTF-8?q?=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 어느 방식으로 회원가입을 할지 선택하는 페이지입니다. 일단 이메일 회원가입 페이지만 연결해놓았습니다. resolves: #1 --- .../lib/domain/presentation/login/signin.dart | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 front/lib/domain/presentation/login/signin.dart diff --git a/front/lib/domain/presentation/login/signin.dart b/front/lib/domain/presentation/login/signin.dart new file mode 100644 index 0000000..cfcb30c --- /dev/null +++ b/front/lib/domain/presentation/login/signin.dart @@ -0,0 +1,75 @@ +import 'package:flutter/material.dart'; + +class SignInScreen extends StatelessWidget { + const SignInScreen({super.key}); + + @override + Widget build(BuildContext context) { + TextStyle textStyle = const TextStyle( + fontSize: 12, + color: Colors.black, + ); + return SafeArea( + child: Scaffold( + body: Padding( + padding: const EdgeInsets.all(20.0), + child: Center( + child: Column(children: [ + Text( + "회원가입", + style: textStyle, + ), + const SizedBox( + height: 10, + ), + Text( + "회원가입 방식을 선택해주세요", + style: textStyle, + ), + const SizedBox( + height: 10, + ), + CustomButton("이메일로 회원가입", () { + Navigator.pushNamed(context, '/emailSignIn'); // 로그인 화면으로 이동 + }), + CustomButton("카카오로 회원가입", () {}), + CustomButton("네이버로 회원가입", () {}), + ]), + ), + ), + ), + ); + } +} + +class CustomButton extends StatelessWidget { + final String buttonText; + final VoidCallback onPressed; + const CustomButton(this.buttonText, this.onPressed, {super.key}); + + @override + Widget build(BuildContext context) { + return ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.grey[300], + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), + ), + onPressed: onPressed, + child: Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.only(left: 10), + child: Text( + buttonText, + style: const TextStyle( + color: Colors.black, + fontSize: 16, + ), + ), + ), + ), + ); + } +} From 67599a865e44823a81acca67ea96427cd463a71b Mon Sep 17 00:00:00 2001 From: brownglasses Date: Mon, 1 Jan 2024 20:24:53 +0900 Subject: [PATCH 6/7] =?UTF-8?q?feat:=20=EC=9D=B4=EB=A9=94=EC=9D=BC?= =?UTF-8?q?=EB=A1=9C=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20UI=20?= =?UTF-8?q?=EB=B0=B0=EC=B9=98=20=EB=B0=8F=20validate=20=EA=B2=80=EC=82=AC,?= =?UTF-8?q?=20onSave=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - '비밀번호확인'을 구현할 때 '비밀번호' 입력 값을 받아와야하므로 '비밀번호' 텍스트 필드에서는 따로 onChanged를 사용하였습니다. - 페이지 UI 를 다 채우기에는 화면이 너무 짧아 스크롤 뷰로 만들었습니다. 후에 UI 의 크기를 조정하거나 아예 스크롤 뷰로 전환할지 검토해야 할 것 같습니다. - '모두 동의' 1. 모두 동의 체크 박스를 누르면 하위 동의 요소들이 모두 동의 되어야함 2. 모든 하위 동의 요소들이 동의 되면 모두 동의가 체크 표시 이 부분을 구현하기 위해 updateAllAgreed 함수를 추가하였습니다. - validate 를 모두 만족했을 떄 회원가입을 누르면 모든 폼의 값들이 프린트되게 하였습니다. --- .../presentation/login/email_singin.dart | 223 ++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 front/lib/domain/presentation/login/email_singin.dart diff --git a/front/lib/domain/presentation/login/email_singin.dart b/front/lib/domain/presentation/login/email_singin.dart new file mode 100644 index 0000000..c8c1b43 --- /dev/null +++ b/front/lib/domain/presentation/login/email_singin.dart @@ -0,0 +1,223 @@ +import 'package:flutter/material.dart'; +import 'package:front/domain/presentation/login/component/checkbox_text_row.dart'; +import 'package:front/domain/presentation/login/component/hinted_textfield.dart'; +import 'package:front/domain/presentation/login/component/rounded_elvatedbutton.dart'; + +class EmailSignInScreen extends StatefulWidget { + const EmailSignInScreen({super.key}); + + @override + State createState() => _EmailSignInScreenState(); +} + +class _EmailSignInScreenState extends State { + GlobalKey formKey = GlobalKey(); + String? id; + String? nickName; + String? confirmPassword; + String? password; + String? name; + String? phoneNumber; + bool personalInfoAgreed = false; + bool termsAgreed = false; + bool allAgreed = false; + @override + Widget build(BuildContext context) { + return Form( + key: formKey, + child: SafeArea( + child: Scaffold( + body: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Center( + child: Column( + children: [ + const Text("회원가입"), + Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + width: 100, // 원의 너비 + height: 100, // 원의 높이 + decoration: BoxDecoration( + shape: BoxShape.circle, // 동그라미 모양 + color: Colors.grey[300], // 회색 + ), + child: const Center(child: Text("이미지")), + ), + ), + HintedTextField( + hintText: "아이디", + onSaved: (String? val) { + id = val; + }, + validator: idValidator, + ), + HintedTextField( + hintText: "닉네임", + onSaved: (String? val) { + nickName = val; + }, + validator: nickNameValidator, + ), + HintedTextField( + hintText: "비밀번호", + onChanged: (String? val) { + confirmPassword = val; + }, + onSaved: (String? val) { + password = val; + }, + validator: passwordValidator, + ), + HintedTextField( + hintText: "비밀번호확인", + onSaved: (String? val) { + confirmPassword = val; + }, + validator: confirmPasswordValidator, + ), + HintedTextField( + hintText: "이름", + onSaved: (String? val) { + name = val; + }, + validator: nameValidator, + ), + HintedTextField( + hintText: "전화번호", + onSaved: (String? val) { + phoneNumber = val; + }, + validator: phoneNumberValidator, + ), + CheckboxTextRow( + text: '모두 동의', + value: allAgreed, + onChanged: (value) { + setState(() { + allAgreed = value!; + personalInfoAgreed = value; + termsAgreed = value; + }); + }, + ), + Expanded( + flex: 0, + child: Container( + decoration: BoxDecoration( + border: Border.all( + color: Colors.black, + width: 2.0, + ), + ), + child: Padding( + padding: const EdgeInsets.all(5), + child: Column(children: [ + CheckboxTextRow( + value: personalInfoAgreed, + onChanged: (value) { + setState(() { + personalInfoAgreed = value!; + updateAllAgreed(); + }); + }, + text: '개인 정보 약관 동의', + ), + CheckboxTextRow( + value: termsAgreed, + onChanged: (value) { + setState(() { + termsAgreed = value!; + updateAllAgreed(); + }); + }, + text: '이용 약관 동의', + ), + ]), + ), + ), + ), + const SizedBox( + height: 10, + ), + RoundedElevatedButton( + text: "회원가입", + onPressed: onSingInPressed, + ), + const SizedBox( + height: 10, + ), + ], + ), + ), + ), + ), + ), + ), + ); + } + + void updateAllAgreed() { + setState(() { + allAgreed = personalInfoAgreed && termsAgreed; + }); + } + + String? idValidator(String? val) { + if (val == null || val.isEmpty) { + return 'ID를 입력해주세요'; + } + return null; + } + + String? nickNameValidator(String? val) { + if (val == null || val.isEmpty) { + return '닉네임을 입력해주세요'; + } + return null; + } + + String? passwordValidator(String? val) { + if (val == null || val.isEmpty) { + return '비밀번호를 입력해주세요'; + } + return null; + } + + String? confirmPasswordValidator(String? val) { + if (val == null || val.isEmpty) { + return '비밀번호를 입력해주세요'; + } + if (val != confirmPassword) { + return '비밀번호가 일치하지 않습니다'; + } + return null; + } + + String? nameValidator(String? val) { + if (val == null || val.isEmpty) { + return '이름을 입력해주세요'; + } + return null; + } + + String? phoneNumberValidator(String? val) { + if (val == null || val.isEmpty) { + return '전화번호를 입력해주세요'; + } + return null; + } + + onSingInPressed() { + if (formKey.currentState!.validate() && allAgreed == true) { + formKey.currentState!.save(); + print(id); + print(nickName); + print(confirmPassword); + print(password); + print(name); + print(phoneNumber); + } + } +} From 3c94f3a0caf5abe1e321c16ff168a875e2749475 Mon Sep 17 00:00:00 2001 From: brownglasses Date: Mon, 1 Jan 2024 20:29:26 +0900 Subject: [PATCH 7/7] =?UTF-8?q?feat:=20routes=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UI 페이지를 연결하기 위해 route 를 업데이트 하였습니다. resolves: #1 --- front/lib/config/routes.dart | 18 ++++ front/lib/domain/presentation/home/home.dart | 18 ++++ front/lib/main.dart | 105 +------------------ 3 files changed, 40 insertions(+), 101 deletions(-) create mode 100644 front/lib/config/routes.dart create mode 100644 front/lib/domain/presentation/home/home.dart diff --git a/front/lib/config/routes.dart b/front/lib/config/routes.dart new file mode 100644 index 0000000..503da47 --- /dev/null +++ b/front/lib/config/routes.dart @@ -0,0 +1,18 @@ +import 'package:front/domain/presentation/home/home.dart'; +import 'package:front/domain/presentation/login/email_singin.dart'; +import 'package:front/domain/presentation/login/login.dart'; +import 'package:front/domain/presentation/login/signIn.dart'; + +class RouteName { + static const home = '/'; + static const login = '/login'; + static const signIn = '/signIn'; + static const emailSignIn = '/emailSignIn'; +} + +var nameRoutes = { + RouteName.home: (context) => const HomeScreen(), + RouteName.login: (context) => const LoginScreen(), + RouteName.signIn: (context) => const SignInScreen(), + RouteName.emailSignIn: (context) => const EmailSignInScreen(), +}; diff --git a/front/lib/domain/presentation/home/home.dart b/front/lib/domain/presentation/home/home.dart new file mode 100644 index 0000000..f96e8c6 --- /dev/null +++ b/front/lib/domain/presentation/home/home.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; + +class HomeScreen extends StatelessWidget { + const HomeScreen({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: const Text('홈')), + body: Center( + child: ElevatedButton( + onPressed: () { + Navigator.pushNamed(context, '/login'); // 로그인 화면으로 이동 + }, + child: const Text('로그인'), + ))); + } +} diff --git a/front/lib/main.dart b/front/lib/main.dart index e016029..d3070fd 100644 --- a/front/lib/main.dart +++ b/front/lib/main.dart @@ -1,115 +1,18 @@ import 'package:flutter/material.dart'; +import 'package:front/config/routes.dart'; -void main() { +void main() async { 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 Colors.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: const 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 createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - - @override - Widget build(BuildContext context) { - // 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. - return 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: Text(widget.title), - ), - body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Invoke "debug painting" (press "p" in the console, choose the - // "Toggle Debug Paint" action from the Flutter Inspector in Android - // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) - // to see the wireframe for each widget. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headline4, - ), - ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. + debugShowCheckedModeBanner: false, + routes: nameRoutes, ); } }