Flutter Tips and Tricks: How Container widget works

Knowing all the features of essential widgets is absolutely necessary to the completion of any Flutter project.
What does this mean?
Any StateLessWidget of Flutter comes with many features. Moreover, some of them depend on each other. For example, in Container widget, you can control the shape of the widget by providing some values. However, it will not work if you use borderRadius property at the same time.
Today we will direct our attention on Container widget. As the name suggests, it can contain many other widgets.
Let us jump from theory to practice – code. You will find everything explained in the following code snippet.

import 'package:flutter/material.dart';

class ContainerController extends StatelessWidget {
@override
Widget build(BuildContext context) {
return _containerController();
}
}

Widget _containerController() => Container(
//padding: EdgeInsets.all(8.00),
// it fills the whole container
//constraints: BoxConstraints.expand(),
alignment: Alignment.center,
//color: Colors.blue,
// we can adjust width and height
// to do that we need to commented out the constraints
width: 350.00,
height: 350.00,
// to skew the container
//transform: Matrix4.rotationZ(0.7),
decoration: BoxDecoration(
color: Colors.blue,
border: Border.all(
color: Colors.red,
width: 2.0,
style: BorderStyle.solid,
),
borderRadius: BorderRadius.all(Radius.circular(40.0)),
boxShadow: [
BoxShadow(
color: Colors.black54,
blurRadius: 20.0,
spreadRadius: 20.0,
),
],
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
Colors.red,
Colors.white,
],
),
// to make shape active we need to comment out borderRadius property and vice versa
//shape: BoxShape.circle,
),
// padding will only work if the container padding is off
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Text(
'Any App',
style: TextStyle(
fontSize: 45.00,
color: Colors.white,
),
),
),
);

To know more about Flutter you may read Beginning Flutter with Dart by Sanjib Sinha
For more Flutter code you may visit the following Github repositories.

Sanjib Sinha Github

What is Algorithm?

discrete-mathematical-algorithm-data-structures
discrete-mathematical-algorithm-data-structures

https://leanpub.com/discretemathematicalalgorithmanddatastructures

Algorithm is expressed as a set of steps. By describing the actions at each step we instruct the computer do something. Usually we can use any natural language to describe the actions to perform at each step.

Consider this simple description.

  • 1. Enter one integer
    2. Enter another integer
    3. Compare both integers and return the maximum value
    4. Compare both integers and return the minimum value

In C++ programming language, on one hand, we can create generic functions to find the maximum or minimum value; and, on the other, we can take help from the ‘algorithm’ template library to find the same values.

Every high level language comes with its own algorithm library. They do so for one reason. Any system of counting or calculation by means of a device like computer involves following a steps or directions. Computer scientists use the word ‘algorithm’ to describe such as ‘set of directions’.

In some cases, these directions could be simple as described above. In most cases, it is much more complex. For complex cases, we need the help of ‘algorithm’ library. Otherwise, we have to do the low-level plumbing, which is much more time consuming and that takes us away from building other important parts of any application.

Historically, the derivation of this word has some interesting facts. At the beginning of ninth century an Arabian mathematician wrote a book called ‘Kitab al jabr w’al muqabala’ (Rules of Restoration and Reduction). The word ‘algebra’ comes from the title of the book. This textbook introduced the use of Hindu numerals and included a systematic discussion of fundamental operations on integers.

The word ‘algorithm’ comes from the name of the mathematician, Abu Ja’far Mohammed ibn Musa al-Khowarizmi.

One of the most famous and well known algorithms is of course Euclid’s Algorithm. It is a process for calculating the greatest common divisor (GCD) of two integers.
We can illustrate this algorithm in the following way.

  • 1. Take two integers x and y
    2. Divide y by x and get the remainder as r
    3. Now replace the value of x with the value of r and replace the value of y with the value of x
    4. Again divide y by x
    5. This process will continue until we get r = 0
    6. Once we get r = 0, stop the calculation, x is the GCD

Notice that the algorithm is expressed as a set of steps. Each step describes some action to take. The important thing is to describe the actions to be performed clearly and unambiguously.

Let us summarize this introductory part on algorithm in one sentence.
Data go inside the computer as inputs, algorithm takes charge, processing the data and after that the data as outputs come out.

By the way, people often mistake the word ‘data’ as singular; but, it is actually a plural form of the Latin word ‘datum’. Since we have used this word too often in our discourse, and will use in future, therefore, for the curious readers I opened up the Oxford dictionary and searched for the word: datum.

Oxford dictionary defines datum as “A thing given or granted; a thing known or assumed as a fact, and made the basis of reasoning or calculation; a fixed starting-point for a series of measurements etc.” It has also made it clear that the plural form of ‘datum’ is ‘data’.

For instance, in Java we have Collection class and in C++ we have containers that manage this data structure part. We are going to find out how they are related in the next post.

Composer and Effective PHP Patterns

object oriented design patterns in php
object oriented design patterns in php

Object Oriented Design Patterns in PHP 7

Gang of Four!

How about starting this discussion by quoting from them?

Their famous book “Design Patterns, Elements of Reusable Object-Oriented Software”; and they are Erich Gamma, Richard Helm, Ralph Johnson and

John Vlissides.

The book starts with this meaningful statement— “Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. You must find pertinent objects, factor them into classes at the right granularity, define class interfaces and inheritance hierarchies, and establish key relationships among them.

Your design should be specific to the problem at hand but also general enough to address future problems and requirements. You also want to avoid redesign, or at least minimize it. Experienced object-oriented designers will tell you that a reusable and flexible design is difficult if not impossible to get “right” the first time. Before a design is finished, they usually try to reuse it several times, modifying it each time.

Yet experienced object-oriented designers do make good designs. Meanwhile, new designers are overwhelmed by the options available and tend to fall back on non-object-oriented techniques they’ve used before. It takes a long time for novices to learn what good object-oriented design is all about. Experienced designers evidently know something inexperienced ones don’t. What is it?”

This introductory paragraph ends with a question mark.
Continue reading Composer and Effective PHP Patterns

How Composer has Revolutionized the PHP World

If you plan to design object-oriented software, it is hard, and, designing reusable object-oriented software is even harder. How can a dependency management system like Composer make this task easier? Let us try to understand that in this chapter. We will see more usages of Composer, as we read in the next chapters.
Composer’s role in Effective Patterns

I would like to start this section by quoting from the famous book “Design Patterns, Elements of Reusable Object-Oriented Software” by the “Gang of Four” Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides.

Continue reading How Composer has Revolutionized the PHP World

Reconfigure Apache2 server with PHP 7

To get Books of Sanjib Sinha…

To know more about Sanjib Sinha….

It’s a quite common problem that we face when we try to work around apache server and php.
Suppose you have just reconfigured your apache 2. Next you find that your php 7 script is not working any more with your php and no script is executed properly.
What will you do?

Open your linux terminal and type the following commands one after another. Usually
it works.

sudo apt-get install apache2 php7.0 libapache2-mod-php7.0

a2query -m php7.0

sudo a2enmod php7.0

sudo service apache2 restart

How to push your local Repository to github

To get Books of Sanjib Sinha…

To know more about Sanjib Sinha….

object-oriented-design-patterns-in-php7 for web
object-oriented-design-patterns-in-php7 for web

How to push your local Repository to github?
As usual I was too lazy to check it out. At last I decided to check it out in https://github.com/and a git-friend Stacey Burns sent me a step-by-step link. It finally worked.

I’m a Full-Time writer. If you find these articles helpful please consider buying any of my books.
You can buy from either Leanpub or
Amazon or from my publisher
Apress.

