Unverified Commit d4061c19 authored by Darren Austin's avatar Darren Austin Committed by GitHub

Refactor gen_defaults to support multiple generated code blocks in the same...

Refactor gen_defaults to support multiple generated code blocks in the same file independently. (#107278)
parent 7db73c0a
...@@ -15,10 +15,10 @@ dart dev/tools/gen_defaults/bin/gen_defaults.dart ...@@ -15,10 +15,10 @@ dart dev/tools/gen_defaults/bin/gen_defaults.dart
There is a template file for every component that needs defaults from There is a template file for every component that needs defaults from
the token database. These templates are implemented as subclasses of the token database. These templates are implemented as subclasses of
`TokenTemplate`. This base class provides some utilities and a structure `TokenTemplate`. This base class provides some utilities and a structure
for adding a new chunk of generated code to the bottom of a given file. for adding a new block of generated code to the bottom of a given file.
Templates need to override the `generate` method to provide the generated Templates need to override the `generate` method to provide the generated
code chunk as a string. The tokens are represented as a `Map<String, dynamic>` code block as a string. The tokens are represented as a `Map<String, dynamic>`
that is loaded from `data/material-tokens.json`. Templates can look up that is loaded from `data/material-tokens.json`. Templates can look up
whatever properties are needed in this structure to provide the properties whatever properties are needed in this structure to provide the properties
needed for the component. needed for the component.
......
...@@ -99,20 +99,20 @@ Future<void> main(List<String> args) async { ...@@ -99,20 +99,20 @@ Future<void> main(List<String> args) async {
tokens['colorsLight'] = _readTokenFile('color_light.json'); tokens['colorsLight'] = _readTokenFile('color_light.json');
tokens['colorsDark'] = _readTokenFile('color_dark.json'); tokens['colorsDark'] = _readTokenFile('color_dark.json');
AppBarTemplate('$materialLib/app_bar.dart', tokens).updateFile(); AppBarTemplate('AppBar', '$materialLib/app_bar.dart', tokens).updateFile();
ButtonTemplate('md.comp.elevated-button', '$materialLib/elevated_button.dart', tokens).updateFile(); ButtonTemplate('md.comp.elevated-button', 'ElevatedButton', '$materialLib/elevated_button.dart', tokens).updateFile();
ButtonTemplate('md.comp.outlined-button', '$materialLib/outlined_button.dart', tokens).updateFile(); ButtonTemplate('md.comp.outlined-button', 'OutlinedButton', '$materialLib/outlined_button.dart', tokens).updateFile();
ButtonTemplate('md.comp.text-button', '$materialLib/text_button.dart', tokens).updateFile(); ButtonTemplate('md.comp.text-button', 'TextButton', '$materialLib/text_button.dart', tokens).updateFile();
CardTemplate('$materialLib/card.dart', tokens).updateFile(); CardTemplate('Card', '$materialLib/card.dart', tokens).updateFile();
ChipActionTemplate('$materialLib/chip_action.dart', tokens).updateFile(); ChipActionTemplate('ActionChip', '$materialLib/chip_action.dart', tokens).updateFile();
ChipFilterTemplate('$materialLib/chip_filter.dart', tokens).updateFile(); ChipFilterTemplate('FilterChip', '$materialLib/chip_filter.dart', tokens).updateFile();
ChipFilterTemplate('$materialLib/chip_choice.dart', tokens).updateFile(); ChipFilterTemplate('FilterChip', '$materialLib/chip_choice.dart', tokens).updateFile();
ChipInputTemplate('$materialLib/chip_input.dart', tokens).updateFile(); ChipInputTemplate('InputChip', '$materialLib/chip_input.dart', tokens).updateFile();
DialogTemplate('$materialLib/dialog.dart', tokens).updateFile(); DialogTemplate('Dialog', '$materialLib/dialog.dart', tokens).updateFile();
FABTemplate('$materialLib/floating_action_button.dart', tokens).updateFile(); FABTemplate('FAB', '$materialLib/floating_action_button.dart', tokens).updateFile();
IconButtonTemplate('$materialLib/icon_button.dart', tokens).updateFile(); IconButtonTemplate('IconButton', '$materialLib/icon_button.dart', tokens).updateFile();
NavigationBarTemplate('$materialLib/navigation_bar.dart', tokens).updateFile(); NavigationBarTemplate('NavigationBar', '$materialLib/navigation_bar.dart', tokens).updateFile();
NavigationRailTemplate('$materialLib/navigation_rail.dart', tokens).updateFile(); NavigationRailTemplate('NavigationRail', '$materialLib/navigation_rail.dart', tokens).updateFile();
SurfaceTintTemplate('$materialLib/elevation_overlay.dart', tokens).updateFile(); SurfaceTintTemplate('SurfaceTint', '$materialLib/elevation_overlay.dart', tokens).updateFile();
TypographyTemplate('$materialLib/typography.dart', tokens).updateFile(); TypographyTemplate('Typography', '$materialLib/typography.dart', tokens).updateFile();
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import 'template.dart'; import 'template.dart';
class AppBarTemplate extends TokenTemplate { class AppBarTemplate extends TokenTemplate {
const AppBarTemplate(super.fileName, super.tokens) const AppBarTemplate(super.blockName, super.fileName, super.tokens)
: super( : super(
colorSchemePrefix: '_colors.', colorSchemePrefix: '_colors.',
textThemePrefix: '_textTheme.', textThemePrefix: '_textTheme.',
...@@ -13,9 +13,8 @@ class AppBarTemplate extends TokenTemplate { ...@@ -13,9 +13,8 @@ class AppBarTemplate extends TokenTemplate {
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]} class _${blockName}DefaultsM3 extends AppBarTheme {
class _TokenDefaultsM3 extends AppBarTheme { _${blockName}DefaultsM3(this.context)
_TokenDefaultsM3(this.context)
: super( : super(
elevation: ${elevation('md.comp.top-app-bar.small.container')}, elevation: ${elevation('md.comp.top-app-bar.small.container')},
scrolledUnderElevation: ${elevation('md.comp.top-app-bar.small.on-scroll.container')}, scrolledUnderElevation: ${elevation('md.comp.top-app-bar.small.on-scroll.container')},
......
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
import 'template.dart'; import 'template.dart';
class ButtonTemplate extends TokenTemplate { class ButtonTemplate extends TokenTemplate {
const ButtonTemplate(this.tokenGroup, String fileName, Map<String, dynamic> tokens) const ButtonTemplate(this.tokenGroup, super.blockName, super.fileName, super.tokens, {
: super(fileName, tokens, super.colorSchemePrefix = '_colors.',
colorSchemePrefix: '_colors.', });
);
final String tokenGroup; final String tokenGroup;
...@@ -55,9 +54,8 @@ class ButtonTemplate extends TokenTemplate { ...@@ -55,9 +54,8 @@ class ButtonTemplate extends TokenTemplate {
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]} class _${blockName}DefaultsM3 extends ButtonStyle {
class _TokenDefaultsM3 extends ButtonStyle { _${blockName}DefaultsM3(this.context)
_TokenDefaultsM3(this.context)
: super( : super(
animationDuration: kThemeChangeDuration, animationDuration: kThemeChangeDuration,
enableFeedback: true, enableFeedback: true,
......
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
import 'template.dart'; import 'template.dart';
class CardTemplate extends TokenTemplate { class CardTemplate extends TokenTemplate {
const CardTemplate(super.fileName, super.tokens); const CardTemplate(super.blockName, super.fileName, super.tokens);
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]} // Generated version ${tokens["version"]}
class _TokenDefaultsM3 extends CardTheme { class _${blockName}DefaultsM3 extends CardTheme {
const _TokenDefaultsM3(this.context) const _${blockName}DefaultsM3(this.context)
: super( : super(
clipBehavior: Clip.none, clipBehavior: Clip.none,
elevation: ${elevation("md.comp.elevated-card.container")}, elevation: ${elevation("md.comp.elevated-card.container")},
......
...@@ -6,16 +6,15 @@ import 'template.dart'; ...@@ -6,16 +6,15 @@ import 'template.dart';
class ChipActionTemplate extends TokenTemplate { class ChipActionTemplate extends TokenTemplate {
const ChipActionTemplate(super.fileName, super.tokens); const ChipActionTemplate(super.blockName, super.fileName, super.tokens);
static const String tokenGroup = 'md.comp.assist-chip'; static const String tokenGroup = 'md.comp.assist-chip';
static const String variant = '.flat'; static const String variant = '.flat';
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]} class _${blockName}DefaultsM3 extends ChipThemeData {
class _TokenDefaultsM3 extends ChipThemeData { const _${blockName}DefaultsM3(this.context, this.isEnabled)
const _TokenDefaultsM3(this.context, this.isEnabled)
: super( : super(
elevation: ${elevation("$tokenGroup$variant.container")}, elevation: ${elevation("$tokenGroup$variant.container")},
shape: ${shape("$tokenGroup.container")}, shape: ${shape("$tokenGroup.container")},
......
...@@ -5,16 +5,15 @@ ...@@ -5,16 +5,15 @@
import 'template.dart'; import 'template.dart';
class ChipFilterTemplate extends TokenTemplate { class ChipFilterTemplate extends TokenTemplate {
const ChipFilterTemplate(super.fileName, super.tokens); const ChipFilterTemplate(super.blockName, super.fileName, super.tokens);
static const String tokenGroup = 'md.comp.filter-chip'; static const String tokenGroup = 'md.comp.filter-chip';
static const String variant = '.flat'; static const String variant = '.flat';
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]} class _${blockName}DefaultsM3 extends ChipThemeData {
class _TokenDefaultsM3 extends ChipThemeData { const _${blockName}DefaultsM3(this.context, this.isEnabled, this.isSelected)
const _TokenDefaultsM3(this.context, this.isEnabled, this.isSelected)
: super( : super(
elevation: ${elevation("$tokenGroup$variant.container")}, elevation: ${elevation("$tokenGroup$variant.container")},
shape: ${shape("$tokenGroup.container")}, shape: ${shape("$tokenGroup.container")},
......
...@@ -5,16 +5,15 @@ ...@@ -5,16 +5,15 @@
import 'template.dart'; import 'template.dart';
class ChipInputTemplate extends TokenTemplate { class ChipInputTemplate extends TokenTemplate {
const ChipInputTemplate(super.fileName, super.tokens); const ChipInputTemplate(super.blockName, super.fileName, super.tokens);
static const String tokenGroup = 'md.comp.input-chip'; static const String tokenGroup = 'md.comp.input-chip';
static const String variant = ''; static const String variant = '';
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]} class _${blockName}DefaultsM3 extends ChipThemeData {
class _TokenDefaultsM3 extends ChipThemeData { const _${blockName}DefaultsM3(this.context, this.isEnabled)
const _TokenDefaultsM3(this.context, this.isEnabled)
: super( : super(
elevation: ${elevation("$tokenGroup$variant.container")}, elevation: ${elevation("$tokenGroup$variant.container")},
shape: ${shape("$tokenGroup.container")}, shape: ${shape("$tokenGroup.container")},
......
...@@ -5,16 +5,15 @@ ...@@ -5,16 +5,15 @@
import 'template.dart'; import 'template.dart';
class DialogTemplate extends TokenTemplate { class DialogTemplate extends TokenTemplate {
const DialogTemplate(super.fileName, super.tokens) const DialogTemplate(super.blockName, super.fileName, super.tokens, {
: super(colorSchemePrefix: '_colors.', super.colorSchemePrefix = '_colors.',
textThemePrefix: '_textTheme.' super.textThemePrefix = '_textTheme.'
); });
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]} class _${blockName}DefaultsM3 extends DialogTheme {
class _TokenDefaultsM3 extends DialogTheme { _${blockName}DefaultsM3(this.context)
_TokenDefaultsM3(this.context)
: super( : super(
alignment: Alignment.center, alignment: Alignment.center,
elevation: ${elevation("md.comp.dialog.container")}, elevation: ${elevation("md.comp.dialog.container")},
......
...@@ -5,16 +5,15 @@ ...@@ -5,16 +5,15 @@
import 'template.dart'; import 'template.dart';
class FABTemplate extends TokenTemplate { class FABTemplate extends TokenTemplate {
const FABTemplate(super.fileName, super.tokens) const FABTemplate(super.blockName, super.fileName, super.tokens, {
: super(colorSchemePrefix: '_colors.', super.colorSchemePrefix = '_colors.',
textThemePrefix: '_textTheme.', super.textThemePrefix = '_textTheme.',
); });
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]} class _${blockName}DefaultsM3 extends FloatingActionButtonThemeData {
class _TokenDefaultsM3 extends FloatingActionButtonThemeData { _${blockName}DefaultsM3(this.context, this.type, this.hasChild)
_TokenDefaultsM3(this.context, this.type, this.hasChild)
: super( : super(
elevation: ${elevation("md.comp.fab.primary.container")}, elevation: ${elevation("md.comp.fab.primary.container")},
focusElevation: ${elevation("md.comp.fab.primary.focus.container")}, focusElevation: ${elevation("md.comp.fab.primary.focus.container")},
......
...@@ -5,15 +5,14 @@ ...@@ -5,15 +5,14 @@
import 'template.dart'; import 'template.dart';
class IconButtonTemplate extends TokenTemplate { class IconButtonTemplate extends TokenTemplate {
const IconButtonTemplate(super.fileName, super.tokens) const IconButtonTemplate(super.blockName, super.fileName, super.tokens, {
: super(colorSchemePrefix: '_colors.', super.colorSchemePrefix = '_colors.',
); });
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]} class _${blockName}DefaultsM3 extends ButtonStyle {
class _TokenDefaultsM3 extends ButtonStyle { _${blockName}DefaultsM3(this.context)
_TokenDefaultsM3(this.context)
: super( : super(
animationDuration: kThemeChangeDuration, animationDuration: kThemeChangeDuration,
enableFeedback: true, enableFeedback: true,
......
...@@ -5,16 +5,15 @@ ...@@ -5,16 +5,15 @@
import 'template.dart'; import 'template.dart';
class NavigationBarTemplate extends TokenTemplate { class NavigationBarTemplate extends TokenTemplate {
const NavigationBarTemplate(super.fileName, super.tokens) const NavigationBarTemplate(super.blockName, super.fileName, super.tokens, {
: super(colorSchemePrefix: '_colors.', super.colorSchemePrefix = '_colors.',
textThemePrefix: '_textTheme.', super.textThemePrefix = '_textTheme.',
); });
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]} class _${blockName}DefaultsM3 extends NavigationBarThemeData {
class _TokenDefaultsM3 extends NavigationBarThemeData { _${blockName}DefaultsM3(this.context)
_TokenDefaultsM3(this.context)
: super( : super(
height: ${tokens["md.comp.navigation-bar.container.height"]}, height: ${tokens["md.comp.navigation-bar.container.height"]},
elevation: ${elevation("md.comp.navigation-bar.container")}, elevation: ${elevation("md.comp.navigation-bar.container")},
......
...@@ -5,16 +5,15 @@ ...@@ -5,16 +5,15 @@
import 'template.dart'; import 'template.dart';
class NavigationRailTemplate extends TokenTemplate { class NavigationRailTemplate extends TokenTemplate {
const NavigationRailTemplate(super.fileName, super.tokens) const NavigationRailTemplate(super.blockName, super.fileName, super.tokens, {
: super(colorSchemePrefix: '_colors.', super.colorSchemePrefix = '_colors.',
textThemePrefix: '_textTheme.', super.textThemePrefix = '_textTheme.',
); });
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]} class _${blockName}DefaultsM3 extends NavigationRailThemeData {
class _TokenDefaultsM3 extends NavigationRailThemeData { _${blockName}DefaultsM3(this.context)
_TokenDefaultsM3(this.context)
: super( : super(
elevation: ${elevation("md.comp.navigation-rail.container")}, elevation: ${elevation("md.comp.navigation-rail.container")},
groupAlignment: -1, groupAlignment: -1,
......
...@@ -5,12 +5,10 @@ ...@@ -5,12 +5,10 @@
import 'template.dart'; import 'template.dart';
class SurfaceTintTemplate extends TokenTemplate { class SurfaceTintTemplate extends TokenTemplate {
const SurfaceTintTemplate(super.fileName, super.tokens); const SurfaceTintTemplate(super.blockName, super.fileName, super.tokens);
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]}
// Surface tint opacities based on elevations according to the // Surface tint opacities based on elevations according to the
// Material Design 3 specification: // Material Design 3 specification:
// https://m3.material.io/styles/color/the-color-system/color-roles // https://m3.material.io/styles/color/the-color-system/color-roles
......
...@@ -5,50 +5,83 @@ ...@@ -5,50 +5,83 @@
import 'dart:io'; import 'dart:io';
abstract class TokenTemplate { abstract class TokenTemplate {
const TokenTemplate(this.fileName, this.tokens, { const TokenTemplate(this.blockName, this.fileName, this.tokens, {
this.colorSchemePrefix = 'Theme.of(context).colorScheme.', this.colorSchemePrefix = 'Theme.of(context).colorScheme.',
this.textThemePrefix = 'Theme.of(context).textTheme.' this.textThemePrefix = 'Theme.of(context).textTheme.'
}); });
/// Name of the code block that this template will generate.
///
/// Used to identify an existing block when updating it.
final String blockName;
/// Name of the file that will be updated with the generated code.
final String fileName;
/// Map of token data extracted from the Material Design token database.
final Map<String, dynamic> tokens;
/// Optional prefix prepended to color definitions.
///
/// Defaults to 'Theme.of(context).colorScheme.'
final String colorSchemePrefix;
/// Optional prefix prepended to text style definitians.
///
/// Defaults to 'Theme.of(context).textTheme.'
final String textThemePrefix;
static const String beginGeneratedComment = ''' static const String beginGeneratedComment = '''
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES''';
''';
static const String headerComment = ''' static const String headerComment = '''
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
'''; ''';
static const String endGeneratedComment = ''' static const String endGeneratedComment = '''
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES''';
''';
final String fileName;
final Map<String, dynamic> tokens;
final String colorSchemePrefix;
final String textThemePrefix;
/// Replace or append the contents of the file with the text from [generate]. /// Replace or append the contents of the file with the text from [generate].
/// ///
/// If the file already contains generated block at the end, it will /// If the file already contains a generated text block matching the
/// be replaced by the [generate] output. Otherwise the content will /// [blockName], it will be replaced by the [generate] output. Otherwise
/// just be appended to the end of the file. /// the content will just be appended to the end of the file.
Future<void> updateFile() async { Future<void> updateFile() async {
String contents = File(fileName).readAsStringSync(); final String contents = File(fileName).readAsStringSync();
final int previousGeneratedIndex = contents.indexOf(beginGeneratedComment); final String beginComment = '$beginGeneratedComment - $blockName\n';
if (previousGeneratedIndex != -1) { final String endComment = '$endGeneratedComment - $blockName\n';
contents = contents.substring(0, previousGeneratedIndex); final int beginPreviousBlock = contents.indexOf(beginComment);
final int endPreviousBlock = contents.indexOf(endComment);
late String contentBeforeBlock;
late String contentAfterBlock;
if (beginPreviousBlock != -1) {
if (endPreviousBlock < beginPreviousBlock) {
print('Unable to find block named $blockName in $fileName, skipping code generation.');
return;
}
// Found a valid block matching the name, so record the content before and after.
contentBeforeBlock = contents.substring(0, beginPreviousBlock);
contentAfterBlock = contents.substring(endPreviousBlock + endComment.length);
} else {
// Just append to the bottom.
contentBeforeBlock = contents;
contentAfterBlock = '';
} }
final StringBuffer buffer = StringBuffer(contents);
buffer.write(beginGeneratedComment); final StringBuffer buffer = StringBuffer(contentBeforeBlock);
buffer.write(beginComment);
buffer.write(headerComment); buffer.write(headerComment);
buffer.write('// Token database version: ${tokens['version']}\n\n');
buffer.write(generate()); buffer.write(generate());
buffer.write(endGeneratedComment); buffer.write(endComment);
buffer.write(contentAfterBlock);
File(fileName).writeAsStringSync(buffer.toString()); File(fileName).writeAsStringSync(buffer.toString());
} }
......
...@@ -5,11 +5,10 @@ ...@@ -5,11 +5,10 @@
import 'template.dart'; import 'template.dart';
class TypographyTemplate extends TokenTemplate { class TypographyTemplate extends TokenTemplate {
const TypographyTemplate(super.fileName, super.tokens); const TypographyTemplate(super.blockName, super.fileName, super.tokens);
@override @override
String generate() => ''' String generate() => '''
// Generated version ${tokens["version"]}
class _M3Typography { class _M3Typography {
_M3Typography._(); _M3Typography._();
......
...@@ -23,24 +23,27 @@ void main() { ...@@ -23,24 +23,27 @@ void main() {
// Have a test template append new parameterized content to the end of // Have a test template append new parameterized content to the end of
// the file. // the file.
final Map<String, dynamic> tokens = <String, dynamic>{'foo': 'Foobar', 'bar': 'Barfoo'}; final Map<String, dynamic> tokens = <String, dynamic>{'version': '0.0', 'foo': 'Foobar', 'bar': 'Barfoo'};
TestTemplate(tempFile.path, tokens).updateFile(); TestTemplate('Test', tempFile.path, tokens).updateFile();
expect(tempFile.readAsStringSync(), ''' expect(tempFile.readAsStringSync(), '''
// This is a file with stuff in it. // This is a file with stuff in it.
// This part shouldn't be changed by // This part shouldn't be changed by
// the template. // the template.
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - Test
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Token database version: 0.0
static final String tokenFoo = 'Foobar'; static final String tokenFoo = 'Foobar';
static final String tokenBar = 'Barfoo'; static final String tokenBar = 'Barfoo';
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - Test
'''); ''');
} finally { } finally {
...@@ -59,38 +62,166 @@ static final String tokenBar = 'Barfoo'; ...@@ -59,38 +62,166 @@ static final String tokenBar = 'Barfoo';
// This part shouldn't be changed by // This part shouldn't be changed by
// the template. // the template.
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - Test
// Do not edit by hand. The code between the "BEGIN GENERATED" and
// "END GENERATED" comments are generated from data in the Material
// Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated code to the end of this file. Do not edit by hand. // Token database version: 0.0
// These defaults are generated from the Material Design Token
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart.
static final String tokenFoo = 'Foobar'; static final String tokenFoo = 'Foobar';
static final String tokenBar = 'Barfoo'; static final String tokenBar = 'Barfoo';
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - Test
'''); ''');
// Have a test template append new parameterized content to the end of // Have a test template append new parameterized content to the end of
// the file. // the file.
final Map<String, dynamic> tokens = <String, dynamic>{'foo': 'foo', 'bar': 'bar'}; final Map<String, dynamic> tokens = <String, dynamic>{'version': '0.0', 'foo': 'foo', 'bar': 'bar'};
TestTemplate(tempFile.path, tokens).updateFile(); TestTemplate('Test', tempFile.path, tokens).updateFile();
expect(tempFile.readAsStringSync(), '''
// This is a file with stuff in it.
// This part shouldn't be changed by
// the template.
// BEGIN GENERATED TOKEN PROPERTIES - Test
// Do not edit by hand. The code between the "BEGIN GENERATED" and
// "END GENERATED" comments are generated from data in the Material
// Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Token database version: 0.0
static final String tokenFoo = 'foo';
static final String tokenBar = 'bar';
// END GENERATED TOKEN PROPERTIES - Test
''');
} finally {
tempDir.deleteSync(recursive: true);
}
});
test('Multiple templates can modify different code blocks in the same file', () {
final Directory tempDir = Directory.systemTemp.createTempSync('gen_defaults');
try {
// Create a temporary file with some content.
final File tempFile = File(path.join(tempDir.path, 'test_template.txt'));
tempFile.createSync();
tempFile.writeAsStringSync('''
// This is a file with stuff in it.
// This part shouldn't be changed by
// the template.
''');
// Update file with a template for 'Block 1'
{
final Map<String, dynamic> tokens = <String, dynamic>{'version': '0.0', 'foo': 'foo', 'bar': 'bar'};
TestTemplate('Block 1', tempFile.path, tokens).updateFile();
}
expect(tempFile.readAsStringSync(), '''
// This is a file with stuff in it.
// This part shouldn't be changed by
// the template.
// BEGIN GENERATED TOKEN PROPERTIES - Block 1
// Do not edit by hand. The code between the "BEGIN GENERATED" and
// "END GENERATED" comments are generated from data in the Material
// Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Token database version: 0.0
static final String tokenFoo = 'foo';
static final String tokenBar = 'bar';
// END GENERATED TOKEN PROPERTIES - Block 1
''');
// Update file with a template for 'Block 2', which should append but not
// disturb the code in 'Block 1'.
{
final Map<String, dynamic> tokens = <String, dynamic>{'version': '0.0', 'foo': 'bar', 'bar': 'foo'};
TestTemplate('Block 2', tempFile.path, tokens).updateFile();
}
expect(tempFile.readAsStringSync(), ''' expect(tempFile.readAsStringSync(), '''
// This is a file with stuff in it. // This is a file with stuff in it.
// This part shouldn't be changed by // This part shouldn't be changed by
// the template. // the template.
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - Block 1
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Token database version: 0.0
static final String tokenFoo = 'foo'; static final String tokenFoo = 'foo';
static final String tokenBar = 'bar'; static final String tokenBar = 'bar';
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - Block 1
// BEGIN GENERATED TOKEN PROPERTIES - Block 2
// Do not edit by hand. The code between the "BEGIN GENERATED" and
// "END GENERATED" comments are generated from data in the Material
// Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Token database version: 0.0
static final String tokenFoo = 'bar';
static final String tokenBar = 'foo';
// END GENERATED TOKEN PROPERTIES - Block 2
''');
// Update 'Block 1' again which should just update that block,
// leaving 'Block 2' undisturbed.
{
final Map<String, dynamic> tokens = <String, dynamic>{'version': '0.0', 'foo': 'FOO', 'bar': 'BAR'};
TestTemplate('Block 1', tempFile.path, tokens).updateFile();
}
expect(tempFile.readAsStringSync(), '''
// This is a file with stuff in it.
// This part shouldn't be changed by
// the template.
// BEGIN GENERATED TOKEN PROPERTIES - Block 1
// Do not edit by hand. The code between the "BEGIN GENERATED" and
// "END GENERATED" comments are generated from data in the Material
// Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Token database version: 0.0
static final String tokenFoo = 'FOO';
static final String tokenBar = 'BAR';
// END GENERATED TOKEN PROPERTIES - Block 1
// BEGIN GENERATED TOKEN PROPERTIES - Block 2
// Do not edit by hand. The code between the "BEGIN GENERATED" and
// "END GENERATED" comments are generated from data in the Material
// Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Token database version: 0.0
static final String tokenFoo = 'bar';
static final String tokenBar = 'foo';
// END GENERATED TOKEN PROPERTIES - Block 2
'''); ''');
} finally { } finally {
...@@ -113,14 +244,14 @@ static final String tokenBar = 'bar'; ...@@ -113,14 +244,14 @@ static final String tokenBar = 'bar';
'family': 'SHAPE_FAMILY_CIRCULAR', 'family': 'SHAPE_FAMILY_CIRCULAR',
}, },
}; };
final TestTemplate template = TestTemplate('foobar.dart', tokens); final TestTemplate template = TestTemplate('Test', 'foobar.dart', tokens);
expect(template.shape('foo'), 'const RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(1.0), topRight: Radius.circular(2.0), bottomLeft: Radius.circular(3.0), bottomRight: Radius.circular(4.0)))'); expect(template.shape('foo'), 'const RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(1.0), topRight: Radius.circular(2.0), bottomLeft: Radius.circular(3.0), bottomRight: Radius.circular(4.0)))');
expect(template.shape('bar'), 'const StadiumBorder()'); expect(template.shape('bar'), 'const StadiumBorder()');
}); });
} }
class TestTemplate extends TokenTemplate { class TestTemplate extends TokenTemplate {
TestTemplate(super.fileName, super.tokens); TestTemplate(super.blockName, super.fileName, super.tokens);
@override @override
String generate() => ''' String generate() => '''
......
...@@ -876,7 +876,7 @@ class _AppBarState extends State<AppBar> { ...@@ -876,7 +876,7 @@ class _AppBarState extends State<AppBar> {
assert(debugCheckHasMaterialLocalizations(context)); assert(debugCheckHasMaterialLocalizations(context));
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final AppBarTheme appBarTheme = AppBarTheme.of(context); final AppBarTheme appBarTheme = AppBarTheme.of(context);
final AppBarTheme defaults = theme.useMaterial3 ? _TokenDefaultsM3(context) : _DefaultsM2(context); final AppBarTheme defaults = theme.useMaterial3 ? _AppBarDefaultsM3(context) : _AppBarDefaultsM2(context);
final ScaffoldState? scaffold = Scaffold.maybeOf(context); final ScaffoldState? scaffold = Scaffold.maybeOf(context);
final ModalRoute<dynamic>? parentRoute = ModalRoute.of(context); final ModalRoute<dynamic>? parentRoute = ModalRoute.of(context);
...@@ -2284,8 +2284,9 @@ mixin _ScrollUnderFlexibleConfig { ...@@ -2284,8 +2284,9 @@ mixin _ScrollUnderFlexibleConfig {
EdgeInsetsGeometry? get expandedTitlePadding; EdgeInsetsGeometry? get expandedTitlePadding;
} }
class _DefaultsM2 extends AppBarTheme { // Hand coded defaults based on Material Design 2.
_DefaultsM2(this.context) class _AppBarDefaultsM2 extends AppBarTheme {
_AppBarDefaultsM2(this.context)
: super( : super(
elevation: 4.0, elevation: 4.0,
shadowColor: const Color(0xFF000000), shadowColor: const Color(0xFF000000),
...@@ -2313,15 +2314,17 @@ class _DefaultsM2 extends AppBarTheme { ...@@ -2313,15 +2314,17 @@ class _DefaultsM2 extends AppBarTheme {
TextStyle? get titleTextStyle => _theme.textTheme.headline6; TextStyle? get titleTextStyle => _theme.textTheme.headline6;
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - AppBar
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends AppBarTheme {
_TokenDefaultsM3(this.context) class _AppBarDefaultsM3 extends AppBarTheme {
_AppBarDefaultsM3(this.context)
: super( : super(
elevation: 0.0, elevation: 0.0,
scrolledUnderElevation: 3.0, scrolledUnderElevation: 3.0,
...@@ -2421,4 +2424,4 @@ class _LargeScrollUnderFlexibleConfig with _ScrollUnderFlexibleConfig { ...@@ -2421,4 +2424,4 @@ class _LargeScrollUnderFlexibleConfig with _ScrollUnderFlexibleConfig {
EdgeInsetsGeometry? get expandedTitlePadding => const EdgeInsets.fromLTRB(16, 0, 16, 28); EdgeInsetsGeometry? get expandedTitlePadding => const EdgeInsets.fromLTRB(16, 0, 16, 28);
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - AppBar
...@@ -161,7 +161,7 @@ class Card extends StatelessWidget { ...@@ -161,7 +161,7 @@ class Card extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final CardTheme cardTheme = CardTheme.of(context); final CardTheme cardTheme = CardTheme.of(context);
final CardTheme defaults = Theme.of(context).useMaterial3 ? _TokenDefaultsM3(context) : _DefaultsM2(context); final CardTheme defaults = Theme.of(context).useMaterial3 ? _CardDefaultsM3(context) : _CardDefaultsM2(context);
return Semantics( return Semantics(
container: semanticContainer, container: semanticContainer,
...@@ -186,8 +186,9 @@ class Card extends StatelessWidget { ...@@ -186,8 +186,9 @@ class Card extends StatelessWidget {
} }
} }
class _DefaultsM2 extends CardTheme { // Hand coded defaults based on Material Design 2.
const _DefaultsM2(this.context) class _CardDefaultsM2 extends CardTheme {
const _CardDefaultsM2(this.context)
: super( : super(
clipBehavior: Clip.none, clipBehavior: Clip.none,
elevation: 1.0, elevation: 1.0,
...@@ -206,15 +207,18 @@ class _DefaultsM2 extends CardTheme { ...@@ -206,15 +207,18 @@ class _DefaultsM2 extends CardTheme {
Color? get shadowColor => Theme.of(context).shadowColor; Color? get shadowColor => Theme.of(context).shadowColor;
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - Card
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Token database version: v0_101
// Generated version v0_101 // Generated version v0_101
class _TokenDefaultsM3 extends CardTheme { class _CardDefaultsM3 extends CardTheme {
const _TokenDefaultsM3(this.context) const _CardDefaultsM3(this.context)
: super( : super(
clipBehavior: Clip.none, clipBehavior: Clip.none,
elevation: 1.0, elevation: 1.0,
...@@ -234,4 +238,4 @@ class _TokenDefaultsM3 extends CardTheme { ...@@ -234,4 +238,4 @@ class _TokenDefaultsM3 extends CardTheme {
Color? get surfaceTintColor => Theme.of(context).colorScheme.surfaceTint; Color? get surfaceTintColor => Theme.of(context).colorScheme.surfaceTint;
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - Card
...@@ -149,7 +149,7 @@ class ActionChip extends StatelessWidget implements ChipAttributes, TappableChip ...@@ -149,7 +149,7 @@ class ActionChip extends StatelessWidget implements ChipAttributes, TappableChip
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterial(context));
final ChipThemeData? defaults = Theme.of(context).useMaterial3 final ChipThemeData? defaults = Theme.of(context).useMaterial3
? _TokenDefaultsM3(context, isEnabled) ? _ActionChipDefaultsM3(context, isEnabled)
: null; : null;
return RawChip( return RawChip(
defaultProperties: defaults, defaultProperties: defaults,
...@@ -178,15 +178,17 @@ class ActionChip extends StatelessWidget implements ChipAttributes, TappableChip ...@@ -178,15 +178,17 @@ class ActionChip extends StatelessWidget implements ChipAttributes, TappableChip
} }
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - ActionChip
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends ChipThemeData {
const _TokenDefaultsM3(this.context, this.isEnabled) class _ActionChipDefaultsM3 extends ChipThemeData {
const _ActionChipDefaultsM3(this.context, this.isEnabled)
: super( : super(
elevation: 0.0, elevation: 0.0,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0))), shape: const RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0))),
...@@ -248,4 +250,4 @@ class _TokenDefaultsM3 extends ChipThemeData { ...@@ -248,4 +250,4 @@ class _TokenDefaultsM3 extends ChipThemeData {
)!; )!;
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - ActionChip
...@@ -177,7 +177,7 @@ class ChoiceChip extends StatelessWidget ...@@ -177,7 +177,7 @@ class ChoiceChip extends StatelessWidget
assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterial(context));
final ChipThemeData chipTheme = ChipTheme.of(context); final ChipThemeData chipTheme = ChipTheme.of(context);
final ChipThemeData? defaults = Theme.of(context).useMaterial3 final ChipThemeData? defaults = Theme.of(context).useMaterial3
? _TokenDefaultsM3(context, isEnabled, selected) ? _FilterChipDefaultsM3(context, isEnabled, selected)
: null; : null;
return RawChip( return RawChip(
defaultProperties: defaults, defaultProperties: defaults,
...@@ -211,15 +211,17 @@ class ChoiceChip extends StatelessWidget ...@@ -211,15 +211,17 @@ class ChoiceChip extends StatelessWidget
} }
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - FilterChip
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends ChipThemeData {
const _TokenDefaultsM3(this.context, this.isEnabled, this.isSelected) class _FilterChipDefaultsM3 extends ChipThemeData {
const _FilterChipDefaultsM3(this.context, this.isEnabled, this.isSelected)
: super( : super(
elevation: 0.0, elevation: 0.0,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0))), shape: const RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0))),
...@@ -288,4 +290,4 @@ class _TokenDefaultsM3 extends ChipThemeData { ...@@ -288,4 +290,4 @@ class _TokenDefaultsM3 extends ChipThemeData {
)!; )!;
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - FilterChip
...@@ -215,7 +215,7 @@ class FilterChip extends StatelessWidget ...@@ -215,7 +215,7 @@ class FilterChip extends StatelessWidget
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterial(context));
final ChipThemeData? defaults = Theme.of(context).useMaterial3 final ChipThemeData? defaults = Theme.of(context).useMaterial3
? _TokenDefaultsM3(context, isEnabled, selected) ? _FilterChipDefaultsM3(context, isEnabled, selected)
: null; : null;
return RawChip( return RawChip(
defaultProperties: defaults, defaultProperties: defaults,
...@@ -250,15 +250,17 @@ class FilterChip extends StatelessWidget ...@@ -250,15 +250,17 @@ class FilterChip extends StatelessWidget
} }
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - FilterChip
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends ChipThemeData {
const _TokenDefaultsM3(this.context, this.isEnabled, this.isSelected) class _FilterChipDefaultsM3 extends ChipThemeData {
const _FilterChipDefaultsM3(this.context, this.isEnabled, this.isSelected)
: super( : super(
elevation: 0.0, elevation: 0.0,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0))), shape: const RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0))),
...@@ -327,4 +329,4 @@ class _TokenDefaultsM3 extends ChipThemeData { ...@@ -327,4 +329,4 @@ class _TokenDefaultsM3 extends ChipThemeData {
)!; )!;
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - FilterChip
...@@ -206,7 +206,7 @@ class InputChip extends StatelessWidget ...@@ -206,7 +206,7 @@ class InputChip extends StatelessWidget
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterial(context));
final ChipThemeData? defaults = Theme.of(context).useMaterial3 final ChipThemeData? defaults = Theme.of(context).useMaterial3
? _TokenDefaultsM3(context, isEnabled) ? _InputChipDefaultsM3(context, isEnabled)
: null; : null;
final Widget? resolvedDeleteIcon = deleteIcon final Widget? resolvedDeleteIcon = deleteIcon
?? (Theme.of(context).useMaterial3 ? const Icon(Icons.clear, size: 18) : null); ?? (Theme.of(context).useMaterial3 ? const Icon(Icons.clear, size: 18) : null);
...@@ -249,15 +249,17 @@ class InputChip extends StatelessWidget ...@@ -249,15 +249,17 @@ class InputChip extends StatelessWidget
} }
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - InputChip
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends ChipThemeData {
const _TokenDefaultsM3(this.context, this.isEnabled) class _InputChipDefaultsM3 extends ChipThemeData {
const _InputChipDefaultsM3(this.context, this.isEnabled)
: super( : super(
elevation: 0.0, elevation: 0.0,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0))), shape: const RoundedRectangleBorder(borderRadius: BorderRadius.only(topLeft: Radius.circular(8.0), topRight: Radius.circular(8.0), bottomLeft: Radius.circular(8.0), bottomRight: Radius.circular(8.0))),
...@@ -319,4 +321,4 @@ class _TokenDefaultsM3 extends ChipThemeData { ...@@ -319,4 +321,4 @@ class _TokenDefaultsM3 extends ChipThemeData {
)!; )!;
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - InputChip
...@@ -135,7 +135,7 @@ class Dialog extends StatelessWidget { ...@@ -135,7 +135,7 @@ class Dialog extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final DialogTheme dialogTheme = DialogTheme.of(context); final DialogTheme dialogTheme = DialogTheme.of(context);
final DialogTheme defaults = theme.useMaterial3 ? _TokenDefaultsM3(context) : _DefaultsM2(context); final DialogTheme defaults = theme.useMaterial3 ? _DialogDefaultsM3(context) : _DialogDefaultsM2(context);
final EdgeInsets effectivePadding = MediaQuery.of(context).viewInsets + (insetPadding ?? EdgeInsets.zero); final EdgeInsets effectivePadding = MediaQuery.of(context).viewInsets + (insetPadding ?? EdgeInsets.zero);
return AnimatedPadding( return AnimatedPadding(
...@@ -522,7 +522,7 @@ class AlertDialog extends StatelessWidget { ...@@ -522,7 +522,7 @@ class AlertDialog extends StatelessWidget {
assert(debugCheckHasMaterialLocalizations(context)); assert(debugCheckHasMaterialLocalizations(context));
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final DialogTheme dialogTheme = DialogTheme.of(context); final DialogTheme dialogTheme = DialogTheme.of(context);
final DialogTheme defaults = theme.useMaterial3 ? _TokenDefaultsM3(context) : _DefaultsM2(context); final DialogTheme defaults = theme.useMaterial3 ? _DialogDefaultsM3(context) : _DialogDefaultsM2(context);
String? label = semanticLabel; String? label = semanticLabel;
switch (theme.platform) { switch (theme.platform) {
...@@ -1275,12 +1275,9 @@ double _paddingScaleFactor(double textScaleFactor) { ...@@ -1275,12 +1275,9 @@ double _paddingScaleFactor(double textScaleFactor) {
return lerpDouble(1.0, 1.0 / 3.0, clampedTextScaleFactor - 1.0)!; return lerpDouble(1.0, 1.0 / 3.0, clampedTextScaleFactor - 1.0)!;
} }
// Generate a DialogTheme that represents the M2 default values. // Hand coded defaults based on Material Design 2.
// This was generated by hand from the previous hand coded defaults class _DialogDefaultsM2 extends DialogTheme {
// for M2. It uses get method overrides instead of properties to _DialogDefaultsM2(this.context)
// avoid computing values that we may not need upfront.
class _DefaultsM2 extends DialogTheme {
_DefaultsM2(this.context)
: _textTheme = Theme.of(context).textTheme, : _textTheme = Theme.of(context).textTheme,
_iconTheme = Theme.of(context).iconTheme, _iconTheme = Theme.of(context).iconTheme,
super( super(
...@@ -1309,15 +1306,17 @@ class _DefaultsM2 extends DialogTheme { ...@@ -1309,15 +1306,17 @@ class _DefaultsM2 extends DialogTheme {
EdgeInsetsGeometry? get actionsPadding => EdgeInsets.zero; EdgeInsetsGeometry? get actionsPadding => EdgeInsets.zero;
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - Dialog
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends DialogTheme {
_TokenDefaultsM3(this.context) class _DialogDefaultsM3 extends DialogTheme {
_DialogDefaultsM3(this.context)
: super( : super(
alignment: Alignment.center, alignment: Alignment.center,
elevation: 6.0, elevation: 6.0,
...@@ -1345,4 +1344,4 @@ class _TokenDefaultsM3 extends DialogTheme { ...@@ -1345,4 +1344,4 @@ class _TokenDefaultsM3 extends DialogTheme {
EdgeInsetsGeometry? get actionsPadding => const EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0); EdgeInsetsGeometry? get actionsPadding => const EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0);
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - Dialog
...@@ -339,7 +339,7 @@ class ElevatedButton extends ButtonStyleButton { ...@@ -339,7 +339,7 @@ class ElevatedButton extends ButtonStyleButton {
final ColorScheme colorScheme = theme.colorScheme; final ColorScheme colorScheme = theme.colorScheme;
return Theme.of(context).useMaterial3 return Theme.of(context).useMaterial3
? _TokenDefaultsM3(context) ? _ElevatedButtonDefaultsM3(context)
: styleFrom( : styleFrom(
backgroundColor: colorScheme.primary, backgroundColor: colorScheme.primary,
foregroundColor: colorScheme.onPrimary, foregroundColor: colorScheme.onPrimary,
...@@ -506,15 +506,17 @@ class _ElevatedButtonWithIconChild extends StatelessWidget { ...@@ -506,15 +506,17 @@ class _ElevatedButtonWithIconChild extends StatelessWidget {
} }
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - ElevatedButton
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends ButtonStyle {
_TokenDefaultsM3(this.context) class _ElevatedButtonDefaultsM3 extends ButtonStyle {
_ElevatedButtonDefaultsM3(this.context)
: super( : super(
animationDuration: kThemeChangeDuration, animationDuration: kThemeChangeDuration,
enableFeedback: true, enableFeedback: true,
...@@ -626,4 +628,4 @@ class _TokenDefaultsM3 extends ButtonStyle { ...@@ -626,4 +628,4 @@ class _TokenDefaultsM3 extends ButtonStyle {
InteractiveInkFeatureFactory? get splashFactory => Theme.of(context).splashFactory; InteractiveInkFeatureFactory? get splashFactory => Theme.of(context).splashFactory;
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - ElevatedButton
...@@ -151,13 +151,14 @@ class _ElevationOpacity { ...@@ -151,13 +151,14 @@ class _ElevationOpacity {
final double opacity; final double opacity;
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - SurfaceTint
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
// Surface tint opacities based on elevations according to the // Surface tint opacities based on elevations according to the
// Material Design 3 specification: // Material Design 3 specification:
...@@ -172,4 +173,4 @@ const List<_ElevationOpacity> _surfaceTintElevationOpacities = <_ElevationOpacit ...@@ -172,4 +173,4 @@ const List<_ElevationOpacity> _surfaceTintElevationOpacities = <_ElevationOpacit
_ElevationOpacity(12.0, 0.14), // Elevation level 5 _ElevationOpacity(12.0, 0.14), // Elevation level 5
]; ];
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - SurfaceTint
...@@ -513,8 +513,8 @@ class FloatingActionButton extends StatelessWidget { ...@@ -513,8 +513,8 @@ class FloatingActionButton extends StatelessWidget {
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final FloatingActionButtonThemeData floatingActionButtonTheme = theme.floatingActionButtonTheme; final FloatingActionButtonThemeData floatingActionButtonTheme = theme.floatingActionButtonTheme;
final FloatingActionButtonThemeData defaults = theme.useMaterial3 final FloatingActionButtonThemeData defaults = theme.useMaterial3
? _TokenDefaultsM3(context, _floatingActionButtonType, child != null) ? _FABDefaultsM3(context, _floatingActionButtonType, child != null)
: _M2Defaults(context, _floatingActionButtonType, child != null); : _FABDefaultsM2(context, _floatingActionButtonType, child != null);
final Color foregroundColor = this.foregroundColor final Color foregroundColor = this.foregroundColor
?? floatingActionButtonTheme.foregroundColor ?? floatingActionButtonTheme.foregroundColor
...@@ -727,13 +727,9 @@ class _RenderChildOverflowBox extends RenderAligningShiftedBox { ...@@ -727,13 +727,9 @@ class _RenderChildOverflowBox extends RenderAligningShiftedBox {
} }
} }
// Generate a FloatingActionButtonThemeData that represents // Hand coded defaults based on Material Design 2.
// the M2 default values. This was generated by hand from the class _FABDefaultsM2 extends FloatingActionButtonThemeData {
// previous hand coded defaults for M2. It uses get method overrides _FABDefaultsM2(BuildContext context, this.type, this.hasChild)
// instead of properties to avoid computing values that we may not
// need upfront.
class _M2Defaults extends FloatingActionButtonThemeData {
_M2Defaults(BuildContext context, this.type, this.hasChild)
: _theme = Theme.of(context), : _theme = Theme.of(context),
_colors = Theme.of(context).colorScheme, _colors = Theme.of(context).colorScheme,
super( super(
...@@ -780,15 +776,17 @@ class _M2Defaults extends FloatingActionButtonThemeData { ...@@ -780,15 +776,17 @@ class _M2Defaults extends FloatingActionButtonThemeData {
@override TextStyle? get extendedTextStyle => _theme.textTheme.button!.copyWith(letterSpacing: 1.2); @override TextStyle? get extendedTextStyle => _theme.textTheme.button!.copyWith(letterSpacing: 1.2);
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - FAB
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends FloatingActionButtonThemeData {
_TokenDefaultsM3(this.context, this.type, this.hasChild) class _FABDefaultsM3 extends FloatingActionButtonThemeData {
_FABDefaultsM3(this.context, this.type, this.hasChild)
: super( : super(
elevation: 6.0, elevation: 6.0,
focusElevation: 6.0, focusElevation: 6.0,
...@@ -855,4 +853,4 @@ class _TokenDefaultsM3 extends FloatingActionButtonThemeData { ...@@ -855,4 +853,4 @@ class _TokenDefaultsM3 extends FloatingActionButtonThemeData {
@override TextStyle? get extendedTextStyle => _textTheme.labelLarge; @override TextStyle? get extendedTextStyle => _textTheme.labelLarge;
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - FAB
...@@ -775,7 +775,7 @@ class _IconButtonM3 extends ButtonStyleButton { ...@@ -775,7 +775,7 @@ class _IconButtonM3 extends ButtonStyleButton {
/// * `splashFactory` - Theme.splashFactory /// * `splashFactory` - Theme.splashFactory
@override @override
ButtonStyle defaultStyleOf(BuildContext context) { ButtonStyle defaultStyleOf(BuildContext context) {
return _TokenDefaultsM3(context); return _IconButtonDefaultsM3(context);
} }
/// Returns null because [IconButton] doesn't have its component theme. /// Returns null because [IconButton] doesn't have its component theme.
...@@ -883,15 +883,17 @@ class _IconButtonDefaultMouseCursor extends MaterialStateProperty<MouseCursor> w ...@@ -883,15 +883,17 @@ class _IconButtonDefaultMouseCursor extends MaterialStateProperty<MouseCursor> w
} }
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - IconButton
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends ButtonStyle {
_TokenDefaultsM3(this.context) class _IconButtonDefaultsM3 extends ButtonStyle {
_IconButtonDefaultsM3(this.context)
: super( : super(
animationDuration: kThemeChangeDuration, animationDuration: kThemeChangeDuration,
enableFeedback: true, enableFeedback: true,
...@@ -992,4 +994,4 @@ class _TokenDefaultsM3 extends ButtonStyle { ...@@ -992,4 +994,4 @@ class _TokenDefaultsM3 extends ButtonStyle {
InteractiveInkFeatureFactory? get splashFactory => Theme.of(context).splashFactory; InteractiveInkFeatureFactory? get splashFactory => Theme.of(context).splashFactory;
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - IconButton
...@@ -1173,11 +1173,12 @@ bool _isForwardOrCompleted(Animation<double> animation) { ...@@ -1173,11 +1173,12 @@ bool _isForwardOrCompleted(Animation<double> animation) {
} }
NavigationBarThemeData _defaultsFor(BuildContext context) { NavigationBarThemeData _defaultsFor(BuildContext context) {
return Theme.of(context).useMaterial3 ? _TokenDefaultsM3(context) : _Defaults(context); return Theme.of(context).useMaterial3 ? _NavigationBarDefaultsM3(context) : _NavigationBarDefaultsM2(context);
} }
class _Defaults extends NavigationBarThemeData { // Hand coded defaults based on Material Design 2.
_Defaults(BuildContext context) class _NavigationBarDefaultsM2 extends NavigationBarThemeData {
_NavigationBarDefaultsM2(BuildContext context)
: _theme = Theme.of(context), : _theme = Theme.of(context),
_colors = Theme.of(context).colorScheme, _colors = Theme.of(context).colorScheme,
super( super(
...@@ -1190,7 +1191,7 @@ class _Defaults extends NavigationBarThemeData { ...@@ -1190,7 +1191,7 @@ class _Defaults extends NavigationBarThemeData {
final ThemeData _theme; final ThemeData _theme;
final ColorScheme _colors; final ColorScheme _colors;
// With Material 3, the NavigationBar uses an overlay blend for the // With Material 2, the NavigationBar uses an overlay blend for the
// default color regardless of light/dark mode. // default color regardless of light/dark mode.
@override Color? get backgroundColor => ElevationOverlay.colorWithOverlay(_colors.surface, _colors.onSurface, 3.0); @override Color? get backgroundColor => ElevationOverlay.colorWithOverlay(_colors.surface, _colors.onSurface, 3.0);
...@@ -1206,15 +1207,17 @@ class _Defaults extends NavigationBarThemeData { ...@@ -1206,15 +1207,17 @@ class _Defaults extends NavigationBarThemeData {
@override MaterialStateProperty<TextStyle?>? get labelTextStyle => MaterialStatePropertyAll<TextStyle?>(_theme.textTheme.overline!.copyWith(color: _colors.onSurface)); @override MaterialStateProperty<TextStyle?>? get labelTextStyle => MaterialStatePropertyAll<TextStyle?>(_theme.textTheme.overline!.copyWith(color: _colors.onSurface));
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - NavigationBar
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends NavigationBarThemeData {
_TokenDefaultsM3(this.context) class _NavigationBarDefaultsM3 extends NavigationBarThemeData {
_NavigationBarDefaultsM3(this.context)
: super( : super(
height: 80.0, height: 80.0,
elevation: 3.0, elevation: 3.0,
...@@ -1254,4 +1257,4 @@ class _TokenDefaultsM3 extends NavigationBarThemeData { ...@@ -1254,4 +1257,4 @@ class _TokenDefaultsM3 extends NavigationBarThemeData {
} }
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - NavigationBar
...@@ -379,7 +379,7 @@ class _NavigationRailState extends State<NavigationRail> with TickerProviderStat ...@@ -379,7 +379,7 @@ class _NavigationRailState extends State<NavigationRail> with TickerProviderStat
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final NavigationRailThemeData navigationRailTheme = NavigationRailTheme.of(context); final NavigationRailThemeData navigationRailTheme = NavigationRailTheme.of(context);
final NavigationRailThemeData defaults = Theme.of(context).useMaterial3 ? _TokenDefaultsM3(context) : _DefaultsM2(context); final NavigationRailThemeData defaults = Theme.of(context).useMaterial3 ? _NavigationRailDefaultsM3(context) : _NavigationRailDefaultsM2(context);
final MaterialLocalizations localizations = MaterialLocalizations.of(context); final MaterialLocalizations localizations = MaterialLocalizations.of(context);
final Color backgroundColor = widget.backgroundColor ?? navigationRailTheme.backgroundColor ?? defaults.backgroundColor!; final Color backgroundColor = widget.backgroundColor ?? navigationRailTheme.backgroundColor ?? defaults.backgroundColor!;
...@@ -910,8 +910,9 @@ const Widget _verticalSpacer = SizedBox(height: 8.0); ...@@ -910,8 +910,9 @@ const Widget _verticalSpacer = SizedBox(height: 8.0);
const double _verticalIconLabelSpacingM3 = 4.0; const double _verticalIconLabelSpacingM3 = 4.0;
const double _verticalDestinationSpacingM3 = 12.0; const double _verticalDestinationSpacingM3 = 12.0;
class _DefaultsM2 extends NavigationRailThemeData { // Hand coded defaults based on Material Design 2.
_DefaultsM2(BuildContext context) class _NavigationRailDefaultsM2 extends NavigationRailThemeData {
_NavigationRailDefaultsM2(BuildContext context)
: _theme = Theme.of(context), : _theme = Theme.of(context),
_colors = Theme.of(context).colorScheme, _colors = Theme.of(context).colorScheme,
super( super(
...@@ -953,15 +954,17 @@ class _DefaultsM2 extends NavigationRailThemeData { ...@@ -953,15 +954,17 @@ class _DefaultsM2 extends NavigationRailThemeData {
} }
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - NavigationRail
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends NavigationRailThemeData {
_TokenDefaultsM3(this.context) class _NavigationRailDefaultsM3 extends NavigationRailThemeData {
_NavigationRailDefaultsM3(this.context)
: super( : super(
elevation: 0.0, elevation: 0.0,
groupAlignment: -1, groupAlignment: -1,
...@@ -1003,4 +1006,4 @@ class _TokenDefaultsM3 extends NavigationRailThemeData { ...@@ -1003,4 +1006,4 @@ class _TokenDefaultsM3 extends NavigationRailThemeData {
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - NavigationRail
...@@ -306,7 +306,7 @@ class OutlinedButton extends ButtonStyleButton { ...@@ -306,7 +306,7 @@ class OutlinedButton extends ButtonStyleButton {
final ColorScheme colorScheme = theme.colorScheme; final ColorScheme colorScheme = theme.colorScheme;
return Theme.of(context).useMaterial3 return Theme.of(context).useMaterial3
? _TokenDefaultsM3(context) ? _OutlinedButtonDefaultsM3(context)
: styleFrom( : styleFrom(
foregroundColor: colorScheme.primary, foregroundColor: colorScheme.primary,
disabledForegroundColor: colorScheme.onSurface.withOpacity(0.38), disabledForegroundColor: colorScheme.onSurface.withOpacity(0.38),
...@@ -438,15 +438,17 @@ class _OutlinedButtonWithIconChild extends StatelessWidget { ...@@ -438,15 +438,17 @@ class _OutlinedButtonWithIconChild extends StatelessWidget {
} }
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - OutlinedButton
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends ButtonStyle {
_TokenDefaultsM3(this.context) class _OutlinedButtonDefaultsM3 extends ButtonStyle {
_OutlinedButtonDefaultsM3(this.context)
: super( : super(
animationDuration: kThemeChangeDuration, animationDuration: kThemeChangeDuration,
enableFeedback: true, enableFeedback: true,
...@@ -542,4 +544,4 @@ class _TokenDefaultsM3 extends ButtonStyle { ...@@ -542,4 +544,4 @@ class _TokenDefaultsM3 extends ButtonStyle {
InteractiveInkFeatureFactory? get splashFactory => Theme.of(context).splashFactory; InteractiveInkFeatureFactory? get splashFactory => Theme.of(context).splashFactory;
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - OutlinedButton
...@@ -327,7 +327,7 @@ class TextButton extends ButtonStyleButton { ...@@ -327,7 +327,7 @@ class TextButton extends ButtonStyleButton {
final ColorScheme colorScheme = theme.colorScheme; final ColorScheme colorScheme = theme.colorScheme;
return Theme.of(context).useMaterial3 return Theme.of(context).useMaterial3
? _TokenDefaultsM3(context) ? _TextButtonDefaultsM3(context)
: styleFrom( : styleFrom(
foregroundColor: colorScheme.primary, foregroundColor: colorScheme.primary,
disabledForegroundColor: colorScheme.onSurface.withOpacity(0.38), disabledForegroundColor: colorScheme.onSurface.withOpacity(0.38),
...@@ -483,15 +483,17 @@ class _TextButtonWithIconChild extends StatelessWidget { ...@@ -483,15 +483,17 @@ class _TextButtonWithIconChild extends StatelessWidget {
} }
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - TextButton
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Generated version v0_101 // Token database version: v0_101
class _TokenDefaultsM3 extends ButtonStyle {
_TokenDefaultsM3(this.context) class _TextButtonDefaultsM3 extends ButtonStyle {
_TextButtonDefaultsM3(this.context)
: super( : super(
animationDuration: kThemeChangeDuration, animationDuration: kThemeChangeDuration,
enableFeedback: true, enableFeedback: true,
...@@ -580,4 +582,4 @@ class _TokenDefaultsM3 extends ButtonStyle { ...@@ -580,4 +582,4 @@ class _TokenDefaultsM3 extends ButtonStyle {
InteractiveInkFeatureFactory? get splashFactory => Theme.of(context).splashFactory; InteractiveInkFeatureFactory? get splashFactory => Theme.of(context).splashFactory;
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - TextButton
...@@ -729,13 +729,15 @@ class Typography with Diagnosticable { ...@@ -729,13 +729,15 @@ class Typography with Diagnosticable {
static const TextTheme tall2021 = _M3Typography.tall; static const TextTheme tall2021 = _M3Typography.tall;
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES - Typography
// Generated code to the end of this file. Do not edit by hand. // Do not edit by hand. The code between the "BEGIN GENERATED" and
// These defaults are generated from the Material Design Token // "END GENERATED" comments are generated from data in the Material
// database by the script dev/tools/gen_defaults/bin/gen_defaults.dart. // Design token database by the script:
// dev/tools/gen_defaults/bin/gen_defaults.dart.
// Token database version: v0_101
// Generated version v0_101
class _M3Typography { class _M3Typography {
_M3Typography._(); _M3Typography._();
...@@ -794,4 +796,4 @@ class _M3Typography { ...@@ -794,4 +796,4 @@ class _M3Typography {
); );
} }
// END GENERATED TOKEN PROPERTIES // END GENERATED TOKEN PROPERTIES - Typography
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment