Assignment java familiar questions-01
Assignment java familiar questions-01
Exercise-03
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(
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
title: Text('TextButton Example'),
),
body: Center(
child: TextButton(
onPressed: () {
print('Button Clicked!');
},
child: Text('Click Me')),
),
));
}
}
Exercise-04
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(
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
title: Text('ElevatedButton Example'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
print('Button Clicked!');
},
child: Text('Click Me')),
),
));
}
}
Exercise-05
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(
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
title: Text('OutlinedButton Example'),
),
body: Center(
child: OutlinedButton(
onPressed: () {
AlertDialog(
key: Key('Kavana N'),
);
},
child: Text(
'Click Me',
style: TextStyle(color: Colors.blue),
)),
),
));
}
}
Asssignment
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context){
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget{
void showAlertDialog(BuildContext context){
showDialog(
context: context,
builder: (BuildContext context){
return AlertDialog(
title: Text("Alert Dialog"),
content: Text('Name: Kavana N'),
actions: <Widget>[
TextButton(
child:Text('Close'),
onPressed: (){
Navigator.of(context).pop();
},)
]
);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter Alert Dialog Example'),),
body: Center(
child: ElevatedButton(
onPressed: (){
showAlertDialog(context);
},
child: Text('Click Me!'),
),)
);
}
}