Skip to main content

Posts

Showing posts from December, 2024

Center widget flutter

  The Center widget in Flutter is a simple yet powerful widget that centers its child within the available space. It's often used to position a widget in the middle of its parent widget. Key Features of Center Alignment : The Center widget by default centers its child both horizontally and vertically. Constraints : The child of a Center widget is allowed to have any size it wants unless constrained by its parent. Ease of Use : The Center widget is commonly used because of its simplicity and readability when designing UI. Parameters child : The widget that you want to center. If null , the Center widget will occupy all available space but won't display anything. widthFactor and heightFactor : Multipliers for the size of the child. These are optional parameters. If specified, the width and/or height of the Center widget will be the child’s size multiplied by the respective factor. If null , the Center will expand to fit its parent. Basic Example dart Copy code import ...

Text Widget In Flutter

  The Text widget in Flutter is used to display text on the screen. It's one of the most fundamental widgets and supports a wide range of customizations to style, align, and manage text. Here’s a detailed overview: Basic Syntax dart Copy code Text( 'Hello, Flutter!', style: TextStyle(fontSize: 24, color: Colors.blue), textAlign: TextAlign.center, ) Key Properties data : The text string to display. Example: 'Hello, World!' . style : Defines the appearance of the text. Uses the TextStyle class for customization. Example : dart Copy code Text( 'Styled Text', style: TextStyle( fontSize: 20, fontWeight: FontWeight.bold, color: Colors.red, fontStyle: FontStyle.italic, letterSpacing: 2.0, wordSpacing: 5.0, decoration: TextDecoration.underline, ), ) textAlign : Aligns the text horizontally. Values: TextAlign.left , TextAlign.right , TextAlign.center , TextAlign.justify , etc. Example: dart Copy code textAlign: TextAlign.cente...

Flutter Container widget

 The Container widget in Flutter is a versatile and commonly used widget that provides a way to create a rectangular box with various properties such as padding, margin, alignment, decoration, and constraints. It is essentially a combination widget that combines several commonly used features into one. Here's a detailed breakdown of everything about the Container widget: Basic Features 1. Dimensions Width and Height : You can specify fixed or relative dimensions. Container( width: 100, height: 100, ) 2. Padding Adds space inside the container between its child and the container’s boundaries. Container( padding: EdgeInsets.all(10), // uniform padding ) 3. Margin Adds space outside the container between the container and other widgets. Container( margin: EdgeInsets.symmetric(vertical: 10, horizontal: 15), ) 4. Color Set a background color for the container. Container( color: Colors.blue, ) Decoration The decoration property allows for more advanced customization, like ...

Step by step guide to installing Flutter on Windows

  Step 1: System Requirements Ensure your system meets the following requirements: Operating System : Windows 10 or later (64-bit). Disk Space : 1.64 GB (minimum) for Flutter SDK, plus additional space for IDE/tools. Tools : Git for Windows: Download here . Command Prompt (cmd) or PowerShell. Step 2: Download Flutter SDK Go to the official Flutter website . Download the Windows Flutter SDK .zip file. Extract the .zip file to a directory, such as C:\src\flutter . Step 3: Add Flutter to System PATH Open Environment Variables : Search for "Environment Variables" in the Windows Start menu. Click Edit the system environment variables > Environment Variables . Under System variables , find and select the Path variable. Click Edit and add the path to the Flutter bin directory (e.g., C:\src\flutter\bin ). Step 4: Verify Installation Open a new Command Prompt or PowerShell window. Run: bash Copy code flutter doctor This checks your installation and lists missing dependenci...

Easy Way to Define a StatelessWidget

 In Flutter, a StatelessWidget is a type of widget that does not change over time. It is immutable, meaning that its properties and state are fixed after it is created. You use StatelessWidget when the widget's appearance or behavior is determined entirely by its constructor parameters. Easy Way to Define a StatelessWidget Here’s a simple example: import 'package:flutter/material.dart'; class MyWidget extends StatelessWidget { final String title; // Constructor to accept input MyWidget({required this.title}); @override Widget build(BuildContext context) { return Center( child: Text( title, style: TextStyle(fontSize: 24), ), ); } } void main() { runApp( MaterialApp( home: Scaffold( appBar: AppBar(title: Text('StatelessWidget Example')), body: MyWidget(title: 'Hello, Flutter!'), ), ), ); } Explanation: Inheritance : The widget class extends StatelessWidget . Construc...

Complete Flutter Roadmap: From Beginner to Pro

  1. Basics of Programming (if you're new to coding) Languages : Learn Dart (Flutter's programming language) basics: Variables, data types, functions, loops, and conditionals. Object-oriented programming (OOP) principles (classes, inheritance, polymorphism). Tools : Install and learn to use code editors like Visual Studio Code or Android Studio. Git for version control. 2. Set Up Flutter Development Environment Install Flutter SDK: Flutter Installation Guide . Set up an IDE: Use Android Studio or VS Code with Flutter and Dart plugins. Configure emulators (Android and iOS) or connect physical devices. 3. Learn Flutter Basics Widgets : Understand the difference between StatelessWidget and StatefulWidget . Explore common widgets: Text , Container , Column , Row , Stack , ListView , etc. Layouts and Design : Learn layout widgets like Padding , Align , Expanded , Flex . Study Flutter's responsive design principles (e.g., MediaQuery , LayoutBuilder ). Hot Reload : Familiarize ...