Flutter Solved LAB manual (1-14)
Flutter Solved LAB manual (1-14)
LAB # 01
FLUTTER INSTALLATION ON ANDROID STUDIO
OBJECTIVE
Configure Flutter within Android Studio
THEORY
To install Flutter in Android Studio, follow these steps:
LAB EXERCISE
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
CONCLUSION:
We set up Flutter on Android Studio
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB # 02
FLUTTER WIDGETS
OBJECTIVE
Understanding some basic Flutter widgets
THEORY
Here are some basic Flutter widgets that are commonly used to build user interfaces in Flutter
applications:
Widget Description
Container Used for layout, decoration, padding, margin, and constraints.
Text Displays a string of text with various styling options.
Image Displays images from different sources like network, assets, memory,
etc.
Row Arranges child widgets in a horizontal line.
Column Arranges child widgets in a vertical line.
Stack Stacks widgets on top of each other. Useful for creating complex
layouts.
ListView Displays a scrollable list of children widgets.
GridView Displays a scrollable grid of children widgets.
AppBar Represents the app bar, typically used as the top-level bar containing a
title and action items.
Scaffold Implements the basic material design visual layout structure with app
bars, drawers, and floating action buttons.
FlatButton A simple button without any elevation or styling.
RaisedButton A button with a material design style that provides elevation when
pressed.
ElevatedButton A button with a material design style that has a shadow by default.
TextField Accepts user input as text.
Checkbox A widget for a single checkbox.
Radio A widget for a radio button that allows single selection among
multiple choices.
Switch A widget for a toggle switch that can be on or off.
GestureDetector Detects various user gestures on its child widget, like taps, drags, etc.
AlertDialog A dialog that interrupts the user's workflow to get a response.
BottomSheet A widget that slides up from the bottom to reveal more content or
actions.
SnackBar A small widget for showing messages at the bottom of the screen.
AnimatedContainer A container that animates changes to its properties like size, color, etc.
Flexible A widget that controls how a child widget can grow to fill available
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
These are just a few of the basic widgets available in Flutter. There are many more widgets
available in the Flutter framework, each serving a specific purpose in building user interfaces.
Understanding and utilizing these widgets effectively allows developers to create rich and
responsive UIs in Flutter applications.
LAB EXERCISE
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
CONCLUSION:
In this lab, I learnt about the basic flutter widget using Android Studio ID.
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB # 03
SET UP EMULATOR ON ANDROID STUDIO FOR DEVELOPMENT
OBJECTIVE
Configure emulator on Android Studio
THEORY
Setting up an emulator in Android Studio for Android app development involves a few steps to
create and configure a virtual device (AVD). Here's a guide to set up an emulator:
6. Configure AVD:
- Name the device and configure additional settings such as RAM, VM heap, orientation, etc.
Adjust as needed.
- Click `Finish`.
LAB EXERCISE
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
CONCLUSION:
We configured an emulator on android studio for development
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB # 04
HELLO WORLD
OBJECTIVE
Display “Hello World” in the center with blue color
THEORY
To display "Hello World" in the center of the screen with blue color in Flutter, you can follow
these steps:
LAB EXERCISE
Output:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB # 05
TEXT ALIGNMENT
OBJECTIVE
Perform Text Alignments
THEORY
In Flutter, the `Text` widget has a property called `textAlign` that allows you to specify how the
text is aligned within its container. The `textAlign` property determines whether the text is
aligned to the left, right, center, or justified. Here are the possible values for `textAlign`:
4. justify: Adjusts spacing between words so that the text is fully justified, meaning it spreads
evenly across the container.
5. start: Aligns text to the start of the line, considering the text direction (left-to-right or right-
to-left).
6. end: Aligns text to the end of the line, considering the text direction (left-to-right or right-to-
left).
You can also utilize a combination of `Container` and `alignment` property to achieve text
alignment.
- The `alignment` property within the `Container` is set to `Alignment.center` to center-align the
child widget.
You can modify the `alignment` property to `Alignment.centerLeft`, `Alignment.centerRight`,
`Alignment.topLeft`, `Alignment.bottomRight`, etc., based on your requirements to achieve
different alignments within the `Container`. Adjust the `Alignment` values to achieve the
desired text positioning within the container.
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB EXERCISE
Top Left:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Top Right:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Output:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
TopCenter:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Output:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
BottomRight:
Output:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
CONCLUSION:
In this lab, we performed text alignments.
LAB # 06
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
BUTTON WIDGET
OBJECTIVE
Display button widgets in horizontal and vertical
THEORY
Types of Button Widgets:
ElevatedButton: Represents a Material Design raised button. Provides elevation when pressed.
TextButton: Represents a simple text button. No elevation or fill color by default.
OutlinedButton: Represents a button with an outlined border. No elevation and transparent fill
color by default.
To display button widgets in both horizontal and vertical arrangements in Flutter, you can use
`Row` and `Column` widgets. Here are the steps:
By following these steps, you can display button widgets in both horizontal and vertical
arrangements using `Row` and `Column` widgets in Flutter. Adjust the button properties, styles,
and actions according to your app's requirements.
LAB EXERCISE
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Output:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
CONCLUSION:
We displayed button widgets horizontally and vertically
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB # 07
OPEN ENDED LAB
OBJECTIVE
Perform Flutter Gestures
THEORY
Gestures are primarily a way for a user to interact with a mobile (or any touch based
device) application. Gestures are generally defined as any physical action / movement
of a user in the intention of activating a specific control of the mobile device.
• Tap − Touching the surface of the device with fingertip for a short
period and then releasing the fingertip.
• Double Tap − Tapping twice in a short time
• Drag − Touching the surface of the device with fingertip and then
moving the fingertip in a steady manner and then finally releasing the
fingertip.
• Flick − Similar to dragging, but doing it in a speeder way.
• Pinch − Pinching the surface of the device using two fingers.
• Spread/Zoom − Opposite of pinching.
• Panning − Touching the surface of the device with fingertip and
moving it in any direction without releasing the fingertip.
It is a simple Flutter task that involves implementing gesture recognition for a container.
The task is to change the color of the container when it is tapped.
LAB EXERCISE
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Output:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Before Tap:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
After Tab
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB # 08
HELLO WORLD IN AVD
OBJECTIVE
Display “Hello World” in AVD
THEORY
Switching from running a Flutter web app to an Android Virtual Device (AVD) in Android
Studio involves a few steps. Here's a guide:
3. Run Configuration:
- Ensure that your Flutter project is open in Android Studio.
- At the top of Android Studio, there is a dropdown menu with configurations (to the right of
the run and debug buttons). It usually displays `main.dart` or the name of your main entry file.
- Click on the dropdown menu and select your Android device emulator (AVD). If no AVD is
listed, click on `Edit Configurations...`.
- The Flutter app will be launched on the selected AVD, and you'll see the app running in the
emulator.
LAB EXERCISE:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
CONCLUSION:
We displayed “Hello World” in AVD
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB # 09
CREATE A METHOD FOR BUTTON
OBJECTIVE
Create a method for button when clicked
THEORY
Properties and Customization:
onPressed: Specifies the function to be called when the button is pressed.
child: Widget representing the content of the button (usually Text widget).
style: Allows customization of the button's appearance such as text style, padding, shape,
background color, and more.
icon: Property in certain button types to include an icon along with text.
Button Behavior:
Buttons can trigger actions like navigation to another screen, submitting a form, or executing a
function.
Buttons can be disabled using the onPressed property set to null.
LAB EXERCISE
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Output:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
CONCLUSION:
In this lab, I understand the concept of button’s method.
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB # 10
PROFILE CARD
OBJECTIVE
Create and display a profile card
THEORY
Here's a step-by-step guide to creating a simple profile card:
1. Create a new Flutter project using your preferred development environment (such as
VSCode, Android Studio, or IntelliJ).
3. Replace the existing code and include the following flutter widgets;
b) Column` and Text widgets: The user details are displayed using `Column` and `Text`
widgets to arrange text vertically.
c) RichText` for Details: A `RichText` widget is used to display multiline text with
different styles. It shows an "About Me" section with a bold heading and a longer
description.
Note:
- Replace the placeholder image URL with your desired image URL.
- Modify the text content and styles according to your preferences.
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB EXERCISE
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Output:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
CONCLUSION:
We created and displayed a profile card.
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB # 11
CALCULATOR APP
OBJECTIVE
Develop a calculator app
THEORY
Dart supports various arithmetic operators that enable performing arithmetic operations on
numeric values. Here are the Dart arithmetic operators:
Arithmetic Operators:
1. Addition (+):
- Adds two operands. Example;
int sum = 10 + 5; // sum is 15
2. Subtraction (-):
- Subtracts the second operand from the first. Example;
int difference = 10 - 5; // difference is 5
3. Multiplication (*):
- Multiplies two operands. Example;
int product = 10 * 5; // product is 50
4. Division (/):
- Divides the first operand by the second. Example;
double quotient = 10 / 5; // quotient is 2.0 (double due to numeric types)
6. Modulo (%):
- Returns the remainder of the division between the first and second operands. Example;
int remainder = 10 % 3; // remainder is 1
These operators work with numeric types (integers and doubles) and allow performing various
arithmetic calculations within Dart. Understanding and using these operators can help in
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB EXERCISE
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Output:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Addition Divison
CONCLUSION:
We created a calculator app.
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB # 12
SPLASH SCREEN
OBJECTIVE
Develop a splash screen
THEORY
To create a simple splash screen in Flutter :
1. Create a Splash Screen Widget: In your `main.dart` file or wherever your app starts, create
a custom `SplashScreen` widget that displays your splash screen content for a certain duration
before navigating to the main screen:
2. Modify Splash Screen Content: Inside the `SplashScreenState` widget's `build` method,
customize the `Scaffold` body to display your desired splash screen content.
This approach uses Flutter's `Timer` class to create a delay before navigating to the main screen
without relying on external packages for splash screen management. Adjust the duration and
customize the splash screen content as needed for your application.
LAB EXERCISE
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
CONCLUSION:
We created and displayed a splash screen.
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB # 13
LOGIN SCREEN AND NAVIGATION
OBJECTIVE
Develop a login screen with navigation
THEORY
To implement a login screen and navigate to a new screen in a Flutter app, you can follow these
steps:
1. Create a new Flutter project: Start by creating a new Flutter project using the `flutter
create` command in your terminal.
2. Design the login screen: Design your login screen UI using widgets like `TextField`,
`ElevatedButton`, etc.
3. Create a new screen to navigate to: Create a new screen (in this example, named
`NewScreen`) where you want to navigate after successful login.
4. Implement navigation on successful login: Inside the `onPressed` handler of your login
button, implement the logic to verify the login credentials. If the login is successful, navigate to
the new screen. For example;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => NewScreen(),
),
);
5. Run the app: Run your Flutter app using `flutter run` in the terminal or use your preferred
IDE's running/debugging options.
LAB EXERCISE
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
CONCLUSION:
In this lab I created and displayed a login screen and sign up page with navigation .
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB # 14
OPEN ENDED LAB
OBJECTIVE
Develop a todo list application.
THEORY
• Create a Dart project and set up the necessary files (e.g., main.dart).
• Create a Task class to represent each task with properties such as id, title, and
isCompleted.
• Create a TaskManager class to manage the list of tasks. Implement methods like
addTask, completeTask, and removeTask.
• Create a simple console-based user interface to interact with the to-do list. Use
options like adding a task, marking a task as completed, and removing a task.
This basic to-do list application allows users to interact through a console-based
interface. You can enhance it further by adding error handling, persistent storage,
a graphical user interface (GUI), or additional features based on your preferences
and skills.
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
LAB EXERCISE
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
Output:
Mobile App Development (MCS-206L) SSUET/QR/114
Nadra Arshad Roll No:2021f-bmcs-014
CONCLUSION:
I created todo list app by using all previous concept.