当前位置:网站首页>Flutter Utils

Flutter Utils

2022-06-23 22:22:00 Is paidaxing there

00.1 Summary of tool classes in this library

Tool class

Functional specifications

EventBusService

bus Event notification tool class , Subscriber mode is implemented . For communication between components

CalculateUtils

Calculates the width of the text , high

ColorUtils

Mainly is to RGB/ARGB Turn into 16 Hexadecimal string color or Color

DateFormats

Common Chinese , English date and time conversion format . Contains the vast majority of date formats

DateUtils

Date tool class , Get date time , Conversion between various times

EncryptUtils

Encryption and decryption tool class , Mainly md5 encryption ,base64 Encryption and decryption , XOR encryption and decryption, etc

ExtensionXxx

Expansion , contain int,list,map,set,num,string Other extension classes , There are most common methods of operation

TransformUtils

Transformation tool class , contain int,string Convert to binary , Letter case conversion, etc

ValidatorUtils

Verification tools , Contains common types , picture ,url, mailbox , Telephone , Resource file , Hump naming and other verification

ExtensionXxx

Expansion , contain int,list,map,set,num,string Other extension classes , There are most common methods of operation

TransformUtils

Transformation tool class , contain int,string Convert to binary , Letter case conversion, etc

FileUtils

File cache class , It mainly stores and obtains strings ,Map,Json Data such as , Write locally file file

TransformUtils

Transformation tool class , contain int,string Convert to binary , Letter case conversion, etc

AppLocalizations

i18 relevant , You can set locale, Get string in language

ImageUtils

Picture tool class , Mainly responsible for pictures and base64 conversion , Load network pictures , Toggle fillet , Round, etc

JsonUtils

json Transformation tool class , Mainly responsible for list,map, Objects and json Conversion between

get_it

spi Interface implementation , Interface ( Abstract base class ) Separate and decouple from the specific implementation

LogUtils

Log tool class , Set log switch , length , And you can filter labels , Print 5 Types of logs

NumUtils

Num Format tool class , Mainly responsible for num Related processing and conversion operations

ObjectUtils

Object Superclass tool class , Be responsible for the judgment of various objects , Get length and other operations

RegexConstants

Regular constants of common regular expressions , This part mainly refers to AndroidUtils

RegexUtils

Regular expression tool class , Mainly by telephone , Id card , mailbox ,ip, Network etc. verification

ScreenUtils

Screen tools , Get the width and height of the screen , And pixel density ratio

SpUtils

sp Storage tool class , Suitable for storing lightweight data , Storage is not recommended json Long string

TextUtils

Text tool class , Mainly deals with string abbreviations ,*, Compare , Remove and so on

TimerUtils

Countdown timer tool class , Set total countdown time , Time interval between , Start pause, etc

UrlUtils

url Tool class , obtain url Of host, Parameters , Verification and other operations

SystemUtils

System tool class , Copy content to clipboard , Pop up and close the soft keyboard , Clear data, etc

OtherUtils

RandomUtils Random tools ,SnackUtils,PlatformUtils Platform tool class

MVP

Flutter Version of MVP Architecture template , To be perfected ……

00.2 How to use this library

  • Specific documents can be demo

01. Event notification bus Tool class

  • Event bus
    • Subscriber mode is usually implemented , The subscriber pattern includes two roles: publisher and subscriber .
  • The first way : Use map Collective storage key For events eventName,value by EventCallback Realization bus
    // Register to listen bus
_subscription = EventBusService.instance.eventBus.on<EventMessage>().listen((event) {
      String name = event.eventName;
      // The switching between front and rear stations has changed 
      if (name == "eventBus1") {
        var busMessage = event.arguments["busMessage"];
        setState(() {
          message1 = busMessage;
        });
      }
    });
// Send a message 
EventBusService.instance.eventBus.fire(EventMessage(
  "eventBus1",
  arguments: {"busMessage": " send out bus news 1"},
));
// Page destroy clear bus
if (_subscription != null) {
  _subscription.cancel();
  _subscription = null;
}
  • The second way : Use StreamController Realization bus Event notification
    // Register listening messages 
bus.on("eventBus2", (arg) {
  var busMessage = arg;
  setState(() {
    message2 = " receive messages :" + busMessage;
  });
});
// Send a message 
var arg = " send out bus news 1";
bus.emit("eventBus2", arg);
// Remove message 
bus.off("eventBus2", (arg) {
});

