本文介绍了如何启用Flutter / Dart语言实验?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Dart中使用新的。

I want to use the new spread syntax in Dart.

我正在使用Android Studio进行Flutter开发,并且收到此错误。

I'm using Android Studio for Flutter development and I receive this error.



ListView(children: [...listTiles, MyWidget()])

但是,我找不到可以指定此选项的地方。

However, I didn't find anywhere where I could specify this option.

我什至无法使其在命令行上运行。 flutter --spread-collections运行给出找不到名为 spread-collections的选项。

I couldn't even make it work on the command line. flutter --spread-collections run gives Could not find an option named "spread-collections"..

flutter --version
Flutter 1.3.8 • channel beta • https://github.com/flutter/flutter.git
Framework • revision e5b1ed7a7f (4 weeks ago) • 2019-03-06 14:23:37 -0800
Engine • revision f4951df193
Tools • Dart 2.2.1 (build 2.2.1-dev.0.0 571ea80e11)


推荐答案

您需要创建analysis_options .yaml文件放在flutter应用程序的根目录中,并写上类似的内容

You need to create an analysis_options.yaml file in the root of your flutter app and write something like

analyzer:
  enable-experiment:
    - spread-collections

还要确保切换到包含新功能的正确频道,例如(开发,测试版或主版)

Also make sure to switch to the correct channel where the new feature is included eg (dev, beta or master)

flutter channel dev

确保您具有最新版本的Flutter

And also make sure you have a recent enough version of flutter

flutter upgrade

您可以n指定浮动版本号,以确保您有一个非常特定的版本

You can specify the flutter version number to ensure you have a very specific version

flutter version v1.2.1

这篇关于如何启用Flutter / Dart语言实验?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 04:55