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

flutter

Uploaded by

smgreat1212
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

flutter

Uploaded by

smgreat1212
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

1.a) Install Flutter and Dart SDK.

1. System Requirements:
Before installing Flutter, ensure that your system meets the following requirements:
• Operating System: Flutter supports Windows (7 or later), macOS (10.14 or later), and
Linux (64- bit).
• Disk Space: At least 400 MB of free disk space.
• Tools: Git for macOS and Linux, and Power Shell for Windows (required for running
Flutter commands).
• Android Studio or Visual Studio Code (optional but recommended for Flutter
development).

2. Download Flutter:
Visit the Flutter website and download the Flutter SDK for your operating system. You can
choose between stable, beta, or dev releases based on your preference.
3. Extract the Flutter SDK:
Once the download is complete, extract the downloaded ZIP file to a location on your
computer where you want to store the Flutter SDK.
For example, on macOS or Linux, you can extract it to your home directory or any other
preferred location.
4. Set Up Flutter Environment:
Add the Flutter bin directory to your system's PATH environment variable. This step allows
you to run Flutter commands from any terminal window.
• On macOS and Linux, you can do this by editing your shell configuration file (e.g., .bash
profile, .zshrc, or .bashrc) and adding the following line:

Replace <path_to_flutter_sdk> with the actual path


Where you extracted the Flutter SDK.
• On Windows, you can add the Flutter bin directory to the system's PATH by following
these instructions.

5. Verify Flutter Installation:


Open a new terminal window and run the following command to verify that Flutter is properly
installed:

This command should display the Flutter version and Dart version if Flutter is installed
correctly.
6. Install Dart SDK:

Flutter comes with its own copy of the Dart SDK, so you don't need to install Dart separately. However,
if you want to use Dart for non-Flutter projects or development, you can download the Dart SDK from
the Dart website and follow the installation instructions provided.

b)WriteasimpleDartprogramtounderstandthelanguagebasics.
Ans)

voidmain(){
varfirstName="John";
var lastName = "Doe";
print("Fullnameis$firstName $lastName");
}
Output:FullnameisJohnDoe

voidmain(){
intnum1=10;//declaringnumber
1 int num2 = 3; //declaring
number2

// Calculation
intsum=num1 + num2;
int diff = num1 - num2;
intmul=num1 * num2;
doublediv=num1/num2;//Itisdoublebecauseitoutputsnumberwith
decimal.

// displaying the output


print("Thesumis$sum");
print("The diff is $diff");
print("The mul is $mul");
print("The div is $div");
}

Output:
Thesumis13T
hediffis7Them
ulis30
Thedivis3.3333333333333335

import'dart:io';

void main() {
print("Enternumber:");
int?number=int.parse(stdin.readLineSync()!);
print("The entered number is ${number}");
}
Output:
Enternumber:
50
Theenterednumberis50

3. a)ExplorevariousFlutterwidgets(Text,Image,Container,etc.).

TextWidget:

import'package:flutter/material.dart';

//functionto triggerbuild process


voidmain()=>runApp(constGeeksforGeeks());

class GeeksforGeeks extends StatelessWidget


{ constGeeksforGeeks({Key?key}):super(key:key)
;

@override
Widgetbuild(BuildContextcontext){ r
eturn MaterialApp(
home:Scaffold(
backgroundColor:Colors.lightGreen,
appBar:AppBar(
backgroundColor: Colors.green,
title:constText("welcomeScreen")
,
), // AppBar
body:Container
(
child:constCenter(
child:Text("Helloworld!!"),
),//Center
),//Container
),//Scaffold
);//MaterialApp
}
}

Output:HelloWorld!!Imag

eWidget:

import'package:flutter/material.dart';

//functionto startapp building


voidmain()=>runApp(constMyApp());

class MyApp extends StatelessWidget


{constMyApp({Key?key}):super(key:key);

//Thiswidgetisthe root
//of your application

@override
Widgetbuild(BuildContextcontext){ retu
rn MaterialApp(
home:Scaffold(
appBar:AppBar( t
itle: const Text(
'InsertImageDemo',
),
),
body:
Center( child:Col
umn(
children:
<Widget>[ Image.asset('assets/images/output.gif',
height:200,
scale:2.5,
//color:Color.fromARGB(255,15,147,59),
opacity:
const
AlwaysStoppedAnimation<double>(0.5)),//Image.
asset
Image.asset(
'assets/images/geeksforgeeks.j
pg', height: 400,
width:400,
),//Image.asset
], //<Widget>[]
), //Column
), //Center
),
);
}
}

ContainterWidget:

import 'package:flutter/material.dart';

voidmain()=>runApp(constMyApp());

class MyApp extends

StatelessWidget {
constMyApp({Key?key}):super(key:key);

@override
Widgetbuild(BuildContextcontext){ retu
rn MaterialApp(
home:Scaffold(
appBar: AppBar(
title:constText("Containerexample"),
),
body:Container( hei
ght: 200,
width:double.infinity,
//color:
Colors.purple,alignment:Align
ment.center,
margin:constEdgeInsets.all(2
0),
padding:constEdgeInsets.all(30),
decoration: BoxDecoration(
border:Border.all(color:Colors.black,width:3),
),
child:constText("Hello!iaminsideacontainer!",
style: TextStyle(fontSize: 20)),
),
),
);
}
}

Output:

You might also like