dart
print输出被截断,可以尝试一段一段打印
void printWrapped(String text) {
final pattern = new RegExp('.{1,800}'); // 800 is the size of each chunk
pattern.allMatches(text).forEach((match) => print(match.group(0)));
}
枚举demo
enum TargetPlatform {
android_arm,
android_arm64,
android_x64,
android_x86,
ios,
darwin_x64,
linux_x64,
windows_x64,
fuchsia,
tester,
web_javascript,
}
switch demo
// TargetPlatform 这个是枚举类型
String getNameForTargetPlatform(TargetPlatform platform) {
switch (platform) {
case TargetPlatform.android_arm:
return 'android-arm';
case TargetPlatform.android_arm64:
return 'android-arm64';
case TargetPlatform.android_x64:
return 'android-x64';
case TargetPlatform.android_x86:
return 'android-x86';
case TargetPlatform.ios:
return 'ios';
case TargetPlatform.darwin_x64:
return 'darwin-x64';
case TargetPlatform.linux_x64:
return 'linux-x64';
case TargetPlatform.windows_x64:
return 'windows-x64';
case TargetPlatform.fuchsia:
return 'fuchsia';
case TargetPlatform.tester:
return 'flutter-tester';
case TargetPlatform.web_javascript:
return 'web-javascript';
}
assert(false);
return null;
}
类的定义
class EngineBuildPaths {
const EngineBuildPaths({
@required this.targetEngine,
@required this.hostEngine,
}) : assert(targetEngine != null),
assert(hostEngine != null);
final String targetEngine;
final String hostEngine;
}
抽象类的定义
// Manages the engine artifacts of Flutter.
abstract class Artifacts {
static Artifacts get instance => context.get<Artifacts>();
static LocalEngineArtifacts getLocalEngine(String engineSrcPath, EngineBuildPaths engineBuildPaths) {
return LocalEngineArtifacts(engineSrcPath, engineBuildPaths.targetEngine, engineBuildPaths.hostEngine);
}
// Returns the requested [artifact] for the [platform] and [mode] combination.
String getArtifactPath(Artifact artifact, { TargetPlatform platform, BuildMode mode });
// Returns which set of engine artifacts is currently used for the [platform]
// and [mode] combination.
String getEngineType(TargetPlatform platform, [ BuildMode mode ]);
}
Lua
for循环
local bugList = {}
bugList[0] = 1
bugList[1] = 2
for i= 1, #bugList do
local bug = bugList[i];
print(bug)
end