02. Color Color Tool class

  • Color Color Tool class . Mainly is to RGB perhaps ARGB Convert color to Color object ,16 Hexadecimal color string, etc .
    hexToColor                               :  take #A357D6 Convert color to 16 It's binary Color
toColor                                  :  take #FF6325 Color or #50A357D6 Turn into 16 It's binary Color
colorString                              :  take color Convert color to string 
colorString                              :  Check whether the string is hexadecimal 

03. Date conversion tool class

  • Date conversion tool class . Mainly to get the current date , Format the time in the specified format , And a variety of date formatting tools and methods
    getNowDateTime                           :  Get current date return DateTime
getYesterday                             :  Get yesterday's date return DateTime
getNowUtcDateTime                        :  Get current date return DateTime(utc)
getNowDateTimeFormat                     :  Get current date , Returns the specified format 
getUtcDateTimeFormat                     :  Get current date , Returns the specified format 
isYesterday                              :  Judge whether it was yesterday according to the time 
getNowDateMs                             :  take # Gets the current millisecond value , return int
getNowDateString                         :  Get current date string , The default is :yyyy-MM-dd HH:mm:ss, Return string 
formatDate                               :  Format time , The first field is dateTime, The second option represents the format 
formatDateString                         :  Format date string , First field, for example :'2021-07-18 16:03:10', The second field, for example :"yyyy/M/d HH:mm:ss"
formatDateMilliseconds                   :  Format date millisecond time , First field, for example :1213423143312, The second field, for example :"yyyy/M/d HH:mm:ss"
getWeekday                               :  obtain dateTime What day is 
getWeekdayByMilliseconds                 :  Get the millisecond value corresponding to the day of the week 
isToday                                  :  Determine whether it is today according to the timestamp 
isYesterday                              :  Judge whether it was yesterday according to the time 

04.File File tool class

4.1 File storage utility class

  • File storage utility class . Mainly storage and acquisition String,Json Wait for the documents , This is stored in file Local files
    getTempDir                               :  Get a temporary directory ( cache ), The system can be cleared at any time 
getAppDocDir                             :  Gets the directory of the application , Used to store files that only it can access . Only when the application is deleted , The system will clear the directory .
getAppFile                               :  Initialization file path , By default, the directory of the selected application 
readStringDir                            :  Gets the data that exists in the file , Read the directory of the application by default 
writeJsonFileDir                         :  write in json file , Write to the directory of the application by default 
writeStringDir                           :  Using files to store strings , Write to the directory of the application by default 
clearFileDataDir                         :  Clear cached data 
deleteFileDataDir                        :  Delete cache file 
writeJsonCustomFile                      :  write in json file , Custom path 
writeStringFile                          :  Using files to store strings , Custom path 
readStringCustomFile                     :  Get the data stored in the custom path file 

4.2 Document management tools

  • Document management tools . Mainly create different directory paths , create a file , Or directory path .
    getTempPath                              :  Get the path to the temporary directory on the device , The directory is not backed up , A cache suitable for storing downloaded files .
getAppDocPath                            :  Gets the directory of the application , Used to store files that only it can access . Only when the application is deleted , The system will clear the directory .
getStoragePath                           :  The path to the directory where the application can access the top-level storage 
createDirSync                            :  Create files asynchronously 
createDir                                :  Create files synchronously 
createTempDir                            :  Create temporary directory 
createAppDocDir                          :  Create a directory to get applications 

05.Sql Database tool class

  • To be improved

06.Json Transformation tool class

  • Json Transformation tool class .json Convert common operations , Gradually improve list,map and json String conversion, etc .
    printJson                                :  pure Json Format output print 
printJsonEncode                          :  pure Json Format output print 
encodeObj                                :  Put the object [ value ] Convert to JSON character string 
getObj                                   :  transformation JSON String to object 
getObject                                :  transformation JSON String or JSON mapping [ Source ] To the object 
getObjList                               :  transformation JSON String list [ Source ] To object list 
getObjectList                            :  transformation JSON String or JSON Mapping list [ Source ] To object list 

07.Log Log printing tool class

  • Log Log printing tool class . Five different types of logs , You can also add tag Tag filtering .
    init                                     :  Initialize log , Customize tag, Whether it is debug Environmental Science , Maximum log length , These fields are not required 
d                                        :  Print debug journal 
e                                        :  Print error journal 
v                                        :  Print v journal 
i                                        :  Print info journal 
w                                        :  Print ware Warning log 

08. Screen parameter tool class

  • Screen parameter tool class . Get the width of the screen , high , Pixel density , Properties such as status bar . Improvement and adaptation in the later stage ……
    screenWidthDp                            :  Current device width  dp
screenHeightDp                           :  Current device height  dp
pixelRatio                               :  Pixel density of the device 
screenWidth                              :  Current device width  px = dp *  density 
screenHeight                             :  Current device height  px = dp *  density 
statusBarHeight                          :  Status bar height  dp  Liu Haiping will be higher 
bottomBarHeight                          :  Bottom safety zone distance  dp
textScaleFactory                         :  Number of font pixels per pixel , Font scaling 

09.Sp Lightweight storage tools

  • sp Lightweight storage tools . Mainly sp Store and get int,String,list,map And so on .
    init                                     :  initialization , You have to initialize 
hasKey                                   :  Judge whether it exists key The data of 
putObject                                :  Storage object Type data 
getObject                                :  obtain sp in key Of map data 
putObjectList                            :  Storage sp in key Of list aggregate 
getObjectList                            :  obtain sp in key Of list aggregate 
getString                                :  obtain sp in key String 
putString                                :  Storage sp in key String 
getBool                                  :  obtain sp in key Boolean value 
putBool                                  :  Storage sp in key Boolean value 
getInt                                   :  obtain sp in key Of int value 
putInt                                   :  Storage sp in key Of int value 
getDouble                                :  obtain sp in key Of double value 
putDouble                                :  Storage sp in key Of double value 
getStringList                            :  obtain sp in key Of list<String> value 
putStringList                            :  Storage sp in key Of list<String> value 
getStringMap                             :  obtain sp in key Of map value 
putStringMap                             :  Storage sp in key Of map value 
getDynamic                               :  obtain sp in key Of dynamic value 
getKeys                                  :  obtain sp All of the key
remove                                   :  remove sp in key Value 
clear                                    :  eliminate sp
isInitialized                            :  Check initialization 
forEach                                  :  Traversal print sp Of key and value

11. Encryption and decryption tool class

  • Encryption and decryption tool class . At present, we support base64 encryption ,md5 encryption . Later, gradually improve more encryption methods ……
    encodeMd5                                : md5  Encrypted string , This is irreversible 
encodeBase64                             : Base64 Encrypted string 
decodeBase64                             : Base64 Decrypt string 
xorBase64Encode                          :  XOR symmetry  Base64  encryption 
xorBase64Decode                          :  XOR symmetry  Base64  Decrypt 

12.Num Format processing tool class

  • Format processing tool class . Mainly dealing with num Format conversion related operations .
    isNum                                    :  The check string is int still double
getIntByValueString                      :  Convert numeric string to int. If the string is not a number , It's translated into 0
getDoubleByValueString                   :  Number string to double. If the string is not a number , It's translated into 0
getNumByValueString                      :  Convert numeric string to num, Number retention x Decimal place 
getNumByValueDouble                      :  Floating point number retention x Decimal place 
addNum                                   :  Add two numbers ( Prevent loss of accuracy )
subtractNum                              :  Subtract two numbers ( Prevent loss of accuracy )
multiplyNum                              :  Multiplication of two numbers ( Prevent loss of accuracy )
divideNum                                :  Divide two numbers ( Prevent loss of accuracy )
addDecString                             :  Add two numbers ( Prevent loss of accuracy )
subtractDecString                        :  Subtract two numbers ( Prevent loss of accuracy )
multiplyDecString                        :  Multiplication of two numbers ( Prevent loss of accuracy )
divideDecString                          :  Divide two numbers ( Prevent loss of accuracy )

14. Image processing tool class

  • Others to be improved , Supplementary fillet , Circular cutting picture , And how to deal with local images . Later, improve the image properties , Picture compression , Various tangent angle methods .
    base64ToImage                            :  take base64 Convert stream to picture 
fileToBase64                             :  The picture file Turn into base64
networkImageToBase64                     :  Convert web link pictures to base64
assetImageToBase64                       :  take asset The picture is translated into base64
showNetImageWh                           :  Load network pictures , And specify the width and height size . Use default preload loading And error view 
showNetImageWhError                      :  Load network pictures , And specify the width and height size . Incoming error view 
showNetImageWhPlaceError                 :  Load network pictures , And specify the width and height size . Incoming preload , Wrong view 
showNetImageWhClip                       :  Load network pictures , And specify the width and height size , Cut the fillet 
showNetImageCircle                       :  Load network pictures , Cut round picture 

