Flutter UI Design Lab Syllabus 2025-2026
Flutter UI Design Lab Syllabus 2025-2026
Mr.E MOTHILAL
Assistant Professor,
CSE(AIML) Dept.,
VISION
MISSION
Department Vision
To attain global standards in Teaching, Training, and Research of the IT industry that maintaining balance
between the evolving needs of the sector and the socioeconomic and ethical needs of society.
Department Mission
To impart quality education and research to undergraduate and postgraduate students in Computer Science &
Engineering (AIML)
To train students in advanced technologies using state-of-the-art facilities.
To develop knowledge, skills and aptitude to function in the IT domain based on ethical values and
social relevance.
Programm Educational Objectives (PEOs)
PEO 1:
To outshine in professional career with sound problem solving ability for providing IT solutions by
proper plan, analysis, design, implementation and validation.
PEO 2:
To pursue training, advance study and research using scientific, technical and communication base
to cope with the evolution in the technology.
PEO 3: TO utilize the acquired technical skills and knowledge for the benefit of society To utilize the
acquired technical skills and knowledge for the benefit of society
Department of
COMPUTER SCIENCE AND ENGINEERING
(Artificial Intelligence & Machine Learning)
PO 2: Problem Analysis: Identify, formulate, review research literature and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and
engineering sciences.
PO 3: Design / Development of Solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the public
health and safety, and the cultural, societal, and environmental considerations.
PO 4: Conduct Investigations of Complex Problems: User search-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information to provide
valid conclusions.
PO 5: Modern Tool Usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an
understanding of the limitations.
PO 6: The Engineer and Society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional
engineering practice.
PO 7: Environment and Sustainability: Understand the impact of the professional engineering solutions in
societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable development.
PO 8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering practice.
PO 9: Individual and Team Work: Function effectively as an individual and as a member or leader in diverse
teams, and in multi-disciplinary settings.
PO 10: Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and design
documentation, make effective presentations, and give and receive clear instructions.
PO 11: Project Management and Finance: Demonstrate knowledge and understanding of the engineering
and management principles and apply these to one’s own work, as a member and leader in a team, to manage
projects and n multi-disciplinary environments.
PO 12: Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
Department of
COMPUTER SCIENCE AND ENGINEERING
(Artificial Intelligence & Machine Learning)
PSO 1:
Identify the mathematical abstractions and algorithm design techniques together with emerging
Software Tools to solve complexities indulged in efficient programming.
PSO 2:
Apply the core concepts of current technologies in the hardware, software mains in
accomplishing IT enabled services to meet out societal needs.
PSO 3:
Practice modern computing techniques by continual learning process with ethical concerns in
establishing innovative career path
2025-2026
Malla Reddy Institute of Technology [Link].
Onwards
& Science (Autonomous) VI Semester
(R-22)
Code: L T P
Credits: 1 UI Design-Flutter Lab - - 2
Course Objectives:
Learns to Implement Flutter Widgets and Layouts
Understands Responsive UI Design and with Navigation in Flutter
Knowledge on Widgets and customize widgets for specific UI elements, Themes
Understand to include animation apart from fetching data
TEXT BOOK:
1. Marco L. Napoli, Beginning Flutter: A Hands-on Guide to App Development.
Course Outcomes: At the end of the course, students will be able to:
Implements Flutter Widgets and Layouts
Responsive UI Design and with Navigation in Flutter
Create custom widgets for specific UI elements and also Apply styling using themes and customstyles.
Design a form with various input fields, along with validation and error handling
Fetches data and write code for unit Test for UI components and also animation
Bloom’s Taxonomy Action Verbs:
The lab manual of UI design with Flutter typically provides a structured guide for students to learn and
practice designing user interfaces using Flutter, a popular framework for building cross-platform mobile
applications. The manual usually covers various topics, including:
Introduction to Flutter: An overview of Flutter, its features, and benefits for mobile app development.
Setting Up Development Environment: Instructions for setting up Flutter and its dependencies ondifferent
platforms like Windows, macOS, and Linux.
Flutter Basics: Fundamentals of Flutter, including widgets, layouts, navigation, state management, and
basic UI design principles.
Building UI Components: Step-by-step tutorials for creating common UI components such as buttons,text
fields, lists, and forms using Flutter widgets.
Styling and Theming: Guidelines for applying styles, themes, colors, fonts, and other visual elementsto
enhance the appearance of the app.
Responsive Design: Techniques for designing responsive user interfaces that adapt to different screensizes
and orientations.
Navigation and Routing: How to implement navigation between screens and manage application
routes using Flutter's navigation system.
API Integration: Integration of RESTful APIs to fetch and display data in the app, including handling
asynchronous operations and error handling.
Testing and Debugging: Strategies for testing UI components, debugging common issues, and using
Flutter's debugging tools effectively.
The lab manual typically includes hands-on exercises, code examples, and assignments to reinforce learning
and practical skills. It may also provide additional resources such as recommended readings, online tutorials,
and reference materials for further exploration of UI design concepts and Flutter development. Overall, the
lab manual serves as a comprehensive guide for students to gain proficiencyin designing user interfaces
with Flutter.
Implementing Responsive Design: Learn techniques for designing responsive user interfaces that adapt to
different screen sizes and orientations, ensuring a consistent user experience across devices.
Styling and Theming: Understand how to apply styles, themes, colors, and typography to enhance the
visual appearance of the app and maintain brand consistency.
Navigation and Routing: Learn how to implement navigation between screens and manage application
routes using Flutter's navigation system.
State Management: Explore various state management techniques in Flutter, such as setState, Provider,
Bloc, and others, to manage and update the state of UI components.
API Integration: Integrate RESTful APIs to fetch and display dynamic data in the app, including handling
asynchronous operations and error handling.
Testing and Debugging: Practice testing UI components, debugging common issues, and using Flutter’s
debugging tools effectively to identify and fix errors.
Deployment and Publishing: Understand the process of building and deploying Flutter apps to different
platforms like Android and iOS, and publishing them to app stores.
Collaboration and Communication: Foster collaboration and communication skills by working in teams
on UI design projects, sharing ideas, and providing feedback to peers.
Explore Algorithmic Complexity and Efficiency: Analyze the time and space complexity of different AI
algorithms, and develop an understanding of algorithmic efficiency and optimization strategies.
Enhance Critical Thinking and Problem-Solving Abilities: Engage in critical thinking and analytical
reasoning while designing and implementing solutions to complex AI problems, fostering problem- solving
skills essential for AI development.
Experiment with Different Approaches: Experiment with various AI approaches, including search
algorithms, heuristic methods, machine learning techniques, and optimization algorithms, to understand
their strengths, weaknesses, and applications.
Foster Collaboration and Communication: Collaborate with peers on problem-solving tasks, discuss
algorithm design choices, and communicate findings effectively, promoting teamwork and effective
communication skills.
Build a Strong Foundation in AI Theory and Practice: Develop a strong foundation in both theoretical
concepts and practical applications of artificial intelligence, preparing students for further study or
professional work in the field.
Promote Lifelong Learning in AI: Cultivate a passion for lifelong learning and exploration in the field of
artificial intelligence, inspiring students to continue their education and pursue advancements in AI
technology throughout their careers.
Before participating in laboratory sessions for UI design with Flutter, students should ideally have thefollowing
prerequisites:
Basic Programming Skills: Students should have a basic understanding of programming concepts,
including variables, data types, control structures, and functions. Knowledge of object-oriented
programming (OOP) concepts like classes, objects, and inheritance would be beneficial.
Familiarity with Dart Programming Language: Flutter uses the Dart programming language, so
students should have a basic understanding of Dart syntax, features, and concepts. Topics such as
variables, functions, classes, and asynchronous programming with Future and Stream would be
important.
Understanding of UI Design Principles: Familiarity with fundamental principles of user interface (UI)
design, such as consistency, simplicity, visual hierarchy, and usability, would be helpful. Students should
have a basic understanding of how to design user-friendly and visually appealing interfaces.
Experience with Mobile Development: While not mandatory, prior experience with mobile app
development using frameworks like Flutter, React Native, or native development (Android/iOS) wouldbe
advantageous. This includes understanding app lifecycle, navigation patterns, and platform-specific
Considerations.
Development Environment Setup: Students should be able to set up and configure their development
environment for Flutter development. This includes installing Flutter SDK, Dart SDK, and necessary
development tools like IDE (e.g., Android Studio, IntelliJ IDEA, Visual Studio Code) and Flutter
plugins/extensions.
Problem-Solving Skills: Students should have strong problem-solving skills and the ability to
troubleshoot issues independently. This includes debugging code, researching solutions online, and
seeking help when needed.
Critical Thinking and Creativity: UI design involves creative thinking and problem-solving to create
intuitive and aesthetically pleasing user interfaces. Students should be able to think critically, analyze
design requirements, and propose innovative solutions.
Time Management: Managing time effectively is crucial for completing lab assignments, meeting
deadlines, and optimizing productivity during lab sessions. Students should be able to prioritize tasks,
allocate time wisely, and stay organized.
Effective Communication: Communication skills, both written and verbal, are essential for collaborating
with peers, discussing design ideas, and presenting project outcomes. Students should beable to articulate
their thoughts, provide constructive feedback, and work effectively in teams.
While these prerequisites provide a foundation for successful participation in UI design laboratory
sessions, students with varying levels of experience and backgrounds can benefit from engaging withthe
course material and actively participating in hands-on activities and projects.
To effectively participate in UI design laboratory sessions with Flutter, students will need the followingsoftware
and hardware requirements:
Software Requirements:
Flutter SDK: Install the Flutter SDK, which includes the Flutter framework and the Dart programming
language. Flutter provides installation instructions for various platforms such as Windows, macOS, and
Linux.
Integrated Development Environment (IDE):
Recommended: Android Studio with Flutter plugin or Visual Studio Code with Flutter extension. Both
IDEs provide excellent support for Flutter development and include features
Hardware Requirements:
Computer: Students will need a computer (desktop or laptop) running Windows, macOS, or Linux to
develop Flutter applications. The computer should meet the minimum system requirements for running
the chosen IDE and emulators/simulators.
Mobile Devices (Optional): While emulators/simulators are sufficient for testing and development,
students may also want to test their apps on physical Android and iOS devices. Ensure compatibility
with Flutter by enabling developer mode and USB debugging on the devices.
Internet Connection: A stable internet connection is necessary for downloading Flutter SDK, IDEs,
packages from Pub, and accessing online resources and documentation.
Storage: Sufficient storage space on the computer to install Flutter SDK, IDEs, and other development
tools, as well as to store project files and dependencies.
By meeting these software and hardware requirements, students can effectively engage in UI design
laboratory sessions with Flutter, develop mobile applications, and gain practical experience in buildinguser
interfaces for various platforms.
Minimum System requirements:
The minimum system requirements for developing Flutter applications are relatively modest, but theymay
vary slightly depending on the operating system and the specific development tools being used. Here are
the general minimum system requirements:
For Windows:
Operating System: Windows 7 SP1 or later (64-bit)
Processor: Intel Core i3 or AMD equivalent (64-bit)
Memory (RAM): 4GB RAM or more
Storage: 2GB of free disk space
Graphics Card: Integrated graphics or dedicated GPU with DirectX 9 support
Internet Connection: Required for downloading development tools, SDKs, and dependencies
For macOS:
Operating System: macOS 10.12 (Sierra) or later
Processor: Intel Core i3 or higher
Memory (RAM): 4GB RAM or more
Storage: 2GB of free disk space
Graphics Card: Integrated graphics or dedicated GPU
Internet Connection: Required for downloading development tools, SDKs, and dependencies
For Linux:
Operating System: Ubuntu 16.04 LTS (Xenial Xerus) or later, or another Linux distribution with
similar support
Processor: Intel Core i3 or AMD equivalent
Memory (RAM): 4GB RAM or more
Storage: 2GB of free disk space
Graphics Card: Integrated graphics or dedicated GPU
Internet Connection: Required for downloading development tools, SDKs, and dependencies
These are general guidelines, and the actual system requirements may vary depending on factors such as
the size and complexity of the Flutter projects, the number of plugins and dependencies used, and the
performance of the development tools (IDEs) being used. Additionally, running emulators or simulatorsfor
testing on mobile devices may require more system resources.
Lab Session 1:
To install Flutter and the Dart SDK, you can follow these steps:
a) Download Flutter: Visit the Flutter website's Get Started page and download the Flutter SDK for your
operating system (Windows, macOS, or Linux).
b) Extract the Flutter SDK: After downloading, extract the contents of the compressed file to a location
on your computer where you want to store the Flutter SDK. For example, you can extract it to C:\flutter
on Windows, /Users/<your-username>/flutter on macOS, or ~/flutter on Linux.
c) Add Flutter to your PATH: Update your system's PATH variable to include the Flutter bin directory.
This step allows you to execute Flutter commands from any directory in your terminal or command
prompt. The precise steps for updating the PATH vary depending on your operating system.
Windows:
From the Start search bar, type 'env' and select 'Edit the system environment variables'.Click
on 'Environment Variables'.
Under 'System Variables', find the 'Path' variable, select it, and click 'Edit'.
Click 'New' and add the path to the bin directory inside the Flutter directory (e.g., C:\flutter\bin).
Click 'OK' on all open dialogs to save your changes.
e) Install Flutter dependencies: Depending on your development environment, you may need to install
additional dependencies, such as Android Studio to fully set up your Flutter development environment.
f) Download Dart SDK (if not bundled with Flutter): Flutter comes with the Dart SDK bundled, so if
you've installed Flutter, you should have the Dart SDK as well. However, if you need to install Dart
separately, you can download it from the Dart "SDK archive".
// Conditional statementsif
(myBool) { print('myBool
is true');
} else {
print('myBool is false');
}
// Loops
for (int i = 0; i < 5; i++) {
print('Iteration $i');
}
// Lists
List<int> numbers = [1, 2, 3, 4, 5];
print('First element of the list: ${numbers[0]}');
print('Length of the list: ${[Link]}');
// Maps
Map<String, int> ages = {
'Kiran': 30,
'Raj': 25,
'Alekya': 35,
};
print('Kiran\'s age: ${ages['Kiran']}');
}
Output:
Lab Session 2:
Flutter provides a rich set of widgets to build user interfaces for mobile,web,and desktop
[Link] widgets help in creating visually appealing and interactive UIs. Here are some of the
commonly used Flutter widgets categorized by their functionalities:
Layout Widgets:
Container: A versatile widget that can contain other widgets and provides options for alignment,
padding,margin, and decoration.
Row and Column: Widgets that arrange their children in a horizontal or vertical line respectively.
Stack: Allows widgets to be stacked on top of each other, enabling complex layouts.
ListView and GridView: Widgets for displaying a scrollable list or grid of children, with support for
various layouts and scrolling directions.
Scaffold: Implements the basic material design layout structure, providing app bars, drawers, and floatingaction
buttons.
RichText: Allows for more complex text styling and formatting, including different styles within the same text
span.
TextStyle: A class for defining text styles that can be applied to Text widgets.
Input Widgets:
TextField: A widget for accepting user input as text, with options for customization and validation.
Checkbox and Radio: Widgets for selecting from a list of options, either through checkboxes or radio
buttons.
Button Widgets:
ElevatedButton and TextButton: Widgets for displaying buttons with different styles and customizationoptions.
IconButton: A button widget that displays an icon and responds to user taps.
GestureDetector: A versatile widget that detects gestures such as taps, swipes, and drags, allowing for
custom interactions.
Animation Widgets:
AnimatedContainer: An animated version of the Container widget, with support for transitioning
properties over a specified duration.
BottomNavigationBar: Provides a navigation bar at the bottom of the screen for switching betwee
different screens or tabs.
Card: Displays content organized in a card-like structure with optional elevation and padding.
These are just a few examples of the many widgets available in Flutter. Each widget comes with its set of
properties and customization options, allowing developers to create highly customizable and responsive user
interfaces.
b) User implement different layout structures using Row, Column, and Stack widgets
1. Row Layout:
void main() {
runApp(MyApp());
}
width: 100,
height: 100,
),
Container(
color: [Link],
width: 100,
height: 100,
),
Container(
color: [Link],width: 100,
height: 100,
),
],
),
),
);
}
}
Output:
2. Column Layout:
import 'package:flutter/[Link]';
void main() {
runApp(MyApp());
}
Output:
3. Stack Layout:
import 'package:flutter/[Link]';
void main() {
runApp(MyApp());
}
),
body: Stack(
alignment: [Link],children:
<Widget>[
Container(
color: [Link],width: 200,
height: 200,
),
Container(
color: [Link],width: 150,
height: 150,
),
Container(
color: [Link],width: 100,
height: 100,
),
],
),
),
);
}
}
Output:
Lab Session 3:
import 'package:flutter/[Link]';
void main() {
runApp(MyApp());
}
Widget _buildNarrowLayout() {
return Center(
child: Column(
mainAxisAlignment: [Link],
children: <Widget>[
FlutterLogo(size: 100),
SizedBox(height: 20),Text(
'Narrow Layout',
style: TextStyle(fontSize: 24),
),
SizedBox(height: 20),
ElevatedButton( onPressed: ()
{}, child: Text('Button'),
),
],
),
);
}
Widget _buildWideLayout() {
return Center(
child: Row(
mainAxisAlignment: [Link],
children: <Widget>[
FlutterLogo(size: 100),
SizedBox(width: 20),Column(
mainAxisAlignment: [Link],children:
<Widget>[
Text(
'Wide Layout',
style: TextStyle(fontSize: 24),
),
SizedBox(height: 20),
ElevatedButton( onPressed: ()
{}, child: Text('Button'),
),
],
),
],
),
);
}
}
Output:
Mobile View:
Desktop View:
b) Implement media queries and breakpoints for responsiveness
import 'package:flutter/[Link]';
void main() {
runApp(MyApp());
}
Widget _buildMobileLayout() {
return Center(
child: Column(
mainAxisAlignment: [Link],
children: <Widget>[
FlutterLogo(size: 100),
SizedBox(height: 20),Text(
'Mobile Layout',
style: TextStyle(fontSize: 24),
),
SizedBox(height: 20),
ElevatedButton( onPressed: ()
{}, child: Text('Button'),
),
],
),
);
}
Widget _buildTabletLayout() {
return Center(
child: Row(
mainAxisAlignment: [Link],
children: <Widget>[
FlutterLogo(size: 100),
SizedBox(width: 20),Column(
mainAxisAlignment: [Link],children:
<Widget>[
Text(
'Tablet Layout',
style: TextStyle(fontSize: 24),
),
SizedBox(height: 20),
ElevatedButton( onPressed: ()
{}, child: Text('Button'),
),
],
),
],
),
);
}
Widget _buildDesktopLayout() {
return Center(
child: Row(
mainAxisAlignment: [Link],
children: <Widget>[
FlutterLogo(size: 100),
SizedBox(width: 20),Column(
mainAxisAlignment: [Link],children:
<Widget>[
Text(
'Desktop Layout',
style: TextStyle(fontSize: 24),
),
SizedBox(height: 20),
ElevatedButton( onPressed: ()
{},
child: Text('Button'),
),
],
),
],
),
);
}
}
Output:
Lab Session 4:
import 'package:flutter/[Link]';
void main() {
runApp(MyApp());
}
Output:
import 'package:flutter/[Link]';
void main() {
runApp(MyApp());
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Named Routes Demo',
initialRoute: '/',
routes: {
'/': (context) => HomeScreen(), '/second':
(context) => SecondScreen(),'/third': (context)
=> ThirdScreen(),
},
);
}
}
[Link](context, '/second');
},
child: Text('Go to Second Screen'),
),
),
);
}
}
class SecondScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Second Screen'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
[Link](context, '/third');
},
child: Text('Go to Third Screen'),
),
),
);
}
}
appBar: AppBar(
title: Text('Third Screen'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
[Link](context, [Link]('/'));
},
child: Text('Go Back to Home'),
),
),
);
}
}
Output:
Lab Session 5:
Stateless Widgets:
Definition: Stateless widgets are widgets that do not have any mutable state. Once created, their properties
(configuration) cannot change.
Characteristics:
They are immutable and lightweight.
They only depend on their configuration and the build context provided during [Link]
appearance (UI) is purely a function of their configuration.
They are ideal for UI elements that do not change over time, such as static text labels, icons, or simple
buttons.
import 'package:flutter/[Link]';
void main() {
runApp(MyApp());
}
}
}
@override
Widget build(BuildContext context) {
return Card(
margin: [Link](horizontal: 16, vertical: 8),child:
ListTile(
title: Text(title), subtitle:
Text(subtitle),leading:
CircleAvatar(
child: Text('${[Link](0, 1)}'),
),
onTap: () {
// Handle card tap
},
),
);
}
Output:
Stateful Widgets:
Definition: Stateful widgets are widgets that maintain state, allowing them to change and update over time in
response to user actions, network events, or other factors.
Characteristics:
They have an associated mutable state that can change during the widget's lifetime.
The state is stored in a separate class that extends State and is associated with the stateful [Link]
to the state trigger a rebuild of the widget's UI, allowing dynamic updates.
They are ideal for UI elements that need to change or react to user interactions, such as input forms,
animations, or scrollable lists.
import 'package:flutter/[Link]';
void main() {
runApp(MyApp());
}
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Counter App'),
),
body: Center( child:
Column(
mainAxisAlignment: [Link],children:
<Widget>[
Text( 'Counter:',
style: TextStyle(fontSize: 24),
),
Text( '$_counter',
style: TextStyle(fontSize: 36, fontWeight: [Link]),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment', child:
Icon([Link]),
),
);
}
}
Output:
Stateful widgets are composed of two classes: the stateful widget itself (which extends StatefulWidget) and its
corresponding state class (which extends State). The state class is responsible for maintaining the widget's
mutable state and updating the UI accordingly via the setState() method.
stateless widgets are static and immutable, while stateful widgets are dynamic and can change over time by
managing their internal state. Understanding the difference between these two types of widgets is essential for
designing and building efficient and responsive Flutter UIs.
void main() {
runApp(MyApp());
}
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Counter Example (setState)'),
),
body: Center( child:
Column(
mainAxisAlignment: [Link],children:
<Widget>[
Text(
'Counter Value:',
),
Text( '$_counter',
style: [Link](context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment', child:
Icon([Link]),
),
);
}
}
Output:
State Management using provider package:
// [Link]
import 'package:flutter/[Link]';
import 'package:provider/[Link]';
import 'provider/movie_provider.dart';
main() {
runApp(ChangeNotifierProvider<MovieProvider>(child:
const MyApp(),
create: (_) => MovieProvider(), // Create a new ChangeNotifier object
));
}
@override
Widget build(BuildContext context) {
return MaterialApp(
// Remove the debug banner
debugShowCheckedModeBanner: false,title:
'State Management using provider',theme:
ThemeData(
primarySwatch: [Link],
),
Create a provider folder and create movie_provider.dart inside the provider folder
// provider/movie_provider.dart import
'package:flutter/[Link]';import
'dart:math';
import '../models/[Link]';
// A list of movies
final List<Movie> initialData = [Link](
50,
(index) => Movie(
title: "Moview $index",
runtime: "${Random().nextInt(100) + 60} minutes"));
// screens/home_screen.dart
import 'package:flutter/[Link]';
import 'package:provider/[Link]';
import '../provider/movie_provider.dart';
import 'my_list_screen.dart';
@override
State<HomeScreen> createState() => _HomeScreenState();
}
return Scaffold(
appBar: AppBar(
title: const Text('State Management using provider'),
),
body: Padding(
padding: const [Link](15),child:
Column(
crossAxisAlignment: [Link],children:
[
[Link]( onPressed: () {
[Link](context).push(
MaterialPageRoute(
builder: (context) => const MyListScreen(),
),
);
},
icon: const Icon([Link]),label:
Text(
"Go to my list (${[Link]})",style: const
TextStyle(fontSize: 24),
),
style: [Link](primary:
[Link],
padding: const [Link](vertical: 20)),
),
const SizedBox(height:
15,
),
Expanded(
child: [Link]( itemCount:
[Link],itemBuilder: (_, index) {
size: 30,
),
onPressed: () {
if () {context
.read<MovieProvider>()
.addToList(currentMovie);
} else { context
.read<MovieProvider>()
.removeFromList(currentMovie);
}
},
),
),
);
}),
),
],
),
),
);
}
}
create my_list_screen.dart inside the screens folder
// screens/my_list_screen.dart
import 'package:flutter/[Link]';
import 'package:provider/[Link]';
@override
State<MyListScreen> createState() => _MyListScreenState();
}
return Card(
key: ValueKey([Link]),elevation:
4,
child: ListTile(
title: Text([Link]),
subtitle: Text([Link] ?? ''),trailing:
TextButton(
child: const Text('Remove',
style: TextStyle(color: [Link]),
),
onPressed: () { [Link]<MovieProvider>().removeFromList(currentMovie);
},
),
),
);
}),
);
}
}
l O M oA R c P S D| 37701387
Output:
we use the provider package to manage state. We define a Counter class that extends
ChangeNotifier, and the counter value is stored inside it. Whenever the counter is incremented,
we call notifyListeners() to informthe listeners about the change.
l O M oA R c P S D| 37701387
Lab Session 6:
AppBar(
title: Text('Custom Widget Example'),
),
body: Column(
mainAxisAlignment:
[Link],children:
<Widget>[
Padding(
padding: const
[Link](8.0),child:
CustomTextField(
hintText: 'Enter your name',
onChanged: (value) {
print('Name changed:
$value');
},
),
),
SizedBox(height
: 20),Padding(
padding: const
[Link](8.0),child:
CustomTextField(
hintText: 'Enter Email',
onChanged: (value) {
print('Name changed:
$value');
},
),
l O M oA R c P S D| 37701387
),
SizedBox(height
: 20),Padding(
padding: const
[Link](8.0),child:
CustomTextField(
hintText: 'Enter Roll
Number', onChanged:
(value) { print('Name
changed: $value');
},
),
),
SizedBox(height
: 20),
CustomButton(
text: 'Press Me',
onPressed: () {
print('Button pressed!');
},
),
],
),
),
);
}
}
const
CustomBu
tton({
Key? key,
@required
[Link],
@required [Link],
}) : super(key: key);
@override
Widget
build(BuildContext
context) {
l O M oA R c P S D| 37701387
return ElevatedButton(onPressed:
onPressed,
child:
Text(text!),
);
}
}
const
CustomTextF
ield({Key?
key,
required
[Link],
required
[Link]
d,
}) : super(key: key);
@override
Widget
build(BuildContext
context) {return
TextField(
onChanged:
onChanged,
decoration:
InputDecoration(
hintText: hintText,
border: OutlineInputBorder(),
),
);
}
}
Output:
l O M oA R c P S D| 37701387
In Flutter, you can apply styling to your widgets using themes and custom styles to maintain
consistency and make your UI morevisually appealing.
Import 'package:flutter/[Link]';
void main()
{
runApp(MyApp());
}
class MyApp extends
@override
StatelessWidget {
{
Widget build(BuildContext context)
return
MaterialA
pp( theme:
l O M oA R c P S D| 37701387
ThemeDat
a(
// Define the overall theme of
the appprimaryColor:
[Link], accentColor:
[Link], fontFamily:
'Roboto',
textTheme: TextTheme(
headline1: TextStyle(fontSize: 24, fontWeight:
[Link]),bodyText1: TextStyle(fontSize: 16),
),
elevatedButtonTheme:
ElevatedButtonThemeData(style:
[Link](
primary: [Link],
textStyle: TextStyle(fontSize: 18),
padding: [Link](horizontal: 20,
vertical: 15),shape: RoundedRectangleBorder(
borderRadius: [Link](10),
),
),
),
),
home: HomePage(),
);
}
}
return
Scaffol
d(
appBar:
AppBar
(
title: Text('Styling Example'),
),
body:
Center
( child:
Colum
n(
l O M oA R c P S D| 37701387
mainAxisAlignment:
[Link],children:
<Widget>[
Text(
'Welcome to MyApp',
style: [Link](context).textTheme.headline1,
),
SizedBox(height
: 20),
ElevatedButton(
onPressed: () {},
child: Text('Get Started'),
),
],
),
),
);
}
}
Output:
In this example:
We define a custom theme using ThemeData and apply it to the entire app using the
theme property ofMaterialApp.
The theme specifies primary and accent colors, a custom font family, and text styles for
different textelements (headline6 and bodyText2).
Lab Session 7:
form with various input fields such as text fields, checkboxes, radio buttons, and a
dropdown menu
import 'package:flutter/[Link]';
void
main()
{
runApp
(MyAp
p());
}
String_name;
String_email;
bool_subscribeToNewsletter= false;
String_selectedCountry ='USA';
@override
Widget
build(BuildContext
context) {return Scaffold(
appBar: AppBar(
title: Text('Form Example'),
),
body: Padding(
padding:
[Link](20.0),
child: Form(
key:
_formKe
y,child:
Column(
crossAxisAlignment:
[Link],children:
<Widget>[
TextFormField(
decoration: InputDecoration(labelText:
'Name'),onSaved: (value) {
l O M oA R c P S D| 37701387
_name = value;
},
),
SizedBox(height:
20),
TextFormField(
decoration: InputDecoration(labelText:
'Email'),onSaved: (value) {
_email = value;
},
),
SizedBox(height:
20),Row(
children: <Widget>[
Checkbox(
value:
_subscribeToNewsletter,
onChanged: (value) {
setState(() {
_subscribeToNewsletter = value;
});
},
),
Text('Subscribe to Newsletter'),
],
),
SizedBox(height:
20),Row(
children: <Widget>[
Text('Country: '),
SizedBox(width: 20),
DropdownButton<String>(
value: _selectedCountry,
onChanged: (value) {
setState(() {
_selectedCountry = value;
}); },
],
),
SizedBox(height:
20),
ElevatedButton(
onPressed: () {
_formKey.[Link]();
// Submit the form
data print('Name:
$_name');
print('Email:
$_email');
print('Subscribe to Newsletter: $_subscribeToNewsletter');
print('Country: $_selectedCountry');
},
child: Text('Submit'),
),
],
),
),
),
);
}
}
Output:
l O M oA R c P S D| 37701387
package:flutter/material
.dart';void main() {
runApp(MyApp());
}
body:
SingleChildScrollVie
w(padding:
[Link](16),
child: FormWidget(),
),
),
);
}
}
String_name;
String_email;
String_password;
String_phone;
String_address;
l O M oA R c P S D| 37701387
@override
Widget
build(BuildContext
context) {return Form(
key:_form Key,
child:Column(
crossAxisAlignment:
[Link],children:
<Widget>[
TextFormField(
decoration: InputDecoration(labelText:
'Name'),validator: (value) {
if ([Link]) {
return 'Please enter your name';
}
return null;
},
onSaved: (value) => _name = value,
),
SizedBox(heig
ht: 16),
TextFormField
(
decoration: InputDecoration(labelText:
'Email'),keyboardType:
[Link], validator:
(value) {
if ([Link]) {
l O M oA R c P S D| 37701387
'Address'),maxLines: 3,
validator: (value) {
if ([Link]) {
return 'Please enter your address';
}
return null;
},
onSaved: (value) => _address = value,
),
SizedBox(height:
16),
ElevatedButton(
onPressed:
_submitForm,
child:
Text('Submit'),
),
],
),
);
}
void _submitForm() {
if (_formKey.[Link]()) {
_formKey.[Link]();
print('Email:
$_email');
print('Password:
$_password');
print('Phone:
$_phone');
print('Address:
$_address');
}
}
}
l O M oA R c P S D| 37701387
Output:
Lab Session 8:
import
'package:flutter/material.d
art';void main() {
runApp(MyApp());
}
Scaffold(
appBar:
AppBar(
title: Text('Animation Example'),
),
body: AnimationWidget(),
),
);
}
}
@override
void
initSt
ate() {
super.
initSt
ate();
_controller =
AnimationController(
duration:
Duration(seconds: 1),
vsync: this,
);
_animation = Tween<double>(begin: 0, end: 300).animate(_controller)
..addListener(() {
setState(() {}); // Trigger rebuild when animation value changes
});
}
@override
Widget
build(BuildContext
l O M oA R c P S D| 37701387
@override
void dispose() {
_controller
.dispose();
[Link]
ose();
}
}
l O M oA R c P S D| 37701387
Output:
We define an Animation object with Tween to define the range of values for the animation.I
nside the initState() method, we initialize the animation controller and define the
[Link] use addListener() to trigger a rebuild when the animation value
changes.
In the build method, we use the animated value _animation.value to control the size of the
Container, whichcontains the FlutterLogo.
The ElevatedButton toggles the animation between forward and reverse based on the status of the
animationcontroller.
You can customize the animation further by adjusting the duration, adding curves, or chaining
multipleanimations together.
void
main()
{
runApp
(MyAp
p());
}
l O M oA R c P S D| 37701387
@override
void
initSt
ate() {
super.
initSt
ate();
_controller =
AnimationController(
vsync: this,
duration: Duration(seconds: 2),
);
_animation =
Tween<double>(
begin: 0.0,
l O M oA R c P S D| 37701387
end: 1.0,
).animate(_controller);
_controller.forward();
}
@override
Widget
build(BuildContext
context) {return Center(
child:
FadeTransiti
on(opacity:
_animation,
child:
Container(
width: 200,
height: 200,
color: [Link],
),
),
);
}
@override
void dispose() {
_controller
.dispose();
[Link]
ose();
}
}
Slide Animation:
import 'package:flutter/[Link]';
void
main()
{
runApp
(MyAp
p());
}
StatelessWidget {
@override
Widget
build(BuildContext
context) {return
MaterialApp(
home:
Scaffold(
appBar:
AppBar(
title: Text('Slide Animation Example'),
),
body: SlideAnimation(),
),
);
}
}
@override
Widget
build(BuildContext
context) {return Center(
child:
SlideTransiti
on(position:
_animation,
child:
Container(
width: 200,
height: 200,
color: [Link],
),
),
);
}
@override
void dispose() {
_controller
.dispose();
[Link]
ose();
}
}
Scale Animation:
import 'package:flutter/[Link]';
void
main()
{
runApp
(MyAp
p());
}
MaterialApp(
home:
Scaffold(
appBar:
AppBar(
title: Text('Scale Animation Example'),
),
body: ScaleAnimation(),
),
);
}
}
@override
void
initSt
ate() {
super.
initSt
ate();
_controller =
AnimationController(
vsync: this,
duration: Duration(seconds: 2),
);
_animation =
Tween<double>(
begin: 0.0,
end: 1.0,
).animate(_controller);
_controller.forward();
}
@override
l O M oA R c P S D| 37701387
Widget
build(BuildContext
context) {return Center(
child:
ScaleTransiti
on(scale:
_animation,
child:
Container(
width: 200,
height: 200,
color: [Link],
),
),
);
}
@override
void dispose() {
_controller
.dispose();
[Link]
ose();
}
}
Output:
l O M oA R c P S D| 37701387
Lab Session 9:
import 'dart:convert';
import
'package:flutter/material.
dart'; import
'package:http/[Link]'
as http;
void
main()
{
runApp
(MyAp
p());
}
@override
void
initSt
ate() {
super.
initSt
ate();
_fetchDataFromApi();
}
if ([Link]
== 200) {setState(() {
_data = [Link]([Link]);
});
} else {
throw Exception('Failed to load data');
}
}
@override
Widget
build(BuildContext
context) {return Scaffold(
appBar: AppBar(
title: Text('API Data Example'),
),
body:
[Link](
itemCount:
_data.length,
itemBuilder: (context,
index) {return
ListTile(
title:
Text(_data[index]['title']),
subtitle:
Text(_data[index]['body']),
);
},
),
);
}
l O M oA R c P S D| 37701387
Output:
void
main()
{
runAp
p(My
App()
);
}
}
}
@override
void
initSt
ate() {
super.
initSt
ate();
_fetchDataFromApi();
}
Future<void>
_fetchDataFromApi() async {
setState(() {
_isLoading = true;
});
[Link]([Link]('[Link]
([Link] == 200) {
setState(() {
_data = [Link]([Link]);
_isLoading = false;
});
} else {
throw Exception('Failed to load data');
}
}
@override
l O M oA R c P S D| 37701387
Widget
build(BuildContext
context) {return Scaffold(
appBar: AppBar(
title: Text('API Data Example'),
),
body: _isLoading
? Center(
child: CircularProgressIndicator(),
)
: [Link](
itemCount:
_data.length,
itemBuilder: (context,
index) {return PostCard(
title: _data[index]['title'],
body:
_data[index]['body'],
);
},
),
);
}
}
const
PostCard
({ Key
key,
@require
d
[Link],
@required [Link],
}) : super(key: key);
@override
Widget
build(BuildContext
context) {return Card(
margin: [Link](horizontal: 16,
vertical: 8),child: Padding(
l O M oA R c P S D| 37701387
padding:
[Link](16),
child: Column(
crossAxisAlignment:
[Link],children:
<Widget>[
Text(title,
style: TextStyle(fontSize: 18, fontWeight: [Link]),
),
SizedBox(heig
ht: 8),Text(
body,
style: TextStyle(fontSize: 16),
),
],
),
),
);
}
}
Output:
import
'package:flutter/[Link]';
import
'package:flutter_test/flutter_test
.dart';
import 'package:your_app/post_card.dart'; // Import your widget file
void main() {
testWidgets('PostCard displays title and body', (WidgetTester tester) async {
// Build our widget and
trigger a [Link]
[Link](
MaterialApp(
home:
PostCard(
title: 'Test
Title', body:
'Test Body',
),
),
);
),
),
);
final bodyText =
[Link]<Text>([Link]('Test Body'));
expect([Link], 16);
});
}
In this test:
We use the testWidgets function from the flutter_test package to define our test cases.
In the first test case, we ensure that the PostCard widget correctly displays the provided title and
body text.
In the second test case, we verify that the text styles applied to the title and body texts are
as expected. We use expect statements to assert that the expected UI elements are found on
the screen and that theirproperties match the expected values.
Make sure to replace your_app with the appropriate package name where your PostCard widget
resides.
Make sure to provide different test scenarios and edge cases to ensure comprehensive test
coverage for yourUI components.
import 'package:flutter/[Link]';
void
main()
{
l O M oA R c P S D| 37701387
runApp
(MyAp
p());
}
void _incrementCounter() {
_counter++;
}
@override
Widget
build(BuildContext
context) {return Scaffold(
appBar: AppBar(
title: Text('Counter App'),
),
body:
Center
( child:
Colum
n(
mainAxisAlignment: [Link],
children:
<Widget>[
Text(
l O M oA R c P S D| 37701387
'Counter:',
style: TextStyle(fontSize: 24),
),
Text(
'$_cou
nter',
style: TextStyle(fontSize: 36, fontWeight: [Link]),
),
],
),
),
floatingActionButton:
FloatingActionButton(onPressed:
_incrementCounter,
tooltip:
'Increment',
child:
Icon([Link]
d),
),
);
}
}
Now, let's use Flutter's debugging tools to identify and fix the issue:
Widget Inspector: First, let's inspect the widget tree to see if the "+" button is correctly wired to
the
_incrementCounter method. We can do this by running the app in debug mode and
enabling the widget inspector. You can do this by clicking the "Open DevTools" button in
your IDE (Android Studio/IntelliJIDEA or Visual Studio Code) or running the following
command in your terminal:
flutter run –debug
Once the app is running, click on the "Toggle Widget Inspector" button in the top-right
corner of your app. Then, select the FloatingActionButton widget representing the "+"
button. Ensure that the onPressedcallback is correctly set to _incrementCounter.
Debugging Console: If everything looks fine in the widget inspector, we can add some debug
print statements to the _incrementCounter method to see if it's being called when the button is
pressed. Modify the
_incrementCounter
method as follows:void
_incrementCounter() {
print('Incrementing
counter');
_counter++;
}
l O M oA R c P S D| 37701387
Now, run the app again in debug mode and observe the console output when you press the "+"
button. If you don't see the "Incrementing counter" message in the console, it means theincrement
Counter method is not being called.
Breakpoints: As a final step, let's set a breakpoint in the increment Counter method and debug
the app to see if it's being hit. Add a breakpoint by clicking on the left margin of the
increment Counter method in your code editor. Then, run the app in debug mode and press the
"+" button. The app should pause at the breakpoint, allowing you to inspect the current state and
variables. You can step through the code to see if there are any issues with the execution flow.
By using Flutter's debugging tools, you should be able to identify the issue with the counter app
and fix it accordingly. In this case, if the debugging process reveals that the increment Counter
method is not being called, you can double-check the on Pressed callback of the Floating Action
Button to ensure it's correctly wired to the increment Counter method.