copyToRootEnv method
Copies a client env file to the root .env for the Flutter build.
Implementation
Future<File> copyToRootEnv(File sourceEnv, {bool isTest = false}) async {
if (!sourceEnv.existsSync()) {
throw BuildException(
'Source environment file missing at "${sourceEnv.path}"',
fix:
'Verify the client directory contains the expected environment file.',
);
}
final targetPath = p.join(projectDir, '.env');
try {
return await sourceEnv.copy(targetPath);
} catch (e, s) {
throw BuildException(
'Failed to copy environment file to root directory.',
fix: 'Check write permissions for "$targetPath".',
originalStackTrace: s,
);
}
}