15. Network processing tools

15.1 Network request tool class

15.2 Url Parsing tool class

  • Handle url Parsing related tool classes
    containsTarget                           :  Judge url Does the link contain parameters 
getFirstPath                             :  obtain url The first parameter in 
getUrlHost                               :  obtain url In the link host
getUrlScheme                             :  obtain url In the link scheme
getFirstPath                             :  obtain url The first parameter in 
isURL                                    :  Returns whether the input matches url Regular expression of 

16. Common regular tool classes

  • Common regular expressions , reference AndroidUtils Tool class , take java To dart
    isMobileSimple                           :  Simple verification of mobile phone number 
isMobileExact                            :  Accurate verification of mobile phone number 
isTel                                    :  Verify phone number 
isIDCard15                               :  Verification of id card number  15  position 
isIDCard18                               :  Simply verify ID number.  18  position 
isIDCard18Exact                          :  Accurate identification ID number  18  position 
isEmail                                  :  Verify email 
isURL                                    :  verification  URL
isZh                                     :  Verify Chinese characters 
isUsername                               :  Verify user name 
isDate                                   :  verification  yyyy-MM-dd  Format date verification , A flat leap year has been considered 
isIP                                     :  verification  IP  Address 
match                                    :  Determine whether to match regular 
RegexConstants.REGEX_DOUBLE_BYTE_CHAR    :  Double byte 
RegexConstants.REGEX_BLANK_LINE          :  Blank line 
RegexConstants.REGEX_QQ_NUM              : QQ  Number 
RegexConstants.REGEX_CHINA_POSTAL_CODE   :  Zip code 
RegexConstants.REGEX_INTEGER             :  Integers 
RegexConstants.REGEX_POSITIVE_INTEGER    :  Positive integer 
RegexConstants.REGEX_NEGATIVE_INTEGER    :  Negtive integer 
RegexConstants.REGEX_NOT_NEGATIVE_INTEGER:  Non-negative integer 
RegexConstants.REGEX_NOT_POSITIVE_INTEGER:  Non positive integer 
RegexConstants.REGEX_FLOAT               :  Floating point numbers 
RegexConstants.REGEX_POSITIVE_FLOAT      :  Positive floating point 
RegexConstants.REGEX_NEGATIVE_FLOAT      :  Negative floating point number 
RegexConstants.REGEX_NOT_NEGATIVE_FLOAT  :  Nonnegative floating point number 
RegexConstants.REGEX_NOT_POSITIVE_FLOAT  :  Non positive floating point number 

17.Object Common tools

  • Object Relevant tools are as follows :
    isNull                                   :  Judge whether the object is null
isNullOrBlank                            :  Check whether the data is empty or empty ( Empty or contain only spaces )
isEmptyString                            :  Determines if the string is empty 
isEmptyList                              :  Determines if the set is empty 
isEmptyMap                               :  Judge whether the dictionary is empty 
isEmpty                                  :  Judge object Whether the object is empty 
isNotEmpty                               :  Judge object Whether it is not empty 
compareListIsEqual                       :  Compare whether the two sets are the same 
getLength                                :  obtain object The length of 

18. Verify related tool classes

  • Verify related tool classes
    isNumericOnly                            :  Check whether the string contains only numbers 
isAlphabetOnly                           :  Check if the string contains only letters .( There are no spaces )
isBool                                   :  Check whether the string is Boolean 
isVector                                 :  Check string Is it vector file 
isImage                                  :  Check whether the string is an image file 
isAudio                                  :  Check whether the string is an audio file 
isVideo                                  :  Check whether the string is a video file 
isTxt                                    :  Check whether the string is txt text file 
isDocument                               :  Check whether the string is doc file 
isExcel                                  :  Check whether the string is excel file 
isPPT                                    :  Check whether the string is ppt file 
isAPK                                    :  Check whether the string is apk file 
isPDF                                    :  Check whether the string is pdf file 
isHTML                                   :  Check whether the string is html file 
isURL                                    :  Check whether the string is url file 
isEmail                                  :  Check whether the string is email file 
isDateTime                               :  Check whether the string is time 
isMD5                                    :  Check whether the string is md5
isSHA1                                   :  Check whether the string is sha1
isSHA256                                 :  Check whether the string is sha256
isIPv4                                   :  Check whether the string is ipv4
isIPv6                                   :  Check whether the string is ipv6
isPalindrome                             :  Check if the string is palindrome 
isCaseInsensitiveContains                :  Check a Does it include b( Treat large and small initials as the same or explain ).
isCaseInsensitiveContainsAny             :  Check a Include in b or b Include in a( Treat large and small initials as the same ).
isCamelCase                              :  Check the string value for hump case 
isCapitalize                             :  Check whether the string value is capitalized 

