0% found this document useful (0 votes)
16 views6 pages

Assignment 1 (Mad)

Uploaded by

motoholic10
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)
16 views6 pages

Assignment 1 (Mad)

Uploaded by

motoholic10
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/ 6

Assignment 1

Case Study on basics of Dart language and design basic


flutter App.

Introduction to Dart :-
Dart is the open-source programming language originally developed by
Google. It is meant for both server side as well as the user side. The Dart SDK
comes with its compiler – the Dart VM and a utility dart2js which is meant for
generating Javascript equivalent of a Dart Script so that it can be run on
those sites also which don’t support Dart.
Dart is Object-oriented language and is quite similar to that of Java
Programming. Dart is extensively use to create single-page websites and
web-applications. Best example of dart application is Gmail.

You can install Dart SDK from their official website or download the installer
from this site.

Key features of Dart :-


1. Strongly Typed :- Dart is a statically typed language, which means that
variable types are known at compile time , leading to better performance
and error checking.
2. Asynchronous Programming :- Dart supports asynchronous programming
through its async/await syntax , making it easy to work with operations
that might take time , such as network requests.
3. Garbage Collection :- Dart has automatic memory management through
garbage collection, which helps in managing memory efficiently.
4. Object-Oriented:- Dart support object-oriented programming concepts
like classes , inheritance , interface and mixins.
For Windows OS:
To install dart in window system we will be using Chocolatey.
To install Dart:
C:\> choco install dart-sdk

To Update Dart:
C:\> choco upgrade dart-sdk

For Linux OS:


If you’re using Debian/Ubuntu on AMD64 (64-bit Intel), you can choose one
of the following options, both of which can update the SDK automatically
when new versions are released.
 Install using apt-get
 Install a Debian package
Install using apt-get:
Perform the following one-time setup:
$ sudo apt-get update
$ sudo apt-get install apt-transport-https
$ sudo sh -c 'wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key
add -'
$ sudo sh -c 'wget -qO-
https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list >
/etc/apt/sources.list.d/dart_stable.list'

Then install the Dart SDK:


$ sudo apt-get update
$ sudo apt-get install dart
Install a Debian package:
Download Dart SDK as Debian package in the .deb package format.
Modify PATH for access to all Dart binaries
After installing the SDK, add its bin directory to your PATH. For example, use
the following command to change PATH in your active terminal session:
$ export PATH="$PATH:/usr/lib/dart/bin"

To change the PATH for future terminal sessions, use a command like this:
$ echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> ~/.profile
 For Mac OS: Install Homebrew , and then run the following
commands:
$ brew tap dart-lang/dart
$ brew install dart

To upgrade when a new release of Dart is available:


$ brew upgrade dart

Creating a Simple Application in Flutter





Flutter is an open-source cross-platform mobile application development SDK
created by Google. It is highly user-friendly and builds high-quality mobile
applications. The intention behind this article is to guide readers through the
process of building an application through flutter by creating a simple Flutter
App on Android Studio. To start creating a Flutter application we have to first
create a flutter project and many other things, for that follow the steps
mentioned below:

Create a New Flutter Project

Step 1: Open the Android Studio IDE and select Start a new Flutter project.
Step 2: Select the Flutter Application as the project type. Then click Next.

Step 3: Verify the Flutter SDK path specifies the SDK’s location (select Install
SDK… if the text field is blank).
Step 4: Enter a project name (for example, myapp). Then click Next
Step 5: Click Finish and wait till Android Studio creates the project.
Step 6: Edit the code

/ Importing important packages require to connect


// Flutter and Dart
import 'package:flutter/material.dart';

// Main Function
void main() {
// Giving command to runApp() to run the app.

/* The purpose of the runApp() function is to attach


the given widget to the screen. */
runApp(const MyApp());
}

// Widget is used to create UI in flutter framework.

/* StatelessWidget is a widget, which does not maintain


any state of the widget. */

/* MyApp extends StatelessWidget and overrides its


build method. */
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

// This widget is the root of your application.


@override
Widget build(BuildContext context) {
return MaterialApp(
// title of the application
title: 'Hello World Demo Application',
// theme of the widget
theme: ThemeData(
primarySwatch: Colors.lightGreen,
),
// Inner UI of the application
home: const MyHomePage(title: 'Home page'),
);
}
}

/* This class is similar to MyApp instead it


returns Scaffold Widget */
class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key, required this.title}) : super(key:
key);
final String title;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
// Sets the content to the
// center of the application page
body: const Center(
// Sets the content of the Application
child: Text(
'Welcome to GeeksForGeeks!',
)),
);
}
}

Conclusion:

In this case study, we explored the basics of the Dart language


and designed a basic Flutter app. Dart provides powerful features
for building robust and scalable applications, and Flutter makes it
easy to create beautiful, cross-platform user interfaces. This
example demonstrates how to perform basic calculations using
user input in a Flutter app, showcasing the simplicity and
effectiveness of Dart and Flutter in mobile app development.

You might also like