0% found this document useful (0 votes)
13 views19 pages

Dart

The document outlines multiple projects focused on Dart and Flutter programming, including setting up development environments, using data types and operators, implementing conditional statements, and creating animations. Each project has specific aims, objectives, requirements, and procedures for coding various functionalities in Dart and Flutter. The results demonstrate successful implementation of the concepts covered in each project.

Uploaded by

Anish Sharma
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)
13 views19 pages

Dart

The document outlines multiple projects focused on Dart and Flutter programming, including setting up development environments, using data types and operators, implementing conditional statements, and creating animations. Each project has specific aims, objectives, requirements, and procedures for coding various functionalities in Dart and Flutter. The results demonstrate successful implementation of the concepts covered in each project.

Uploaded by

Anish Sharma
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/ 19

PROJECT- 1

Title: Installing and Using Dart & Flu er, and Managing Flu er Projects

Aim:

To set up the development environment for Flu er and Dart and learn how to manage
Flu er projects effec vely.

Objec ve:

 Install Flu er SDK and Dart.

 Set up IDE (Android Studio or VS Code).

 Create, run, and manage a Flu er project.

 Understand project structure and dependencies.

Requirements:

 A computer (Windows, macOS, or Linux).

 Internet connec on.

 Flu er SDK.

 Dart SDK (comes with Flu er).

 Android Studio or Visual Studio Code.

 Git.

Procedure:

1. Install Flu er SDK:

o Download Flu er from h ps://flu er.dev.

o Extract it and add the bin folder to the system path.

2. Run Flu er Doctor:

o Open terminal and run flu er doctor to check dependencies.

3. Install IDE:

o Use Android Studio or VS Code.

o Add Flu er and Dart plugins/extensions.

4. Create Project:
o Run flu er create project_name.

5. Navigate to Project:

o cd project_name.

6. Run the App:

o Use flu er run.

7. Manage Project Structure:

o lib/ contains main Dart code.

o pubspec.yaml for dependencies.

o Use flu er pub get to install packages.

Result:

A working Flu er environment with a structured app created, run, and managed using Dart
and Flu er SDKs.
PROJECT- 2
Title: Programs Using Various Data Types and Operators in Dart

Aim:

To understand and implement different data types and operators in Dart programming
language through simple example programs.

Objec ve:

 To use built-in data types such as int, double, String, bool, and var.

 To apply arithme c, rela onal, logical, assignment, and condi onal operators.

 To demonstrate type safety and operator behavior.

Requirements:

 Dart SDK installed

 VS Code or any Dart-supported IDE

 Basic understanding of programming logic

 Terminal or DartPad for execu on

Procedure:

1. Open DartPad or IDE:

o Go to h ps://dartpad.dev or open IDE.

2. Write Program with Data Types:

