Created
March 9, 2022 00:52
-
-
Save jmagman/d7b76fc20ff5d5808f6ce26ea3d622e9 to your computer and use it in GitHub Desktop.
CADisableMinimumFrameDurationOnPhone Info.plist migration for https://github.com/flutter/flutter/pull/94509
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2014 The Flutter Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style license that can be | |
// found in the LICENSE file. | |
import '../../base/file_system.dart'; | |
import '../../base/logger.dart'; | |
import '../../base/project_migrator.dart'; | |
import '../../xcode_project.dart'; | |
// Add CADisableMinimumFrameDurationOnPhone to the Info.plist. | |
class MinimumFrameDurationMigration extends ProjectMigrator { | |
MinimumFrameDurationMigration( | |
IosProject project, | |
Logger logger, | |
) : _infoPlist = project.defaultHostInfoPlist, | |
super(logger); | |
final File _infoPlist; | |
@override | |
bool migrate() { | |
if (!_infoPlist.existsSync()) { | |
logger.printTrace('Xcode project workspace data not found, skipping minimum frame duration migration.'); | |
return true; | |
} | |
processFileLines(_infoPlist); | |
return true; | |
} | |
@override | |
String migrateFileContents(String fileContents) { | |
// | |
if (fileContents.contains('CADisableMinimumFrameDurationOnPhone')) { | |
return fileContents; | |
} | |
const String plistEnd = ''' | |
</dict> | |
</plist> | |
'''; | |
const String plistWithKey = ''' | |
<key>CADisableMinimumFrameDurationOnPhone</key> | |
<true/> | |
</dict> | |
</plist> | |
'''; | |
return fileContents.replaceAll(plistEnd, plistWithKey); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment