Last active
September 28, 2023 12:37
-
-
Save easylive1989/88069a560a90317884f5371b0d9650c8 to your computer and use it in GitHub Desktop.
2023鐵人賽_D14_3
This file contains 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(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Builder(builder: (context) { | |
return Padding( | |
padding: const EdgeInsets.all(16), | |
child: Column( | |
children: [ | |
Row( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: [ | |
const Icon(Icons.abc_outlined, size: 30), | |
const SizedBox(width: 8), | |
Expanded( | |
child: TextFormField( | |
decoration: | |
const InputDecoration(label: Text("Name")))), | |
const SizedBox(width: 8), | |
const EditNameSubmitButton(), | |
], | |
), | |
Row( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: [ | |
const Icon(Icons.signpost, size: 30), | |
const SizedBox(width: 8), | |
Expanded( | |
child: TextFormField( | |
decoration: | |
const InputDecoration(label: Text("Address")))), | |
const SizedBox(width: 8), | |
const EditAddressSubmitButton(), | |
], | |
), | |
], | |
), | |
); | |
}), | |
), | |
); | |
} | |
} | |
class EditNameSubmitButton extends StatelessWidget { | |
const EditNameSubmitButton({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return ElevatedButton( | |
onPressed: () => _showSuccess(context), | |
child: const Text("Submit"), | |
); | |
} | |
void _showSuccess(BuildContext context) async { | |
ScaffoldMessenger.of(context) | |
.showSnackBar(const SnackBar(content: Text("更新成功"))); | |
} | |
} | |
class EditAddressSubmitButton extends StatelessWidget { | |
const EditAddressSubmitButton({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return ElevatedButton( | |
onPressed: () => _showSuccess(context), | |
child: const Text("Submit"), | |
); | |
} | |
void _showSuccess(BuildContext context) async { | |
ScaffoldMessenger.of(context) | |
.showSnackBar(const SnackBar(content: Text("更新成功"))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment