Thursday, May 28, 2020

How to make your app responsive according to screen size in Flutter

Step 1 : You can use below code to take your screen width & height

    double width = MediaQuery.of(context).size.width;
    double height = MediaQuery.of(context).size.height;

Step 2 : from those variable you can give your widget width and height 

Refer the full code, here container have made according to screen size 


import 'package:flutter/material.dart';

void main() {
  runApp(app());
}

class app extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    double widthVar = MediaQuery.of(context).size.width;
    double heightVar = MediaQuery.of(context).size.height;
    return Scaffold(
      appBar: AppBar(
        title: Text('Title A'),
      ),
      body: Center(
        child: Container(
          width: widthVar * 0.40,
          height: heightVar * 0.08,
          color: Colors.blue,
        ),
      ),
    );
  }
}

Create variable and pass data in Flutter



Step 1 : Have to declare the variable in create the constructor. 

class MyHomePage extends StatelessWidget {
  final String title;
  final String bodyText;
  MyHomePage({Key key, this.title, this.bodyText}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
      ),
      body: Center(
          child: Text(
        bodyText,
      )),
    );
  }
}


Step 2: Calling & pass the data


class app extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(
        title: 'sample title',
        bodyText: 'this is the body',
      ),
    );
  }
}


Check out the full code

import 'package:flutter/material.dart';

void main() {
  runApp(app());
}

class app extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(
        title: 'sample title',
        bodyText: 'this is the body',
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String title;
  final String bodyText;
  MyHomePage({Key key, this.title, this.bodyText}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(this.title),
      ),
      body: Center(
          child: Text(
        bodyText,
      )),
    );
  }
}

Sunday, May 17, 2020

Import bookmarks and other data from Google Chrome

Step 1 - Click the menu button fx57menu then click Library 57 library icon Click Bookmarks and then click the Show All Bookmarks bar at the bottom.




Step 2 - Click Import and Backup and choose Import Data from Another Browser




Step 3 - Choose chrome and click next.



Step 4 - Select the item and click next.


Step 5 - Click on finish.

Saturday, May 16, 2020

How configure firestore with your flutter application ?


Step 1 -  Go to https://console.firebase.google.com/ 

Step 2 - Click on add project



Step 3 - Click add Firebase to your Android app



Step 4 - fill the android package name and click register



Step 5 - Download config file & put it inside '\android\app'



Step 6 - Go to '\android' location and open 'build.gradle' add this line inside the dependencies

classpath 'com.google.gms:google-services:4.3.3'

 
Step 7 - Get into app 'build.gradle' and go to end 

If this line is already there do not add again.

add this line apply plugin: 'com.android.application'

apply plugin: 'com.google.gms.google-services'
 
Inside the dependencies

dependencies {
  implementation 'com.google.firebase:firebase-analytics:17.2.2'
}

Step 8 - go to pubspec.yaml

add this below dependency
 cloud_firestore^0.13.5 





Note - If you face any problem, Try this Open project/app/build.gradle and add the following lines.

defaultConfig {
    ...

    multiDexEnabled true
}

and

dependencies {
    ...

    implementation 'com.android.support:multidex:1.0.3' 
} 

How to change the flutter package name?


Android


Step 1 - Go to android\app\src\main location and find the 'AndroidManifest' file 
change the package name with new name.

package="com.example.newsapp">  

Step 2 - Go to \android\app location and open build.gradle file where you have to find the 'applicationId' change with new name.

applicationId "com.example.newsapp"


iOS


Step 1 - Go to \ios\Runner location and open the 'infor.plist' find this below line 

<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>

change it with your new package name

<string>$com.example.newsapp</string>

How to make your app responsive according to screen size in Flutter

Step 1 : You can use below code to take your screen width & height      double  width =  MediaQuery . of (context).size.width;      doub...