Skip to main content

Posts

How to create dynamic grids in flutter app

Recent posts

How to create the static grid in flutter app

Grid is a layout design system to show items in a list.
Today we will learn that how can we create grid in any flutter app.
So Grid is just like a box that can be same size or different.
Lets check the example -
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Grid Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(title: 'FLutter Grid'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.tit…

How to change app theme in flutter

Theme is the basic need of any mobile app. This is the basically a color combination of app arguments like Status bar color, Nav bar color, Menu Color, Buttons color etc...
These all things have same color combination in each other.

Now the question is, How to change the theme in Flutter?
Actually changing the theme in Flutter is very easy. Flutter library makes the theme change process is very normal.
Suppose we have a basic app and we need to change the theme.
Let show this in example-



This is the demo script of a Flutter app.
When you will execute this code, this will show this screen -

Now we learn, how to change theme of this demo app.

Change the color name at line no 21 from  primarySwatch: Colors.blue, to  primarySwatch: Colors.green, and you the output is -



Change the color name at line no 21 from  primarySwatch: Colors.blue, to  primarySwatch: Colors.red, and you the output is -




How to setup Flutter starter app

Flutter is an awesome framework for develop native iOS and Android app from a single code.

Flutter installation: First of all, You need to download Flutter SDK for your system.
Choose your operating system and download it in your directory.
Set $PATH variable by directory of your flutter library in your environment variable (On Windows) and in .bash_profile (ON Mac & Linux).
After setting $PATH,  your terminal is ready to execute flutter commands.
Follow the simple steps to setup and enjoy your Flutter.
 Create First APP:
       Let's get start the flutter development ( You are familiar with command line interface )-
$ flutter create awesome_app
$ cd awesome_app
$ flutter devices
$ flutter run

How to print pretty json in python

Json is the data set which contain key and value pair.

Example:
json_string = ["foo", {"bar":["baz", null, 1.0, 2]}]

print (json_string)

output: ["foo", {"bar":["baz", null, 1.0, 2]}]

print (json.dumps(chain, indent=4, sort_keys=True))output: ["foo", { "bar": [ "baz", null, 1.0, 2] } ]

How to get thumbnails of youtube videos?

You can try for different types of YouTube videos thumbnails by using these urls -
For the default & normal quality thumbnail:

http://img.youtube.com/vi/<youtube-video-id>/default.jpg
For the high quality (HQ) thumbnail:
http://img.youtube.com/vi/<youtube-video-id>/hqdefault.jpg
There is also a medium quality thumbnail:
http://img.youtube.com/vi/<youtube-video-id>/mqdefault.jpg
For the maximum resolution thumbnail:
http://img.youtube.com/vi/<youtube-video-id>/maxresdefault.jpg

For eg .
YouTube link - http://www.youtube.com/watch?v=4EvNxWhskf8YouTube video id -4EvNxWhskf8
So that -
<imgsrc="http://img.youtube.com/vi/4EvNxWhskf8/hqdefault.jpg"title="YouTube Video"alt="YouTube Video"/>

Send POST file using Curl in PHP

Curl is the most powerful Http Client. We can send any request using curl.
Today we will discuss about send a file with curl in PHP.


We will discuss to send file from our directory and also from a form.

File from directory
$this->fields = array( "file" => curl_file_create('file/path/image.png', 'image/jpeg', 'file_name') ); $http = curl_init(); curl_setopt($http, CURLOPT_URL, "example.com"); curl_setopt($http, CURLOPT_POST, true); curl_setopt($http, CURLOPT_POSTFIELDS, $this->fields); curl_setopt($http, CURLOPT_RETURNTRANSFER, true); curl_exec($http);

File from Form
$this->fields = array( "file" => curl_file_create($_FILES['file']['tmp_name'], $_FILES['file']['type'], $_FILES['file']['name']) ); $http = curl_init(); curl_setopt($http, CURLOPT_URL, "ex…