19. Routing management tool class

21.Text Text tool class

  • Text related tool classes are as follows :
    isEmpty                                  :  Judge whether the text content is empty 
isNotEmpty                               :  Judge whether the text content is not empty 
startsWith                               :  The judgment string is xx start 
contains                                 :  Determine whether the string contains xx
abbreviate                               :  Use dot abbreviation string 
compare                                  :  Compare two strings for the same 
hammingDistance                          :  Comparing two strings of the same length has several different characters 
formatDigitPattern                       :  every other  x position   Add  pattern. For example, it is used to format bank cards 
formatSpace4                             :  every other 4 Bit plus space 
hideNumber                               :  Hide the middle of mobile phone number n position , For example, hide your mobile phone number  13667225184  by  136****5184
replace                                  :  Replace data in string 
split                                    :  Cut strings according to rules , Returns an array of 
reverse                                  :  Reverse string 

22.i18 Expanding tools

  • LocatizationExtensionState Class :String getString(String id)
    • Get different Locales Channel language content . give an example : Use :var name = context.getString("name");
  • LocatizationExtensionContext Class :String getString(String id)
    • Get different Locales Channel language content
  • How to add language content from different channels . Written in main Function runApp Before
    AppLocalizations.supportedLocales = [
    const Locale('en', 'US'),
    const Locale('pt', 'BR'),
    const Locale('ja', 'JP'),
    const Locale('zh', 'CN'),
];

23.Time Time tools

24.SPI Help tools

  • spi Brief introduction
    • Service Locator The interface can be ( Abstract base class ) Separate and decouple from the specific implementation , At the same time, it is allowed to receive data from App Access specific implementations from anywhere in the .
    // The first step is to register 
GetIt serviceLocator = GetIt.instance;
getIt.registerSingleton<BusinessService>(new BusinessServiceImpl());
// Step 2 use 
BusinessService businessService = serviceLocator<BusinessService>();
businessService.noneBusinessPattern();
// Step 3 unbind 
serviceLocator.resetLazySingleton<BusinessService>();

25. Timer helper class

  • Timer helper class
    TimerUtils                               :  Create countdown timer 
setTotalTime                             :  Set total countdown time 
setInterval                              :  Set up Timer interval 
startTimer                               :  Start timing Timer
updateTotalTime                          :  Reset total countdown time 
isActive                                 :  Judge Timer Whether to start 
pauseTimer                               :  Pause countdown timer 
cancel                                   :  Cancel the timer 
setOnTimerTickCallback                   :  Set the listening of the countdown timer 

26. Common development tools

26.1 int Expansion :ExtensionInt

  • ExtensionInt Expansion
    isPalindrome                             :  Check int Is it palindrome 
isOneAKind                               :  Check that all data has the same value 
toBinary                                 :  transformation int The value is binary 
toBinaryInt                              :  transformation int The value is binary int
fromBinary                               :  transformation int The value is a binary string 

26.2 List Expansion :ExtensionList

  • ExtensionList Expansion
    toJsonString                             :  take list Turn into json character string 
getJsonPretty                            :  take list Turn into json character string , Line break 
valueTotal                               :  obtain num Total value of the list (int/double)
isNull                                   :  Judge whether the object is null
isNullOrBlank                            :  Check whether the data is empty or empty ( Empty or contain only spaces )

26.3 Map Expansion :ExtensionMap

  • ExtensionMap Expansion 【set Extended class isomorphism 】
    toJsonString                             :  take map Turn into json character string 
getJsonPretty                            :  take map Turn into json String wrap 
isNull                                   :  Judge whether the object is null
isNullOrBlank                            :  Check whether the data is empty or empty ( Empty or contain only spaces )

26.4 String Expansion :ExtensionString

  • ExtensionString Expansion
    isNull                                   :  Judge whether the object is null
