Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Writing ThemeData as part of the theme file
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-015 committed Jun 28, 2022
1 parent 999cb74 commit 8993421
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ class ThemingPostGenTask extends PostGenTask {
textThemeBoilerplate,
);

final themeConstant = ConstantHolder(
'ThemeData',
'themeData',
'ThemeData(textTheme: textTheme,)',
isconst: false,
);

var pathService = GetIt.I.get<PathService>();

/// Imports for material and the [TextStyles].
Expand All @@ -48,7 +55,7 @@ import 'package:${projectName.snakeCase}/${pathService.themingRelativePath.repla
generationConfiguration.fileStructureStrategy.commandCreated(
WriteConstantsCommand(
Uuid().v4(),
[textConstant],
[themeConstant, textConstant],
filename: '${projectName.snakeCase}_theme',
ownershipPolicy: FileOwnership.PBC,
imports: imports,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class WriteConstantsCommand extends FileStructureCommand {
var description =
constant.description.isNotEmpty ? '/// ${constant.description}' : '';
var constStr =
'static const ${constant.type} ${constant.name} = ${constant.value};';
'static ${constant.isconst ? 'const' : ''} ${constant.type} ${constant.name} = ${constant.value};';

constBuffer.writeln('$description\n$constStr');
});
Expand Down Expand Up @@ -87,10 +87,14 @@ class ConstantHolder {
/// Optional description to put as comment above the constant
String description;

/// Whether [this] should have "const" written in it.
bool isconst; //TODO: Temporary bool in order to write theming file.

ConstantHolder(
this.type,
this.name,
this.value, {
this.isconst = true,
this.description = '',
});
}

0 comments on commit 8993421

Please sign in to comment.