Unverified Commit 0bb1e573 authored by Per Classon's avatar Per Classon Committed by GitHub

Revert "Add DataTableTheme to allow for themable DataTables (#64316)" (#65382)

This reverts commit cb4b8677.
parent e10bdbbd
...@@ -52,7 +52,6 @@ export 'src/material/constants.dart'; ...@@ -52,7 +52,6 @@ export 'src/material/constants.dart';
export 'src/material/curves.dart'; export 'src/material/curves.dart';
export 'src/material/data_table.dart'; export 'src/material/data_table.dart';
export 'src/material/data_table_source.dart'; export 'src/material/data_table_source.dart';
export 'src/material/data_table_theme.dart';
export 'src/material/debug.dart'; export 'src/material/debug.dart';
export 'src/material/dialog.dart'; export 'src/material/dialog.dart';
export 'src/material/dialog_theme.dart'; export 'src/material/dialog_theme.dart';
......
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'material_state.dart';
import 'theme.dart';
/// Defines default property values for descendant [DataTable]
/// widgets.
///
/// Descendant widgets obtain the current [DataTableThemeData] object
/// using `DataTableTheme.of(context)`. Instances of
/// [DataTableThemeData] can be customized with
/// [DataTableThemeData.copyWith].
///
/// Typically a [DataTableThemeData] is specified as part of the
/// overall [Theme] with [ThemeData.dataTableTheme].
///
/// All [DataTableThemeData] properties are `null` by default. When
/// null, the [DataTable] will use the values from [ThemeData] if they exist,
/// otherwise it will provide its own defaults based on the overall [Theme]'s
/// textTheme and colorScheme. See the individual [DataTable] properties for
/// details.
///
/// See also:
///
/// * [ThemeData], which describes the overall theme information for the
/// application.
@immutable
class DataTableThemeData with Diagnosticable {
/// Creates a theme that can be used for [ThemeData.dataTableTheme].
const DataTableThemeData({
this.decoration,
this.dataRowColor,
this.dataRowHeight,
this.dataTextStyle,
this.headingRowColor,
this.headingRowHeight,
this.headingTextStyle,
this.horizontalMargin,
this.columnSpacing,
this.dividerThickness,
});
/// {@macro flutter.material.dataTable.decoration}
final Decoration decoration;
/// {@macro flutter.material.dataTable.dataRowColor}
/// {@macro flutter.material.dataTable.dataRowColorCode}
final MaterialStateProperty<Color> dataRowColor;
/// {@macro flutter.material.dataTable.dataRowHeight}
final double dataRowHeight;
/// {@macro flutter.material.dataTable.dataTextStyle}
final TextStyle dataTextStyle;
/// {@macro flutter.material.dataTable.headingRowColor}
final MaterialStateProperty<Color> headingRowColor;
/// {@macro flutter.material.dataTable.headingRowHeight}
final double headingRowHeight;
/// {@macro flutter.material.dataTable.headingTextStyle}
final TextStyle headingTextStyle;
/// {@macro flutter.material.dataTable.horizontalMargin}
final double horizontalMargin;
/// {@macro flutter.material.dataTable.columnSpacing}
final double columnSpacing;
/// {@macro flutter.material.dataTable.dividerThickness}
final double dividerThickness;
/// Creates a copy of this object but with the given fields replaced with the
/// new values.
DataTableThemeData copyWith({
Decoration decoration,
MaterialStateProperty<Color> dataRowColor,
double dataRowHeight,
TextStyle dataTextStyle,
MaterialStateProperty<Color> headingRowColor,
double headingRowHeight,
TextStyle headingTextStyle,
double horizontalMargin,
double columnSpacing,
double dividerThickness,
}) {
return DataTableThemeData(
decoration: decoration ?? this.decoration,
dataRowColor: dataRowColor ?? this.dataRowColor,
dataRowHeight: dataRowHeight ?? this.dataRowHeight,
dataTextStyle: dataTextStyle ?? this.dataTextStyle,
headingRowColor: headingRowColor ?? this.headingRowColor,
headingRowHeight: headingRowHeight ?? this.headingRowHeight,
headingTextStyle: headingTextStyle ?? this.headingTextStyle,
horizontalMargin: horizontalMargin ?? this.horizontalMargin,
columnSpacing: columnSpacing ?? this.columnSpacing,
dividerThickness: dividerThickness ?? this.dividerThickness,
);
}
/// Linearly interpolate between two [DataTableThemeData]s.
///
/// The argument `t` must not be null.
///
/// {@macro dart.ui.shadow.lerp}
static DataTableThemeData lerp(DataTableThemeData a, DataTableThemeData b, double t) {
assert(t != null);
return DataTableThemeData(
decoration: Decoration.lerp(a.decoration, b.decoration, t),
dataRowColor: _lerpProperties(a.dataRowColor, b.dataRowColor, t, Color.lerp),
dataRowHeight: lerpDouble(a.dataRowHeight, b.dataRowHeight, t),
dataTextStyle: TextStyle.lerp(a.dataTextStyle, b.dataTextStyle, t),
headingRowColor: _lerpProperties(a.headingRowColor, b.headingRowColor, t, Color.lerp),
headingRowHeight: lerpDouble(a.headingRowHeight, b.headingRowHeight, t),
headingTextStyle: TextStyle.lerp(a.headingTextStyle, b.headingTextStyle, t),
horizontalMargin: lerpDouble(a.horizontalMargin, b.horizontalMargin, t),
columnSpacing: lerpDouble(a.columnSpacing, b.columnSpacing, t),
dividerThickness: lerpDouble(a.dividerThickness, b.dividerThickness, t)
);
}
@override
int get hashCode {
return hashValues(
decoration,
dataRowColor,
dataRowHeight,
dataTextStyle,
headingRowColor,
headingRowHeight,
headingTextStyle,
horizontalMargin,
columnSpacing,
dividerThickness,
);
}
@override
bool operator ==(Object other) {
if (identical(this, other))
return true;
if (other.runtimeType != runtimeType)
return false;
return other is DataTableThemeData
&& other.decoration == decoration
&& other.dataRowColor == dataRowColor
&& other.dataRowHeight == dataRowHeight
&& other.dataTextStyle == dataTextStyle
&& other.headingRowColor == headingRowColor
&& other.headingRowHeight == headingRowHeight
&& other.headingTextStyle == headingTextStyle
&& other.horizontalMargin == horizontalMargin
&& other.columnSpacing == columnSpacing
&& other.dividerThickness == dividerThickness;
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<Decoration>('decoration', decoration, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Color>>('dataRowColor', dataRowColor, defaultValue: null));
properties.add(DoubleProperty('dataRowHeight', dataRowHeight, defaultValue: null));
properties.add(DiagnosticsProperty<TextStyle>('dataTextStyle', dataTextStyle, defaultValue: null));
properties.add(DiagnosticsProperty<MaterialStateProperty<Color>>('headingRowColor', headingRowColor, defaultValue: null));
properties.add(DoubleProperty('headingRowHeight', headingRowHeight, defaultValue: null));
properties.add(DiagnosticsProperty<TextStyle>('headingTextStyle', headingTextStyle, defaultValue: null));
properties.add(DoubleProperty('horizontalMargin', horizontalMargin, defaultValue: null));
properties.add(DoubleProperty('columnSpacing', columnSpacing, defaultValue: null));
properties.add(DoubleProperty('dividerThickness', dividerThickness, defaultValue: null));
}
static MaterialStateProperty<T> _lerpProperties<T>(MaterialStateProperty<T> a, MaterialStateProperty<T> b, double t, T Function(T, T, double) lerpFunction ) {
// Avoid creating a _LerpProperties object for a common case.
if (a == null && b == null)
return null;
return _LerpProperties<T>(a, b, t, lerpFunction);
}
}
class _LerpProperties<T> implements MaterialStateProperty<T> {
const _LerpProperties(this.a, this.b, this.t, this.lerpFunction);
final MaterialStateProperty<T> a;
final MaterialStateProperty<T> b;
final double t;
final T Function(T, T, double) lerpFunction;
@override
T resolve(Set<MaterialState> states) {
final T resolvedA = a?.resolve(states);
final T resolvedB = b?.resolve(states);
return lerpFunction(resolvedA, resolvedB, t);
}
}
/// Applies a data table theme to descendant [DataTable] widgets.
///
/// Descendant widgets obtain the current theme's [DataTableTheme] object using
/// [DataTableTheme.of]. When a widget uses [DataTableTheme.of], it is
/// automatically rebuilt if the theme later changes.
///
/// A data table theme can be specified as part of the overall Material
/// theme using [ThemeData.dataTableTheme].
///
/// See also:
///
/// * [DataTableThemeData], which describes the actual configuration
/// of a data table theme.
class DataTableTheme extends InheritedWidget {
/// Constructs a data table theme that configures all descendant
/// [DataTable] widgets.
///
/// The [data] must not be null.
const DataTableTheme({
Key key,
@required this.data,
Widget child,
}) : assert(data != null), super(key: key, child: child);
/// The properties used for all descendant [DataTable] widgets.
final DataTableThemeData data;
/// Returns the configuration [data] from the closest
/// [DataTableTheme] ancestor. If there is no ancestor, it returns
/// [ThemeData.dataTableTheme]. Applications can assume that the
/// returned value will not be null.
///
/// Typical usage is as follows:
///
/// ```dart
/// DataTableThemeData theme = DataTableTheme.of(context);
/// ```
static DataTableThemeData of(BuildContext context) {
final DataTableTheme dataTableTheme = context.dependOnInheritedWidgetOfExactType<DataTableTheme>();
return dataTableTheme?.data ?? Theme.of(context).dataTableTheme;
}
@override
bool updateShouldNotify(DataTableTheme oldWidget) => data != oldWidget.data;
}
...@@ -476,7 +476,6 @@ class PaginatedDataTableState extends State<PaginatedDataTable> { ...@@ -476,7 +476,6 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
horizontalMargin: widget.horizontalMargin, horizontalMargin: widget.horizontalMargin,
columnSpacing: widget.columnSpacing, columnSpacing: widget.columnSpacing,
showCheckboxColumn: widget.showCheckboxColumn, showCheckboxColumn: widget.showCheckboxColumn,
showBottomBorder: true,
rows: _getRows(_firstRowIndex, widget.rowsPerPage), rows: _getRows(_firstRowIndex, widget.rowsPerPage),
), ),
), ),
......
...@@ -22,7 +22,6 @@ import 'card_theme.dart'; ...@@ -22,7 +22,6 @@ import 'card_theme.dart';
import 'chip_theme.dart'; import 'chip_theme.dart';
import 'color_scheme.dart'; import 'color_scheme.dart';
import 'colors.dart'; import 'colors.dart';
import 'data_table_theme.dart';
import 'dialog_theme.dart'; import 'dialog_theme.dart';
import 'divider_theme.dart'; import 'divider_theme.dart';
import 'elevated_button_theme.dart'; import 'elevated_button_theme.dart';
...@@ -284,7 +283,6 @@ class ThemeData with Diagnosticable { ...@@ -284,7 +283,6 @@ class ThemeData with Diagnosticable {
ElevatedButtonThemeData elevatedButtonTheme, ElevatedButtonThemeData elevatedButtonTheme,
OutlinedButtonThemeData outlinedButtonTheme, OutlinedButtonThemeData outlinedButtonTheme,
TextSelectionThemeData textSelectionTheme, TextSelectionThemeData textSelectionTheme,
DataTableThemeData dataTableTheme,
bool fixTextFieldOutlineLabel, bool fixTextFieldOutlineLabel,
bool useTextSelectionTheme, bool useTextSelectionTheme,
}) { }) {
...@@ -402,7 +400,6 @@ class ThemeData with Diagnosticable { ...@@ -402,7 +400,6 @@ class ThemeData with Diagnosticable {
elevatedButtonTheme ??= const ElevatedButtonThemeData(); elevatedButtonTheme ??= const ElevatedButtonThemeData();
outlinedButtonTheme ??= const OutlinedButtonThemeData(); outlinedButtonTheme ??= const OutlinedButtonThemeData();
textSelectionTheme ??= const TextSelectionThemeData(); textSelectionTheme ??= const TextSelectionThemeData();
dataTableTheme ??= const DataTableThemeData();
fixTextFieldOutlineLabel ??= false; fixTextFieldOutlineLabel ??= false;
useTextSelectionTheme ??= false; useTextSelectionTheme ??= false;
...@@ -478,7 +475,6 @@ class ThemeData with Diagnosticable { ...@@ -478,7 +475,6 @@ class ThemeData with Diagnosticable {
elevatedButtonTheme: elevatedButtonTheme, elevatedButtonTheme: elevatedButtonTheme,
outlinedButtonTheme: outlinedButtonTheme, outlinedButtonTheme: outlinedButtonTheme,
textSelectionTheme: textSelectionTheme, textSelectionTheme: textSelectionTheme,
dataTableTheme: dataTableTheme,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: fixTextFieldOutlineLabel,
useTextSelectionTheme: useTextSelectionTheme, useTextSelectionTheme: useTextSelectionTheme,
); );
...@@ -565,7 +561,6 @@ class ThemeData with Diagnosticable { ...@@ -565,7 +561,6 @@ class ThemeData with Diagnosticable {
@required this.elevatedButtonTheme, @required this.elevatedButtonTheme,
@required this.outlinedButtonTheme, @required this.outlinedButtonTheme,
@required this.textSelectionTheme, @required this.textSelectionTheme,
@required this.dataTableTheme,
@required this.fixTextFieldOutlineLabel, @required this.fixTextFieldOutlineLabel,
@required this.useTextSelectionTheme, @required this.useTextSelectionTheme,
}) : assert(visualDensity != null), }) : assert(visualDensity != null),
...@@ -634,8 +629,8 @@ class ThemeData with Diagnosticable { ...@@ -634,8 +629,8 @@ class ThemeData with Diagnosticable {
assert(textButtonTheme != null), assert(textButtonTheme != null),
assert(elevatedButtonTheme != null), assert(elevatedButtonTheme != null),
assert(outlinedButtonTheme != null), assert(outlinedButtonTheme != null),
assert(fixTextFieldOutlineLabel != null),
assert(textSelectionTheme != null), assert(textSelectionTheme != null),
assert(dataTableTheme != null),
assert(fixTextFieldOutlineLabel != null), assert(fixTextFieldOutlineLabel != null),
assert(useTextSelectionTheme != null); assert(useTextSelectionTheme != null);
...@@ -1112,10 +1107,6 @@ class ThemeData with Diagnosticable { ...@@ -1112,10 +1107,6 @@ class ThemeData with Diagnosticable {
/// A theme for customizing the appearance and layout of [TextField] widgets. /// A theme for customizing the appearance and layout of [TextField] widgets.
final TextSelectionThemeData textSelectionTheme; final TextSelectionThemeData textSelectionTheme;
/// A theme for customizing the appearance and layout of [DataTable]
/// widgets.
final DataTableThemeData dataTableTheme;
/// A temporary flag to allow apps to opt-in to a /// A temporary flag to allow apps to opt-in to a
/// [small fix](https://github.com/flutter/flutter/issues/54028) for the Y /// [small fix](https://github.com/flutter/flutter/issues/54028) for the Y
/// coordinate of the floating label in a [TextField] [OutlineInputBorder]. /// coordinate of the floating label in a [TextField] [OutlineInputBorder].
...@@ -1215,7 +1206,6 @@ class ThemeData with Diagnosticable { ...@@ -1215,7 +1206,6 @@ class ThemeData with Diagnosticable {
ElevatedButtonThemeData elevatedButtonTheme, ElevatedButtonThemeData elevatedButtonTheme,
OutlinedButtonThemeData outlinedButtonTheme, OutlinedButtonThemeData outlinedButtonTheme,
TextSelectionThemeData textSelectionTheme, TextSelectionThemeData textSelectionTheme,
DataTableThemeData dataTableTheme,
bool fixTextFieldOutlineLabel, bool fixTextFieldOutlineLabel,
bool useTextSelectionTheme, bool useTextSelectionTheme,
}) { }) {
...@@ -1291,7 +1281,6 @@ class ThemeData with Diagnosticable { ...@@ -1291,7 +1281,6 @@ class ThemeData with Diagnosticable {
elevatedButtonTheme: elevatedButtonTheme ?? this.elevatedButtonTheme, elevatedButtonTheme: elevatedButtonTheme ?? this.elevatedButtonTheme,
outlinedButtonTheme: outlinedButtonTheme ?? this.outlinedButtonTheme, outlinedButtonTheme: outlinedButtonTheme ?? this.outlinedButtonTheme,
textSelectionTheme: textSelectionTheme ?? this.textSelectionTheme, textSelectionTheme: textSelectionTheme ?? this.textSelectionTheme,
dataTableTheme: dataTableTheme ?? this.dataTableTheme,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? this.fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? this.fixTextFieldOutlineLabel,
useTextSelectionTheme: useTextSelectionTheme ?? this.useTextSelectionTheme, useTextSelectionTheme: useTextSelectionTheme ?? this.useTextSelectionTheme,
); );
...@@ -1445,7 +1434,6 @@ class ThemeData with Diagnosticable { ...@@ -1445,7 +1434,6 @@ class ThemeData with Diagnosticable {
elevatedButtonTheme: ElevatedButtonThemeData.lerp(a.elevatedButtonTheme, b.elevatedButtonTheme, t), elevatedButtonTheme: ElevatedButtonThemeData.lerp(a.elevatedButtonTheme, b.elevatedButtonTheme, t),
outlinedButtonTheme: OutlinedButtonThemeData.lerp(a.outlinedButtonTheme, b.outlinedButtonTheme, t), outlinedButtonTheme: OutlinedButtonThemeData.lerp(a.outlinedButtonTheme, b.outlinedButtonTheme, t),
textSelectionTheme: TextSelectionThemeData .lerp(a.textSelectionTheme, b.textSelectionTheme, t), textSelectionTheme: TextSelectionThemeData .lerp(a.textSelectionTheme, b.textSelectionTheme, t),
dataTableTheme: DataTableThemeData.lerp(a.dataTableTheme, b.dataTableTheme, t),
fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel,
useTextSelectionTheme: t < 0.5 ? a.useTextSelectionTheme : b.useTextSelectionTheme, useTextSelectionTheme: t < 0.5 ? a.useTextSelectionTheme : b.useTextSelectionTheme,
); );
...@@ -1527,7 +1515,6 @@ class ThemeData with Diagnosticable { ...@@ -1527,7 +1515,6 @@ class ThemeData with Diagnosticable {
&& other.elevatedButtonTheme == elevatedButtonTheme && other.elevatedButtonTheme == elevatedButtonTheme
&& other.outlinedButtonTheme == outlinedButtonTheme && other.outlinedButtonTheme == outlinedButtonTheme
&& other.textSelectionTheme == textSelectionTheme && other.textSelectionTheme == textSelectionTheme
&& other.dataTableTheme == dataTableTheme
&& other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel && other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel
&& other.useTextSelectionTheme == useTextSelectionTheme; && other.useTextSelectionTheme == useTextSelectionTheme;
} }
...@@ -1608,7 +1595,6 @@ class ThemeData with Diagnosticable { ...@@ -1608,7 +1595,6 @@ class ThemeData with Diagnosticable {
elevatedButtonTheme, elevatedButtonTheme,
outlinedButtonTheme, outlinedButtonTheme,
textSelectionTheme, textSelectionTheme,
dataTableTheme,
fixTextFieldOutlineLabel, fixTextFieldOutlineLabel,
useTextSelectionTheme, useTextSelectionTheme,
]; ];
...@@ -1687,7 +1673,6 @@ class ThemeData with Diagnosticable { ...@@ -1687,7 +1673,6 @@ class ThemeData with Diagnosticable {
properties.add(DiagnosticsProperty<TextButtonThemeData>('textButtonTheme', textButtonTheme, defaultValue: defaultData.textButtonTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<TextButtonThemeData>('textButtonTheme', textButtonTheme, defaultValue: defaultData.textButtonTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<ElevatedButtonThemeData>('elevatedButtonTheme', elevatedButtonTheme, defaultValue: defaultData.elevatedButtonTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<ElevatedButtonThemeData>('elevatedButtonTheme', elevatedButtonTheme, defaultValue: defaultData.elevatedButtonTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<OutlinedButtonThemeData>('outlinedButtonTheme', outlinedButtonTheme, defaultValue: defaultData.outlinedButtonTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<OutlinedButtonThemeData>('outlinedButtonTheme', outlinedButtonTheme, defaultValue: defaultData.outlinedButtonTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<DataTableThemeData>('dataTableTheme', dataTableTheme, defaultValue: defaultData.dataTableTheme, level: DiagnosticLevel.debug));
} }
} }
......
...@@ -177,10 +177,6 @@ void main() { ...@@ -177,10 +177,6 @@ void main() {
MaterialApp( MaterialApp(
home: Material( home: Material(
child: DataTable( child: DataTable(
headingTextStyle: const TextStyle(
fontSize: 14.0,
letterSpacing: 0.0, // Will overflow if letter spacing is larger than 0.0.
),
columns: <DataColumn>[ columns: <DataColumn>[
DataColumn( DataColumn(
label: Text('X' * 2000), label: Text('X' * 2000),
...@@ -199,7 +195,6 @@ void main() { ...@@ -199,7 +195,6 @@ void main() {
), ),
), ),
); );
expect(tester.renderObject<RenderBox>(find.byType(Text).first).size.width, greaterThan(800.0)); expect(tester.renderObject<RenderBox>(find.byType(Text).first).size.width, greaterThan(800.0));
expect(tester.renderObject<RenderBox>(find.byType(Row).first).size.width, greaterThan(800.0)); expect(tester.renderObject<RenderBox>(find.byType(Row).first).size.width, greaterThan(800.0));
expect(tester.takeException(), isNull); // column overflows table, but text doesn't overflow cell expect(tester.takeException(), isNull); // column overflows table, but text doesn't overflow cell
...@@ -697,7 +692,7 @@ void main() { ...@@ -697,7 +692,7 @@ void main() {
); );
// custom first column padding // custom first column padding
padding = find.widgetWithText(Padding, 'Frozen yogurt').first; padding = find.widgetWithText(Padding, 'Frozen yogurt');
cellContent = find.widgetWithText(Align, 'Frozen yogurt'); // DataTable wraps its DataCells in an Align widget cellContent = find.widgetWithText(Align, 'Frozen yogurt'); // DataTable wraps its DataCells in an Align widget
expect( expect(
tester.getRect(cellContent).left - tester.getRect(padding).left, tester.getRect(cellContent).left - tester.getRect(padding).left,
...@@ -957,9 +952,9 @@ void main() { ...@@ -957,9 +952,9 @@ void main() {
); );
Table table = tester.widget(find.byType(Table)); Table table = tester.widget(find.byType(Table));
TableRow tableRow = table.children.last; TableRow tableRow = table.children.first;
BoxDecoration boxDecoration = tableRow.decoration as BoxDecoration; BoxDecoration boxDecoration = tableRow.decoration as BoxDecoration;
expect(boxDecoration.border.top.width, 1.0); expect(boxDecoration.border.bottom.width, 1.0);
const double thickness = 4.2; const double thickness = 4.2;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -974,58 +969,9 @@ void main() { ...@@ -974,58 +969,9 @@ void main() {
), ),
); );
table = tester.widget(find.byType(Table)); table = tester.widget(find.byType(Table));
tableRow = table.children.last; tableRow = table.children.first;
boxDecoration = tableRow.decoration as BoxDecoration;
expect(boxDecoration.border.top.width, thickness);
});
testWidgets('DataTable set show bottom border', (WidgetTester tester) async {
const List<DataColumn> columns = <DataColumn>[
DataColumn(label: Text('column1')),
DataColumn(label: Text('column2')),
];
const List<DataCell> cells = <DataCell>[
DataCell(Text('cell1')),
DataCell(Text('cell2')),
];
const List<DataRow> rows = <DataRow>[
DataRow(cells: cells),
DataRow(cells: cells),
];
await tester.pumpWidget(
MaterialApp(
home: Material(
child: DataTable(
showBottomBorder: true,
columns: columns,
rows: rows,
),
),
),
);
Table table = tester.widget(find.byType(Table));
TableRow tableRow = table.children.last;
BoxDecoration boxDecoration = tableRow.decoration as BoxDecoration;
expect(boxDecoration.border.bottom.width, 1.0);
await tester.pumpWidget(
MaterialApp(
home: Material(
child: DataTable(
columns: columns,
rows: rows,
),
),
),
);
table = tester.widget(find.byType(Table));
tableRow = table.children.last;
boxDecoration = tableRow.decoration as BoxDecoration; boxDecoration = tableRow.decoration as BoxDecoration;
expect(boxDecoration.border.bottom.width, 0.0); expect(boxDecoration.border.bottom.width, thickness);
}); });
testWidgets('DataTable column heading cell - with and without sorting', (WidgetTester tester) async { testWidgets('DataTable column heading cell - with and without sorting', (WidgetTester tester) async {
...@@ -1279,7 +1225,7 @@ void main() { ...@@ -1279,7 +1225,7 @@ void main() {
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.text('Content1'))); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.text('Content1')));
await tester.pump(const Duration(milliseconds: 200)); // splash is well underway await tester.pump(const Duration(milliseconds: 200)); // splash is well underway
final RenderBox box = Material.of(tester.element(find.byType(InkWell))) as RenderBox; final RenderBox box = Material.of(tester.element(find.byType(InkWell))) as RenderBox;
expect(box, paints..circle(x: 68.0, y: 24.0, color: pressedColor)); expect(box, paints..circle(x: 64.0, y: 24.0, color: pressedColor));
await gesture.up(); await gesture.up();
}); });
} }
...@@ -288,7 +288,6 @@ void main() { ...@@ -288,7 +288,6 @@ void main() {
elevatedButtonTheme: ElevatedButtonThemeData(style: ElevatedButton.styleFrom(primary: Colors.green)), elevatedButtonTheme: ElevatedButtonThemeData(style: ElevatedButton.styleFrom(primary: Colors.green)),
outlinedButtonTheme: OutlinedButtonThemeData(style: OutlinedButton.styleFrom(primary: Colors.blue)), outlinedButtonTheme: OutlinedButtonThemeData(style: OutlinedButton.styleFrom(primary: Colors.blue)),
textSelectionTheme: const TextSelectionThemeData(cursorColor: Colors.black), textSelectionTheme: const TextSelectionThemeData(cursorColor: Colors.black),
dataTableTheme: const DataTableThemeData(),
fixTextFieldOutlineLabel: false, fixTextFieldOutlineLabel: false,
useTextSelectionTheme: false, useTextSelectionTheme: false,
); );
...@@ -377,7 +376,6 @@ void main() { ...@@ -377,7 +376,6 @@ void main() {
elevatedButtonTheme: const ElevatedButtonThemeData(), elevatedButtonTheme: const ElevatedButtonThemeData(),
outlinedButtonTheme: const OutlinedButtonThemeData(), outlinedButtonTheme: const OutlinedButtonThemeData(),
textSelectionTheme: const TextSelectionThemeData(cursorColor: Colors.white), textSelectionTheme: const TextSelectionThemeData(cursorColor: Colors.white),
dataTableTheme: const DataTableThemeData(),
fixTextFieldOutlineLabel: true, fixTextFieldOutlineLabel: true,
useTextSelectionTheme: true, useTextSelectionTheme: true,
); );
......
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