0% found this document useful (0 votes)
3 views2 pages

task2

This document contains a Flutter application that creates a simple user interface with a greeting, a button that shows a snackbar when clicked, a text field to capture user input, a checkbox, and a slider. The application uses state management to update the displayed text based on user interactions. It demonstrates basic Flutter widgets and their functionalities.
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)
3 views2 pages

task2

This document contains a Flutter application that creates a simple user interface with a greeting, a button that shows a snackbar when clicked, a text field to capture user input, a checkbox, and a slider. The application uses state management to update the displayed text based on user interactions. It demonstrates basic Flutter widgets and their functionalities.
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/ 2

S.

Kashikaa

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {


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

class HomePage extends StatefulWidget {


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

class _HomePageState extends State<HomePage> {


bool isChecked = false;
double sliderValue = 50;
String typedText = "";
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Flutter")),
body: Padding(
padding: EdgeInsets.all(16),
child: Column(
children: [
Text("Hello"),
ElevatedButton(
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Button clicked!")),
);
},
child: Text("Click me"),
),
TextField(
onChanged: (text) => setState(() => typedText = text),
decoration: InputDecoration(labelText: "Type here"),
),
Text("You typed: $typedText"),
Checkbox(
value: isChecked,
onChanged: (val) => setState(() => isChecked = val!),
),
Slider(
value: sliderValue,
min: 0,
max: 100,
onChanged: (val) => setState(() => sliderValue = val),
),
Text("Slider value: ${sliderValue.toInt()}"),
],
),
),
);
}
}

You might also like