Actually I plan to write a book on Python programming language. A beginner’s like me would get help from that.
I want to keep all codes in a git repository so that everybody can download them.
I just want to share my experience.
First Step: create a repository in github. I created a repository ‘PlayWithPython’
Second Step: open your terminal and ‘cd’ to your ‘Project Folder’ that you have planned to push to your git repository. I have a folder called ‘PlayWithpython’ and write a sample python code called ‘first.py’ (this is for testing purpose)
Third Step: type – ‘git init’
// it will initialize your local repository
Fourth Step: type – ‘add .’
Fifth Step: type – ‘git commit -m “First Cmmit”‘
Sixth Step: type – ‘git remote add origin https://github.com/12reach/PlayWithPython.git’
Seventh Step: type – ‘git push -u origin master’
It is done. Now you can check your git repository.
I give the steps below.
I hope it helps.

root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# ls
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# nano first.py
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# ls
first.py
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# git init
Initialized empty Git repository in /home/ss/GIT/MyGitFirst/newrepo/PlayWithPython/.git/
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# git add .
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# git commit -m "First Cmmit"
[master (root-commit) 6022f14] First Cmmit
Committer: root
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

git config --global user.name "Your Name"
git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

1 file changed, 4 insertions(+)
create mode 100644 first.py
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# git remote add origin https://github.com/12reach/PlayWithPython.git
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# git push -u origin master
Username for 'https://github.com': 12reach
Password for 'https://12reach@github.com':
Counting objects: 3, done.
Writing objects: 100% (3/3), 254 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/12reach/PlayWithPython.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython#

Another More complete pull and push took place here:

hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git init
Initialized empty Git repository in /home/hagudu/PlayWithPython/.git/
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git add .
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git commit -m 'initial commit'
[master (root-commit) aee9b1c] initial commit
91 files changed, 3589 insertions(+)
create mode 100644 Databases/MyFirstSQLiteDB.db
create mode 100644 Databases/MySQLite1.py
create mode 100644 Databases/__pycache__/MySQLite1.cpython-34.pyc
create mode 100644 Databases/__pycache__/python_mysql_dbconfig.cpython-34.pyc
create mode 100644 Databases/config.ini
create mode 100644 Databases/database-test1.py
create mode 100644 Databases/mysqldb-test1.py
create mode 100644 Databases/mysqldb_test2.py
create mode 100644 Databases/python_mysql_dbconfig.py
create mode 100644 Databases/query_with_fetchall.py
create mode 100644 Databases/query_with_fetchmany.py
create mode 100644 Databases/retrieve_mysql_data.py
create mode 100644 Databases/test.db
create mode 100644 Databases/test1.db
create mode 100644 Debugging/MyFirstSQLiteDB.db
create mode 100644 Debugging/unittests.py
create mode 100644 FileIO/files.py
create mode 100644 FileIO/files.txt
create mode 100644 FileIO/new.txt
create mode 100644 General Syntax/assigining_values.py
create mode 100644 General Syntax/conditionals
create mode 100644 General Syntax/conditionals.py
create mode 100644 General Syntax/functions
create mode 100644 General Syntax/functions.py
create mode 100644 General Syntax/objects.py
create mode 100644 General Syntax/standard.py
create mode 100644 Loops/file.txt
create mode 100644 Loops/forloops.py
create mode 100644 Loops/while_loops.py
create mode 100644 MySQL_Connector/__pycache__/mysql_config.cpython-34.pyc
create mode 100644 MySQL_Connector/connection-test.py
create mode 100644 MySQL_Connector/deletes.py
create mode 100644 MySQL_Connector/inserts.py
create mode 100644 MySQL_Connector/mysql_config.ini
create mode 100644 MySQL_Connector/mysql_config.py
create mode 100644 MySQL_Connector/retrieve-blob.py
create mode 100644 MySQL_Connector/retrieve.py
create mode 100644 MySQL_Connector/retrieve_by_dbconfig.py
create mode 100644 MySQL_Connector/update-blob.py
create mode 100644 MySQL_Connector/updates.py
create mode 100644 README.md
create mode 100644 Variables, Objects and Values/ListsTuples.py
create mode 100644 Variables, Objects and Values/dictionaries.py
create mode 100644 Variables, Objects and Values/numbers.py
create mode 100644 Variables, Objects and Values/strings.py
create mode 100644 Variables, Objects and Values/understanding_basics.py
create mode 100644 classes/class-and-objects.py
create mode 100644 classes/compositions.py
create mode 100644 classes/decorators.py
create mode 100644 classes/fish.py
create mode 100644 classes/generators.py
create mode 100644 classes/inheritances.py
create mode 100644 classes/methods.py
create mode 100644 classes/object-data.py
create mode 100644 classes/object-dictionary.py
create mode 100644 classes/polymorphisms.py
create mode 100644 classes/primary-class-object.py
create mode 100644 containers/sequences.py
create mode 100644 exceptions/exceptions.py
create mode 100644 exceptions/generator_functions.py
create mode 100644 functions/defining_functions.py
create mode 100644 functions/generate-functions.py
create mode 100644 functions/listsofarguments.py
create mode 100644 functions/named-arguments.py
create mode 100644 functions/return-values.py
create mode 100644 modules/__pycache__/modules.cpython-34.pyc
create mode 100644 modules/modules.py
create mode 100644 primary/assigning_values.py
create mode 100644 primary/bitwise.py
create mode 100644 primary/conditionals.py
create mode 100644 primary/exceptions.py
create mode 100644 primary/file.txt
create mode 100644 primary/functions.py
create mode 100644 primary/main_script.py
create mode 100644 primary/object_variable.py
create mode 100644 primary/objects.py
create mode 100644 primary/regx.py
create mode 100644 primary/whitespaces.py
create mode 100644 regular expressions/reg
create mode 100644 regular expressions/regreplace.py
create mode 100644 regular expressions/regsearch.py
create mode 100644 regular expressions/reusereg.py
create mode 100644 strings/search.py
create mode 100644 strings/strings.txt
create mode 100644 strings/test.py
create mode 100644 test.py
create mode 100644 tests/boymeetsagirl.py
create mode 100644 tests/grtThingsDone.py
create mode 100644 tests/loops.py
create mode 100644 tests/recursion.py
create mode 100644 tests/test.py
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git remote add origin https://github.com/12reach/PlayWithPython.git
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git commit -m 'initial commit'
On branch master
nothing to commit, working directory clean
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git push origin master
Username for 'https://github.com': 12reach
Password for 'https://12reach@github.com':
To https://github.com/12reach/PlayWithPython.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/12reach/PlayWithPython.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git pull origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/12reach/PlayWithPython
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
Merge made by the 'recursive' strategy.
first.py | 4 ++++
1 file changed, 4 insertions(+)
create mode 100644 first.py
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git push origin master
Username for 'https://github.com': 12reach
Password for 'https://12reach@github.com':
Counting objects: 114, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (110/110), done.
Writing objects: 100% (113/113), 35.01 KiB | 0 bytes/s, done.
Total 113 (delta 6), reused 0 (delta 0)
To https://github.com/12reach/PlayWithPython.git
6022f14..a6f48b2 master -> master
hagudu@hagudu-H81M-S1:~/PlayWithPython$

Since you here…

I’m a professional writer. I do nothing; I only write books.
If you find this post helpful please consider buying any of my books. You can buy from either Leanpub or amazon.
If you live outside the USA, it is good to buy from Leanpub.
Let me explain why. I don’t get my royalty of outside-USA-sale on Amazon. So please consider that aspect.
Maybe you are not in the mood to buy my book. In such case, you can send any amount as a ‘token of appreciation’ through Paypal.
My Paypal username-email is sanjib12sinha@gmail.com.