void main() {

int a = 10;

double b = 5.5;

String name = "Dart";

bool isFun = true;

var total = a + b;

print("Integer: $a");

3. Use Operators:
void main() {

int x = 10, y = 3;

print("Addi on: ${x + y}");

print("Subtrac on: ${x - y}");

print("Mul plica on: ${x * y}");

print("Division: ${x / y}");

print("Modulus: ${x % y}");

print("Is x > y? ${x > y}");

print("Is x == y? ${x == y}");

print("Logical AND: ${x > 5 && y < 5}");

Expected Output:

Integer: 10

Double: 5.5

String: Dart

Boolean: true

Total (a + b): 15.5


PROJECT- 3

Title: Programs Using Condi onal Statements in Dart

Aim:

To implement decision-making in Dart programs using condi onal statements like if, if-else,
if-else-if, and switch.

Objec ve:

 To understand the flow of logic in condi onal constructs.

 To write Dart programs using different condi onal statements.

 To evaluate condi ons and execute code blocks based on truth values.

Requirements:

 Dart SDK or DartPad

 IDE (VS Code, Android Studio) or h ps://dartpad.dev

 Basic understanding of boolean expressions

Procedure:

Program 1: if-else Statement

void main() {

int num = 10;

if (num > 0) {

print("Number is posi ve");

} else {

print("Number is non-posi ve"); }}

Program 2: if-else-if Ladder

void main() {

int marks = 75;

if (marks >= 90) {


print("Grade: A");

} else if (marks >= 70) {

print("Grade: B");

} else if (marks >= 50) {

print("Grade: C");

} else {

print("Grade: F"); }}

Program 3: switch Statement

void main() {

String day = "Tuesday"

switch (day) {

case "Monday":

print("Start of the week");

break;

case "Tuesday":

print("Second day of the week");

break;

case "Friday":

print("End of the work week");

break;

default:

print("Another day"); }}

Result:

 Output 1: Number is posi ve

 Output 2: Grade: B

 Output 3: Second day of the week


Each condi on is evaluated correctly, and the appropriate block is executed.
PROJECT- 4
Title: Lab Experiment 4 – Programs Using Loop Statements and Strings in Dart

Aim:

To understand and implement loop structures (for, while, do-while) and perform opera ons
on strings in Dart.

Objec ve:

 To use looping constructs for repeated tasks.

 To manipulate and evaluate string data.

 To demonstrate use cases like coun ng, reversing, and character opera ons with
strings.

Requirements:

 Dart SDK / DartPad

 IDE (VS Code / Android Studio)

 Basic knowledge of loops and strings

Procedure:

Program 1: for Loop to Print String Characters

void main() {

String text = "Dart";

for (int i = 0; i < text.length; i++) {

print("Character at $i: ${text[i]}");

Program 2: while Loop to Reverse a String

void main() {

String original = "loop";

String reversed = "";

int i = original.length - 1;
while (i >= 0) {

reversed += original[i];

i--;

print("Reversed string: $reversed");

Program 3: do-while Loop to Count Vowels

dart

CopyEdit

void main() {

String input = "Educa on";

int count = 0;

int i = 0;

do {

if ("aeiouAEIOU".contains(input[i])) {

count++;

i++;

} while (i < input.length);

print("Number of vowels: $count");

Result:

 Program 1 prints each character of "Dart".

 Program 2 outputs the reversed string "pool".


PROJECT- 5
Title: Programs Using Widgets in Flu er

Aim:

To understand and use basic widgets in Flu er for building user interfaces.

Objec ve:

 To explore the structure of a Flu er widget tree.

 To implement stateless and stateful widgets.

 To create simple UIs using Text, Container, Column, Row, ElevatedBu on, etc.

Requirements:

 Flu er SDK and Dart installed

 IDE (VS Code or Android Studio)

 Android/iOS emulator or real device

 Basic knowledge of Dart and UI components

Procedure:

Program 1: Simple Stateless Widget

import 'package:flu er/material.dart';

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

class MyApp extends StatelessWidget {

@override

Widget build(BuildContext context) {

return MaterialApp(

home: Scaffold(

appBar: AppBar( tle: Text('Stateless Widget')),

body: Center(child: Text('Hello Flu er!')),

),
);

Program 2: Stateful Widget with Bu on

import 'package:flu er/material.dart';

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

class CounterApp extends StatefulWidget {

@override

_CounterAppState createState() => _CounterAppState();

class _CounterAppState extends State<CounterApp> {

int counter = 0;

void increment() {

setState(() {

counter++;

});

@override

Widget build(BuildContext context) {

return MaterialApp(

home: Scaffold(

appBar: AppBar( tle: Text('Stateful Widget')),

body: Center(
child: Column(

mainAxisAlignment: MainAxisAlignment.center,

children: [

Text('Counter: $counter'),

ElevatedBu on(

onPressed: increment,

child: Text('Increment'),

),

],

),

),

),

);

Result:

 Program 1 shows a basic app with a text message using a stateless widget.

 Program 2 displays a counter and a bu on to increment the value, using a


stateful widget. Both programs successfully demonstrate usage of core Flu er
widgets and UI interac on.
PROJECT- 6
Title: Lab Experiment – Programs Using Func ons and Classes in Dart

Aim:

To learn the use of func ons and object-oriented concepts through classes in Dart
programming.

Objec ve:

 To define and use user-defined func ons.

 To create and use classes and objects.

 To implement constructors, methods, and encapsula on.

Requirements:

 Dart SDK / DartPad

 IDE (VS Code / Android Studio)

 Knowledge of Dart syntax and object-oriented principles

Procedure:

Program 1: Simple Func on

void greet(String name) {

print("Hello, $name!");

void main() {

greet("Alice");

Program 2: Class with Constructor and Method

class Student {

String name;

int age;
Student(this.name, this.age);

void displayInfo() {

print("Name: $name");

print("Age: $age");

void main() {

Student s1 = Student("Bob", 20);

s1.displayInfo();

Program 3: Class with Ge er and Se er

class Circle {

double _radius;

Circle(this._radius);

double get area => 3.14 * _radius * _radius;

set radius(double value) {

if (value > 0) {

_radius = value;

void main() {
Circle c = Circle(5);

print("Area: ${c.area}");

c.radius = 7;

print("Updated Area: ${c.area}");

Result:

 Program 1 prints a gree ng using a simple func on.

 Program 2 creates a student object and displays info using a class method.

 Program 3 demonstrates ge ers and se ers in a class to calculate area. All programs
validate Dart's support for func onal and object-oriented programming.
PROJECT- 7
Title: Lab Experiment – Programs for Adding Anima ons in Flu er

Aim:

To implement basic anima ons in a Flu er applica on using built-in anima on widgets and
controllers.

Objec ve:

 To understand Flu er’s anima on framework.

 To use implicit and explicit anima ons.

 To enhance UI interac vity and user experience through anima ons.

Requirements:

 Flu er SDK

 VS Code or Android Studio

 Android/iOS emulator or device

 Knowledge of Dart and Flu er widget tree

Procedure:

Program 1: Implicit Anima on using AnimatedContainer

import 'package:flu er/material.dart';

import 'dart:math';

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

class MyApp extends StatefulWidget {

@override

_MyAppState createState() => _MyAppState();

class _MyAppState extends State<MyApp> {


double _size = 100;

void _changeSize() {

setState(() {

_size = Random().nextInt(200).toDouble() + 50;

});

@override

Widget build(BuildContext context) {

return MaterialApp(

home: Scaffold(

appBar: AppBar( tle: Text('AnimatedContainer')),

body: Center(

child: Column(

mainAxisAlignment: MainAxisAlignment.center,

children: [

AnimatedContainer(

width: _size,

height: _size,

color: Colors.blue,

dura on: Dura on(seconds: 1),

curve: Curves.easeInOut,

),

ElevatedBu on(

onPressed: _changeSize,

child: Text("Animate"),

),
],

),

),

),

);

Program 2: Explicit Anima on using Anima onController

import 'package:flu er/material.dart';

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

class AnimatedBox extends StatefulWidget {

@override

_AnimatedBoxState createState() => _AnimatedBoxState();

class _AnimatedBoxState extends State<AnimatedBox> with SingleTickerProviderStateMixin


{

late Anima onController _controller;

late Anima on<double> _anima on;

@override

void initState() {

super.initState();

_controller = Anima onController(

dura on: const Dura on(seconds: 2),

vsync: this,
);

_anima on = Tween<double>(begin: 0, end: 300).animate(_controller)

..addListener(() {

setState(() {});

});

_controller.repeat(reverse: true);

@override

void dispose() {

_controller.dispose();

super.dispose();

@override

Widget build(BuildContext context) {

return MaterialApp(

home: Scaffold(

appBar: AppBar( tle: Text("Explicit Anima on")),

body: Center(

child: Container(

height: _anima on.value,

width: _anima on.value,

color: Colors.red,

),

),

),

);
}

Result:

 Program 1 animates size changes using AnimatedContainer when the bu on is


pressed.

 Program 2 uses Anima onController and Tween to animate a container’s size in a


loop. Both programs demonstrate smooth anima ons, enhancing UI responsiveness
in Flu er.

You might also like