file 1
file 1
dart';
void main() {
runApp(MyApp());
}
void generateFullName() {
setState(() {
fullName =
"${firstNameController.text} ${lastNameController.text}".trim();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Full Name App'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(
controller: firstNameController,
decoration: InputDecoration(
labelText: 'First Name',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
TextField(
controller: lastNameController,
decoration: InputDecoration(
labelText: 'Last Name',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16),
ElevatedButton(
onPressed: generateFullName,
child: Text('Generate Full Name'),
),
SizedBox(height: 16),
Text(
fullName.isNotEmpty
? "Your full name is: $fullName"
: "Enter your first and last name",
style: TextStyle(fontSize: 18),
),
],
),
),
);
}
}