import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class Person {
final String name;
final int age;
Person(this.name, this.age);
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
final person = Person('Alice', 30);
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Simple Person Info')),
body: Center(
child: Text('Name: ${person.name}\nAge: ${person.age}',
style: const TextStyle(fontSize: 24),
textAlign: TextAlign.center,
),
),
),
);
}
}
We created a Person class with two properties: name and age. Then, inside the MyApp widget, we made an object of Person named person with sample data.
We used string interpolation to show the person's name and age inside a Text widget. The text is centered and has a bigger font size for easy reading.