为什么获取方法“contains”没有为类型“String”定义。颤动

问题描述 投票:0回答:1

我在 dart 中对字符串使用 contains 方法,但收到这样的错误。

谁能告诉我在 dart 中使用

.contains
作为字符串有什么问题

这是我的代码

String isPdf = "https://www.africau.edu/images/default/sample.pdf";
isPdf.contains("pdf");

发生错误

The method 'contains' isn't defined for the type 'String'.
Try correcting the name to the name of an existing method, or defining a method named 'contains'.

在 vscode 中,quickfix 告诉我这一点

change the 'contains' method to 'oscontains'.
flutter dart contains
1个回答
0
投票

未为“List”类型定义“substring”方法。 尝试将名称更正为现有方法的名称,或定义名为“substring”的方法

© www.soinside.com 2019 - 2024. All rights reserved.