Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the skills of developing Flutter applications with Dart

Shulou Source: shulou.com Published: 2022-06-02 05:39:14 09月20日 Update

Editor to share with you what are the skills of using Dart to develop Flutter applications, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Release mode judgment

Determine whether the current environment is in release mode.

Const bool kReleaseMode = bool.fromEnvironment ('dart.vm.product')

You can also use the constants provided by foundation to achieve the same:

Import 'package:flutter/foundation.dart';print (' Is ReleaseMode: $kReleaseMode')

Use this to control the log output, such as closing the log in release mode:

If (isProduction) {debugPrint = (String message, {int wrapWidth}) = > {};}

Details = "https://api.flutter.dev/flutter/foundation/kReleaseMode-constant.html

Set the background image for Container

We all know that Container supports child to set the display content. In order to show the cascading effect, you can use Column. In fact, you can also use decoration to indirectly implement the background image.

Container (width: double.maxFinite, height: double.maxFinite, decoration: BoxDecoration (image: DecorationImage (image: NetworkImage ('https://bit.ly/2oqNqj9'),),), child: Center (child: Text (' Flutter.dev', style: TextStyle (color: Colors.red),), assertion hint

Using asert to make assertions, and providing personalized copy through the second parameter, allows users to have a clearer description of the assertion requirements

Assert (age > 18, "age should be > 18"); "chain" call

Using Dart syntax, method calls can be simplified

Class Person {String name; int age; Person (this.name, this.age); void data () = > print ("$name is $age years old.");} void main () {/ / Without Cascade Notation Person person = Person ("Richard", 50); person.data (); person.age = 22; person.data (); person.name + = "Parker"; person.data () / / Cascade Notation with Object of Person Person ("Jian", 21).. data ().. age = 22.. data ().. name + = "Yang".. data ();} null handling

A more common judgment is to assign a value when a variable is empty.

/ / User belowtitle? = "Title"; / / instead ofif (title = = null) {title = "Title";} these are all the contents of this article entitled "what are the techniques for developing Flutter applications with Dart". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Content patterns articles techniques applications development logs background clarity same not so personality users parameters variables most common constant effects copywriting Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi macOS NVidia Shulou Technology Shulou Tech Info