0% found this document useful (0 votes)
3 views

file 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

file 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import 'package:flutter/material.

dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {


@override
Widget build(BuildContext context) {
return MaterialApp(
home: FullNameApp(),
);
}
}

class FullNameApp extends StatefulWidget {


@override
_FullNameAppState createState() => _FullNameAppState();
}

class _FullNameAppState extends State<FullNameApp> {


final TextEditingController firstNameController = TextEditingController();
final TextEditingController lastNameController = TextEditingController();
String fullName = "";

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),
),
],
),
),
);
}
}

You might also like