我想忽略静态代码分析中的特定行。
对于 Flake8,我会使用语法# noqa: F401.
对于 pylint,我会使用语法# pylint: disable=unused-import。
当我正在开发代码生成框架时,我希望代码能够支持这两种 linter。有没有办法结合这两个指令,以便正确检测到它们?
我无法理解 DART 中生成的斐波那契代码的工作原理。
void main() async {
List<BigInt> lista = [];
final start = DateTime.now();
finobacciPOC(lista, BigInt.from(15000), BigInt.zero, BigInt.one);
print('lista');
final time_exec = start.difference(DateTime.now());
print("Calculate in time ${time_exec}");
}
void finobacciPOC(
List<BigInt> listResult, BigInt total, BigInt start, BigInt end) async {
BigInt sum = start + end;
await Future.delayed(Duration(microseconds: 1));
listResult.add(sum);
total = total - BigInt.one;
if (total == BigInt.zero) {
print(listResult);
return;
}
finobacciPOC(listResult, total, end, sum);
}
Run Code Online (Sandbox Code Playgroud)
仅当您保留延迟例程时(如果您想生成 15000 个序列),该代码才有效。如果删除延迟,将显示溢出错误。
我想了解这个场景是如何运作的。
在 VS Codium 中的模拟器上运行 flutter run 时,出现以下错误:
flutter run --debug
Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...
startup failed:
/home/damian/dev_tools/flutter/packages/flutter_tools/gradle/build/classes/groovy/main/FlutterPlugin$_addTasksForOutputsAppLinkSettings_closure22$_closure48$_closure50$_closure51$_closure52$_closure53$_closure55$_closure57$_closure58.class (filename too long)
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':gradle:compileGroovy'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with …Run Code Online (Sandbox Code Playgroud) 创建一个新的Swift Playground / .playgroundbook 打算在iPad App 上使用时,我经常收到错误消息:
“运行操场时出现问题。运行此操场时遇到问题。请检查您的代码是否有错误。”
我可以追踪这个问题是在将某些子视图添加到我的实时视图时引起的。更准确地说,我的目标是将 UIImage 拆分为多个部分并为它们创建新的 UIImageViews:
for x in 0..<parts {
for y in 0..<parts {
//Create UIImageView with cropped image
let pieceView = UIImageView.init(frame: CGRect.init(x: CGFloat(x)*singleSize.width, y:CGFloat(y)*singleSize.height, width: singleSize.width, height: singleSize.height))
let imageRef = image.cgImage!.cropping(to: CGRect.init(x:0, y:0, width: 100, height: 100));
pieceView.image = UIImage.init(cgImage: imageRef!)
//Add them to an array
self.viewArray.append(pieceView)
}
}
Run Code Online (Sandbox Code Playgroud)
这就是事情对我来说变得非常棘手的地方:现在添加 7 个 UIImageViews 没有问题。但是一旦我想添加 8 个或更多,操场就会停止工作并给出错误消息“操场运行有问题...”(见上文)
到目前为止我测试了什么:
这是一个非常初学者的问题,但因为我一直想知道,例如在这种方法中:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
为什么我们有didFinishLaunchingWithOptions作为一个论点?我知道这application将是 typeUIApplication并且 launchOptions 将是 type UIApplicationLaunchWithOptionsKey: any,但是为什么我们只在那里调用了这个“存根”didFinishLaunchingWithOptions如果您知道我的意思?
另外,第一个参数之前的下划线是什么意思?我不得不多次把它放在那里,这样我的功能才能工作。
我在名为“keys.json”的文件中设置了一些环境变量,并使用--dart-define-from-file来加载它们。
flutter run --dart-define-from-file=keys.json
Run Code Online (Sandbox Code Playgroud)
通过命令行它可以正常工作,但是使用 Xcode 时又如何呢?
如何设置--dart-define-from-file变量以便我可以在 Xcode 中运行和构建项目?