generateMainFile function
Generates the main.dart entry file based on the given GeneratorConfig.
If localization is enabled, it generates a localized main file, otherwise a basic provider setup.
config – Configuration settings (e.g., localization, state management).
projectName – The name of the Flutter project.
state – Currently unused, but can be used for different state management strategies.
Implementation
generateMainFile(GeneratorConfig config, String projectName, String state) {
final mainPath = '$projectName/lib/main.dart';
// Check if localization is enabled
final hasLocalization =
config.languages.isNotEmpty && config.defaultLanguage != null;
// Choose content template based on localization flag
final content = hasLocalization
? _localizedMainFile(
projectName, config.defaultLanguage!, config.languages)
: _basicProviderMainFile(projectName);
// Write the content to file
_write(mainPath, content);
}