0% found this document useful (0 votes)
22 views

Week 5@flutter

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

Week 5@flutter

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

DEPARTMENT OF INFORMATION TECHNOLOGY

EXPERIMENT-5
AIM:
a) Learn about stateful and stateless widgets

CODE:

import 'package:flutter/material.dart';
//This function triggers the build process
void main() => runApp(const MyApp());
// StatefulWidget
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
// ignore: library_private_types_in_public_api
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Color.fromARGB(255, 190, 229, 234),
appBar: AppBar(
leading: const Icon(Icons.menu),
backgroundColor: Colors.blue,
title: const Text(
"Department of IT",
textAlign: TextAlign.start,
),
), // AppBar
body: const Center(
child: Text(
"StateFul Widget",
style: TextStyle(color: Colors.black, fontSize: 30),
),
), // Container
), // Scaffold
); // MaterialApp
}
}
OUTPUT:

Leave space for to draw the output

Stateless Widget:

CODE:

import 'package:flutter/material.dart';
//This function triggers the build process
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: const Color.fromARGB(255, 211, 245, 252),
appBar: AppBar(
leading: const Icon(Icons.menu),
backgroundColor: Colors.blue,
title: const Text(
"Dept of IT",
textAlign: TextAlign.start,
),
), // AppBar
body: const Center(
child: Text(
"Stateless Widget",
style: TextStyle(color: Colors.black, fontSize: 30),
),
), // Container
), // Scaffold
); // MaterialApp
}
}
OUTPUT:

Leave space for to draw the output

b) Implement state management using set State and Provider.

You might also like