22 December, 2020

Flutter Commands List

 

Command to check flutter version:

D:\>flutter --version

Output:

Flutter 1.20.4 • channel unknown • unknown source

Framework • revision fba99f6cf9 (3 months ago) • 2020-09-14 15:32:52 -0700

Engine • revision d1bc06f032

Tools • Dart 2.9.2


 To generate an app bundle, run:

        flutter build appbundle --target-platform android-arm,android-arm64,android-x64

        Learn more on: 

    To split the APKs per ABI, run:

        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi

        Learn more on:  

Resolve Conflicts: 

flutter packages pub run build_runner watch --delete-conflicting-outputs

Here is some useful command List:  run flutter help <command>  to get command related information

Command Name

Example

Comments

analyze

flutter analyze -d <DEVICE_ID>

Analyzes the project’s Dart source code.

Use instead of dartanalyzer.

assemble

flutter assemble -o <DIRECTORY>

Assemble and build flutter resources.

attach

flutter attach -d <DEVICE_ID>

Attach to a running application.

bash-completion

flutter bash-completion

Output command line shell completion setup scripts.

build

flutter build <DIRECTORY>

Flutter build commands.

channel

flutter channel <CHANNEL_NAME>

List or switch flutter channels.

config

flutter config --build-dir=<DIRECTORY>

Configure Flutter settings. To remove a setting, configure it to an empty string.

create

flutter create <DIRECTORY>

Creates a new project.

devices

flutter devices -d <DEVICE_ID>

List all connected devices.

doctor

flutter doctor

Show information about the installed tooling.

downgrade

flutter downgrade

Downgrade Flutter to the last active version for the current channel.

drive

flutter drive

Runs Flutter Driver tests for the current project.

emulators

flutter emulators

List, launch and create emulators.

format

flutter format <DART_FILE>

Format one or more dart files.

gen-l10n

flutter gen-l10n <DIRECTORY>

Generate localizations for the Flutter project.

install

flutter install -d <DEVICE_ID>

Install a Flutter app on an attached device.

logs

flutter logs

Show log output for running Flutter apps.

format

flutter format <DIRECTORY|DART_FILE>

Formats Flutter source code.

Use instead of dartfmt.

precache

flutter precache <ARGUMENTS>

Populates the Flutter tool’s cache of binary artifacts.

pub

flutter pub <PUB_COMMAND>

Works with packages.

Use instead of pub.

run

flutter run <DART_FILE>

Runs a Flutter program.

symbolize

flutter symbolize --input=<STACK_TRACK_FILE>

Symbolize a stack trace from the AOT compiled flutter application.

test

flutter test [<DIRECTORY|DART_FILE>]

Runs tests in this package.

Use instead of pub run test.

upgrade

flutter upgrade

Upgrade your copy of Flutter.


20 December, 2020

Flutter run time based jobs - Background Job

 

Run time based job in flutter

Time based job are useful when you want to do job work in background upon on some time interval or even once without letting user know.

There is two easiest way to accomplish it.

  1. Timer
  2. Corn

Timer Class: 

A count-down timer that can be configured to fire once or repeatedly.


    Timer _timer;

    _callBack(Timer t) {
    {
      _doMyWork();
      print("timer called");
      t.cancel(); // canceled the time on 1st call only, execute only once
    }

  @override
  void initState() {
    super.initState();
    _timer = Timer.periodic(Duration(minutes: 1), _callBack);
  }

  @override
  void dispose() {
    if (_timer.isActive) _timer.cancel();
    super.dispose();
  }


Corn Lib: 

Use Cron lib which will be run tasks periodically at fixed times or intervals. It's used for more complex time intervals, eg: if a task needs to be run on a specific time of an hour. let's see the diagram


The above diagram has an asterisk that represents a number that appears in a specific position.

import 'package:cron/cron.dart';

main() {
  var cron = new Cron();
  cron.schedule(new Schedule.parse('*/1 * * * *'), () async {
    print('every minutes');
  });
  cron.schedule(new Schedule.parse('10-15 * * * *'), () async {
    print('between every 10 and 15 minutes');
  });
}

 first '*' represents minutes, similar for the hour and so on as shown in the diagram.

Another example of the hour would be Schedule.parse(* 1,2,3,4 * * *), This schedule will run every minute every day during the hours of 1 AM, 2 AM, 3 AM, and 4 AM.

for more reference wiki/Cron



Bonus Point(Built-in Commands)

The build_runner package exposes a binary by the same name, which can be invoked using pub run build_runner <command>

--delete-conflicting-outputs: Assume conflicting outputs in the users package are from previous builds, and skip the user prompt that would usually be provided.

Example:

flutter packages pub run build_runner watch --delete-conflicting-outputs 


Other Flutter related link:

Flutter: INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.example.app signatures do not match previously installed version; ignoring


Flutter Error:


Launching lib\main.dart on Nokia 4 2 in debug mode...
lib\main.dart:1
✓ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Error: ADB exited with exit code 1
Performing Streamed Install

adb: failed to install D:\app\outputs\flutter-apk\app.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.example.app signatures do not match previously installed version; ignoring!]
Error launching application on Nokia 4 2.

