Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the skills of developing Flutter applications with Dart

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report