Wednesday 30 June 2021

Flutter Tip : Included Only classes in the project instead of all dart classes.

  1 comment

We normally depend on the third-party libraries' APIs and this has happened with each programming language. 

So, In Flutter, For example, you want to check on which platform the application is running then for this need to import the dart:io library and Its lots of classes in its packages. But we need access to ProcessInfo.dart class methods only and to do this, We need to use the show keyword while importing the library.  It will only include this class and discard all other classes present in the library. Furthermore, you can check this link for a better understanding 


Method 1 : It will include all the classes present in the library. 

import 'dart:io';

Method 2: It will include only the classes which we need. 

import 'dart:io' show ProcessInfo;

Apart from the above, We also have other keywords as well and which are very helpful. 👍 Such as hide and as.

import 'dart:io' hide ProcessInfo; //It will hide ProcessInfo classe from the io package.

import 'dart:io' as AnyName; //It will rename the io package name to AnyName, Then you can access this packages classes method by using AnyName.(Enter method name)





1 comment :

  1. Best online casino without download - deccasino
    No matter what mode of gambling you choose, it is a great option งานออนไลน์ to be able to gamble 메리트카지노 at your favorite online casino without downloading any febcasino file.

    ReplyDelete

Loading...