Flutter Size Box In Sinhala

Flutter Size Box In Sinhala

SizedBox යනු flutter SDK හි ඇති විජට් එකකි. එය නිශ්චිත ප්රමාණයකින් යුත් සරල පෙට්ටියකි. එය ළමා විජට් සඳහා ප්‍රමාණයේ සීමාවන් සැකසීමට, විජට් දෙක අතර හිස් ප්‍රමාණයේ පෙට්ටියක් තැබීමට හෝ ඒ අතර යම් ඉඩක් ලබා ගැනීමට භාවිතා කළ හැකිය. එය අඩු ගුණාංග සහිත Container widget  එකකට තරමක් සමාන වේ.

Constructor of SizedBox Class:

 It draws a simple box with the mentioned height and width or a child widget inside. 

const SizedBox(

{Key key,

double width,

double height,

Widget child}

)

Constructor of SizedBox.expand:

 This implementation of the SizedBox widget allows it to be as big as the parent widget allows it to be. 

const SizedBox.expand(

{Key key,

Widget child}

)

 

Constructor of SizedBox.fromSize: 

This allows creating a SizedBox with a specified size.

SizedBox.fromSize(

{Key key,

Widget child,

Size size}

)

Constructor of SizedBox.shrink:

 This implementation of the SizedBox widget allows it to be as small as the child widget allows it to be. 

const SizedBox.shrink(

{Key key,

Widget child}

)

Properties of SizedBox Widget:

  • child: This property takes in a child widget as the object to display it below the SizedBox in the widget tree or inside the SizedBox n the screen.

  • height: This property specifies the height of SizedBox in pixels. It is a double value as the object.

  • width: This property also holds in a double value as the object to give width to the SizedBox.

Example 1:

import 'package:flutter/material.dart';

//Importing material design library
void main() {
runApp(
    //Our app widget tree starts from here
    MaterialApp(
    home: Scaffold(
        appBar: AppBar(
        title: Text('AppsLankaDev'),
        centerTitle: true,
        backgroundColor: Colors.greenAccent[400],
        ), //AppBar
        body: Center(
        //SizedBox Widget
        child: SizedBox(
            width: 200.0,
            height: 100.0,
            child: Card(
            color: Colors.green,
            child: Center(
                child: Text(
                'AppsLankaDev',
                style: TextStyle(color: Colors.white),
                ), //Text
            ), //Center
            ), //Card
        ), //SizedBox
        ), //Center
    ), //Scaffold
    ), //MaterialApp
);
}

 

 

 We are developing Mobile application and Web application for more details visit our web site www.appslanka.lk

 

0 Comments

Leave a comment

Your email address will not be published. Required fields are marked *