Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions packages/material_ui/lib/src/divider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import 'package:flutter/widgets.dart';
import 'divider_theme.dart';
import 'theme.dart';

part 'generated/divider_defaults_m3.g.dart';

// Examples can assume:
// late BuildContext context;

Expand Down Expand Up @@ -383,27 +385,3 @@ class _DividerDefaultsM2 extends DividerThemeData {
@override
Color? get color => Theme.of(context).dividerColor;
}

// BEGIN GENERATED TOKEN PROPERTIES - Divider

// 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.

// dart format off
class _DividerDefaultsM3 extends DividerThemeData {
const _DividerDefaultsM3(this.context) : super(
space: 16,
thickness: 1.0,
indent: 0,
endIndent: 0,
);

final BuildContext context;

@override Color? get color => Theme.of(context).colorScheme.outlineVariant;
}
// dart format on

// END GENERATED TOKEN PROPERTIES - Divider
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Do not edit by hand. The code is generated from data in the Material
// Design token database by the script:
// packages/material_ui/tool/gen_defaults/bin/gen_defaults.dart.
part of '../divider.dart';

class _DividerDefaultsM3 extends DividerThemeData {
const _DividerDefaultsM3(this.context)
: super(space: 16, thickness: 1.0, indent: 0, endIndent: 0);
Expand Down
5 changes: 3 additions & 2 deletions packages/material_ui/tool/gen_defaults/bin/gen_defaults.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import '../templates/chip_template.dart';
import '../templates/color_scheme_template.dart';
// import '../templates/date_picker_template.dart';
// import '../templates/dialog_template.dart';
// import '../templates/divider_template.dart';
import '../templates/divider_template.dart';

// import '../templates/drawer_template.dart';
// import '../templates/expansion_tile_template.dart';
// import '../templates/fab_template.dart';
Expand Down Expand Up @@ -84,7 +85,7 @@ Future<void> main(List<String> args) async {
const ColorSchemeTemplateM3().generateFile(verbose: verbose);
// const DatePickerTemplateM3().generateFile(verbose: verbose);
// const DialogTemplateM3().generateFile(verbose: verbose);
// const DividerTemplateM3().generateFile(verbose: verbose);
const DividerTemplateM3().generateFile(verbose: verbose);
// const DrawerTemplateM3().generateFile(verbose: verbose);
// const ExpansionTileTemplateM3().generateFile(verbose: verbose);
// const FabTemplateM3().generateFile(verbose: verbose);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2013 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import '../data/divider.dart';
import 'template.dart';

class DividerTemplateM3 extends TokenTemplateM3 {
const DividerTemplateM3();

@override
String get name => 'Divider';

@override
String get parentFilePath => 'divider.dart';

@override
String generateContents(String className) =>
'''
class $className extends DividerThemeData {
const $className(this.context) : super(
space: 16,
thickness: ${TokenDivider.thickness},
indent: 0,
endIndent: 0,
);

final BuildContext context;

@override Color? get color => ${color(TokenDivider.color, 'Theme.of(context).colorScheme')};
}
''';
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import '../templates/chip_template.dart';
import '../templates/color_scheme_template.dart';
// import '../templates/date_picker_template.dart';
// import '../templates/dialog_template.dart';
// import '../templates/divider_template.dart';
import '../templates/divider_template.dart';
// import '../templates/drawer_template.dart';
// import '../templates/expansion_tile_template.dart';
// import '../templates/fab_template.dart';
Expand Down Expand Up @@ -552,8 +552,13 @@ void main() {
});

test('DividerTemplateM3 emits M3 Divider defaults from tokens', () {
// Intentionally empty, will be implemented during migration. See:
// https://github.com/flutter/flutter/issues/187899
final String contents = _generateContents(const DividerTemplateM3());
expect(contents, contains('class _DividerDefaultsM3 extends DividerThemeData'));
expect(contents, contains('thickness: 1.0'));
expect(
contents,
contains('Color? get color => Theme.of(context).colorScheme.outlineVariant;'),
);
});

test('DrawerTemplateM3 emits M3 Drawer defaults from tokens', () {
Expand Down
Loading