isNullOrBlank                            :  Check whether the data is empty or empty ( Empty or contain only spaces )
isNumericOnly                            :  Check whether the string contains only numbers 
isAlphabetOnly                           :  Check if the string contains only letters .( There are no spaces )
isBool                                   :  Check whether the string is Boolean 
isVector                                 :  Check string Is it vector file 
isImage                                  :  Check whether the string is an image file 
isAudio                                  :  Check whether the string is an audio file 
isVideo                                  :  Check whether the string is a video file 
isTxt                                    :  Check whether the string is txt text file 
isDocument                               :  Check whether the string is doc file 
isExcel                                  :  Check whether the string is excel file 
isPPT                                    :  Check whether the string is ppt file 
isAPK                                    :  Check whether the string is apk file 
isPDF                                    :  Check whether the string is pdf file 
isHTML                                   :  Check whether the string is html file 
isURL                                    :  Check whether the string is url file 
isEmail                                  :  Check whether the string is email file 
isDateTime                               :  Check whether the string is time 
isMD5                                    :  Check whether the string is md5
isSHA1                                   :  Check whether the string is sha1
isSHA256                                 :  Check whether the string is sha256
isIPv4                                   :  Check whether the string is ipv4
isIPv6                                   :  Check whether the string is ipv6
isPalindrome                             :  Check if the string is palindrome 
isCaseInsensitiveContains                :  Check a Does it include b( Treat large and small initials as the same or explain ).
isCaseInsensitiveContainsAny             :  Check a Include in b or b Include in a( Treat large and small initials as the same ).
isCamelCase                              :  Check the string value for hump case 
isCapitalize                             :  Check whether the string value is capitalized 

33. Transform related tool classes

  • Conversion related operation tool classes
    toBinary                                 :  transformation int The value is binary , such as :15 => 1111
toBinaryInt                              :  transformation int The value is binary 
fromBinary                               :  Convert binary to int value 
capitalize                               :  Every word in the string should be capitalized 
capitalizeFirst                          :  Capitalize the first letter of the string , Other letters are lowercase 
removeAllWhitespace                      :  Delete all spaces in the string 
numericOnly                              :  Extract the numeric value of the string 

34. Global exception capture tool

  • in the light of flutter Global exception capture , have access to :handle_exception
    // If you use , stay main In the method , As shown below :
hookCrash(() {
  runApp(MainApp());
});
  • Capture a printout :
    I/flutter ( 9506): yc e  — — — — — — — — — — st — — — — — — — — — — — — —
I/flutter ( 9506): yc e | handle_exception :  e---->MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_
I/flutter ( 9506): yc e | preferences)
I/flutter ( 9506): yc e  — — — — — — — — — — ed — — — — — — — — — ---— —
I/flutter ( 9506): yc e  handle_exception :  stack---->

35. Parse data tool class

  • analysis xml/html Data tools

36. Byte conversion tool class

  • ByteUtils Conversion related operation tool classes
    toBinary                                 :  transformation int The value is binary 
toReadable                               :  Convert a byte array to a readable string 
toBase64                                 :  Convert byte array to base64 character string 
fromBase64                               :  transformation base64 String to byte array 
clone                                    :  Clone byte array 
same                                     :  Determine whether the two bytes are the same 
extract                                  :  Extract data from a sequence of bytes 
combine                                  :  Splice two bytes 
insert                                   :  Inserts a byte at an index 
remove                                   :  Remove bytes at an index 

40. Other related tools

40.2 Random tools

  • RandomUtils
    randomColor                              :  Generate a random integer representing hexadecimal color 
randomString                             :  Generates a random string of a specified length or a random length 
randInt                                  :  Generate a random number between the beginning and the end 
randomElement                            :  Returns a random element from the list 

40.3 Get platform tool class

  • PlatformUtils. The tool class can obtain the platform , Then set up a value Differentiated platform information .
    final value = PlatformUtils.select(
  ios: "ios",
  android: "android",
  web: "web",
  fuchsia: "fuchsia",
  macOS: () => "macOS",
  windows: () => "windows",
  linux: () => "linux",
);
// result , stay Android On the device ,value Namely :android

40.4 Cutting board tools

  • System tool class , Mainly soft keyboard operation and copying content to the clipboard
    copyToClipboard                          :  Copy text content to clipboard 
hideKeyboard                             :  Hide soft keyboard , Specific to see :TextInputChannel
showKeyboard                             :  Display soft keyboard 
clearClientKeyboard                      :  Clear data 
原网站

版权声明
本文为[Is paidaxing there]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/12/202112151541452371.html