0% found this document useful (0 votes)
2 views4 pages

Ex - 2

The document describes a simple Flutter application that utilizes GUI components, including text, buttons, and a dropdown menu. The app allows users to change the font size and color of the displayed text. It features a main application class and a stateful widget to manage the UI state and interactions.

Uploaded by

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

Ex - 2

The document describes a simple Flutter application that utilizes GUI components, including text, buttons, and a dropdown menu. The app allows users to change the font size and color of the displayed text. It features a main application class and a stateful widget to manage the UI state and interactions.

Uploaded by

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

Experiment – 2

To Develop a Simple Android Application that uses GUI Components, Font and Colors.
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(
title: 'Simple Flutter App',
home: const MyHomePage(),
);
}
}

class MyHomePage extends StatefulWidget {


const MyHomePage({super.key});

@override
State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {


double _fontSize = 20.0;
Color _fontColor = Colors.black;
final _colors = [Colors.black, Colors.red, Colors.green, Colors.blue];

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Simple Flutter App')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Hellooo Flutter !!!', style: TextStyle(fontSize: _fontSize, color: _fontColor)),
ElevatedButton(
onPressed: () => setState(() => _fontSize = _fontSize == 20.0 ? 40.0 : 20.0),
child: const Text("Change Font Size"),
),
DropdownButton<Color>(
value: _fontColor,
onChanged: (color) => setState(() => _fontColor = color!),
items: _colors.map((color) => DropdownMenuItem(value: color, child:
Container(width: 100, height: 30, color: color))).toList(),
),
],
),
),
);
}
}
Output :

You might also like