Solution 1:

You need to uninstall it because you are using a different signature than the original. If it is not working it might be because it is still installed for another user on the device. To completely uninstall, go to Settings -> Apps -> yourApp -> Options (the three dots on top right) -> Uninstall for all users


Solution 2:  run follwoing command that will solve   your problem

  • adb uninstall "yourApp"
  • example: adb uninstall "com.example.myapp"

18 December, 2020

Which Azure service would you deploy to detect a sudden spike in network traffic?

 

  • Which Azure service would you deploy to detect a sudden spike in network traffic?
  • Network Performance Monitor solution:

Network Performance Monitor is a cloud-based hybrid network monitoring solution that provide capabilities to  monitor network performance between various points in your network infrastructure.

You can leverage this service to:

  • Monitor network connectivity to service and application endpoints
  • Monitor the performance of Azure ExpressRoute.

 

Network Performance Monitor offers three broad capabilities:

  1. Performance Monitor
  2. Service Connectivity Monitor
  3. ExpressRoute Monitor

 

You can easily detect these kinds of issues by looking at a trend chart. The issue appears as a sudden spike in network latency or packet loss. To investigate the issue, use the Network State Recorder control to view the network snapshot and topology for that point in time when the issue occurred.

 

https://docs.microsoft.com/en-in/azure/azure-monitor/insights/network-performance-monitor#trend-charts

Credit: MSDN  Trend Chart

Add Solution to monitor your Work space:

Add the Network Performance Monitor solution to your workspace from the Azure marketplace. You also can use the process described in Add Azure Monitor solutions from the Solutions Gallery.

 You can visit MSDN for more details.

Flutter: OS Error: Connection reset by peer, errno = 104

 

Some time developers face issue this issue  in development mode there could anything that cause this issue

Flutter Error:

SocketException: OS Error: Connection reset by peer, errno = 104

Reason 

It may be your ISP blocking the connection

Flutter corrupted build package etc..

Solutions 1:

