import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: ArrowFunctionDemo(),
);
}
}
class ArrowFunctionDemo extends StatefulWidget {
const ArrowFunctionDemo({super.key});
@override
State<ArrowFunctionDemo> createState() => _ArrowFunctionDemoState();
}
class _ArrowFunctionDemoState extends State<ArrowFunctionDemo> {
String greeting = 'Hello!';
// TODO: Add a function using arrow syntax to update greeting
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Arrow Function Demo')),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('Greeting: $greeting', style: const TextStyle(fontSize: 24)),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
// TODO: Call the arrow function here
},
child: const Text('Press Me'),
),
],
),
),
);
}
}