To solve this issue run the following commands

  • Step 1: flutter clean 
  • Step 2: flutter pub cache repair
  • Solutions 2:

    • Use different VPN
    • or Connect with your internet service provider to unblock respective URL

    Flutter Error: 

    some developer face this issue running in debug mode

    Write error: ssl=0x709bd56fc8: I/O error during system call, Connection reset by peer

    Solutions 1:

    To solve this issue run the following commands

  • Step 1: flutter clean 

  • For example:

    D:\Mobile\myApp>flutter clean Deleting build... 4,739ms (!) Deleting .dart_tool... 13ms Deleting Generated.xcconfig... 5ms Deleting flutter_export_environment.sh... 7ms 

    16 December, 2020

    What Is Flutter?

     What Is Flutter?

     Google Flutter is an open-source UI software development kit. It facilitated to develop applications for Android, iOS, Linux, Mac, Windows, Google Fuchsia, and the web from a single codebase. 

    The major components of Flutter:

    • Dart platform
    • Flutter engine
    • Foundation library
    • Design-specific widgets

     Flutter has good documentation along with great guidelines, from here you can setup flutter development env.

    What is Dart?

    Dart is a programming language for cross platforms apps. It is getting popular and can be used to build mobile, desktop, server, and web applications. Dart is an object-oriented, class-based, garbage-collected language with C-style syntax. Dart can compile to either native code or JavaScript. 

    Dart platform 

    Flutter apps are written and developed in the Dart language. On Windows, macOS, and Linux Flutter runs in the Dart virtual machine, which features a just-in-time execution engine. While writing and debugging an app, Flutter uses Just In Time compilation, allowing for "hot reload", Hot Refresh, with which modifications to source files can be injected into a running application. Flutter extends this with support for stateful hot reload, where in most cases changes to source code are reflected immediately in the running app without requiring a restart or any loss of state 

    Flutter App: a release versions of Flutter apps are compiled with ahead-of-time (AOT) compilation on both Android and iOS so it makes Flutter's high performance on mobile devices possible.

    fig: flutter running in vs code

    vscode: hot reload tool bar


    Flutter engine

    Flutter's engine, provides low-level rendering support using Google's Skia graphics library. Skia is an open source 2D graphics library which provides common APIs that work across a variety of hardware and software platforms. Additionally, it interfaces with platform-specific SDKs such as those provided by Android and iOS.

    Foundation library

    The Flutter Foundation library is written in Dart, provides basic classes and functions that are used to construct applications using Flutter, such as APIs to communicate across the system and underlying services.

     

    Design-specific widgets /Flutter widgets

    In Flutter everything(on UI/user interface/looks and feels) are a  widgets and actually its reusable component like react if you familiar . The central idea is that you build your UI out of widgets.

    The Flutter framework contains two sets of widgets that conform to specific design languages: Material Design widgets implement Google's design language of the same name.

     Cupertino (iOS-style) widgets: implement Apple's iOS Human interface guidelines

    Flutter Code Example: HelloWorld App

    import 'package:flutter/material.dart';

    void main() {
      runApp(
        Center(
          child: Text(
            'Hello, world!',
            textDirection: TextDirection.ltr,
          ),
        ),
      );
    }


    even you can practice and learn more without flutter setup on local machine on flutter studio app , its online flutter coding practice tool free.


    What is Next?

    • get flutter or Setup Flutter Development Environment on Local Machine
    • flutter - development ideas
    • google flutter : including more around dart
    • flutter web/flutter for webs : run flutter app on web/browser
    • flutter github: you can find flutter codebase here
    • flutter widgets: knowledge sharing around important widgets
    • flutter block
    • flutter docs : Here more to read
    • flutter firestore : using google firestore in flutter
    • flutter for linux/flutter linux : knowledge sharing around 
    • flutter awesome: how to use beautiful eye catchy  icons in flutter
    • flutter windows: requirement and setup details for window platform
    • flutter in android studio/flutter android studio: flutter development using android studio



    10 December, 2020

    'ng' is not recognized as an internal or external command,

     

    Error: 'ng' is not recognized as an internal or external command



    Reason for the issue is:

    1. Either Env variable is not setup properly
    2. or  angular cli is not installed globally so 

    Solutions:

    1. open command prompt, press (ctr + r) and type cmd
    2.  run this command "npm install -g @angular/cli"
    3. and all set for you to just verify go to cmd and type "ng" you will get all the details as the problem has be solved.



    28 August, 2020

    Keystore file does not exist

    The following steps are required to solve this problem.

    Error: keytool error: java.lang.Exception: Keystore file does not exist: path-to-debug-or-production-keystore


    • open command-line tool - WINDOW+R
    • go to C:\Program Files\Java\jdk1.8.0_261 (or your java version)


    And run below command

    keytool -exportcert -alias androiddebugkey -keystore C:\Users\{your.username}\.android\debug.keystore -list -v


    Note* to use C:\Users\{your.username}\.android\debug.keystore instead of ~/.android\debug.keystore. I still got the error when type this shorten way.


    cmd

    Microservices vs Monolithic Architecture

     Microservices vs Monolithic Architecture Here’s a clear side-by-side comparison between Microservices and Monolithic architectures — fro...