Skip to content

Replaced deprecated text theme #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
32 changes: 17 additions & 15 deletions lib/date_range_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ library date_range_picker;
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// forked by AmSn6. replaced deprecated text theme on 23-09-2021

import 'dart:async';
import 'dart:math' as math;

Expand Down Expand Up @@ -93,9 +95,9 @@ class _DatePickerHeader extends StatelessWidget {
break;
}
final TextStyle dayStyle =
headerTextTheme.display1!.copyWith(color: dayColor, height: 1.4);
headerTextTheme.headline4!.copyWith(color: dayColor, height: 1.4);
final TextStyle yearStyle =
headerTextTheme.subhead!.copyWith(color: yearColor, height: 1.4);
headerTextTheme.subtitle1!.copyWith(color: yearColor, height: 1.4);

Color? backgroundColor;
switch (themeData.brightness) {
Expand Down Expand Up @@ -452,7 +454,7 @@ class DayPicker extends StatelessWidget {
(selectableDayPredicate != null &&
!selectableDayPredicate!(dayToBuild));
BoxDecoration? decoration;
TextStyle? itemStyle = themeData.textTheme.body1;
TextStyle? itemStyle = themeData.textTheme.bodyText2;
final bool isSelectedFirstDay = selectedFirstDate.year == year &&
selectedFirstDate.month == month &&
selectedFirstDate.day == day;
Expand All @@ -467,39 +469,39 @@ class DayPicker extends StatelessWidget {
: null;
if (isSelectedFirstDay &&
(isSelectedLastDay == null || isSelectedLastDay)) {
itemStyle = themeData.accentTextTheme.body2;
itemStyle = themeData.textTheme.bodyText1;
decoration = new BoxDecoration(
color: themeData.accentColor, shape: BoxShape.circle);
color: themeData.primaryColor, shape: BoxShape.circle);
} else if (isSelectedFirstDay) {
// The selected day gets a circle background highlight, and a contrasting text color.
itemStyle = themeData.accentTextTheme.body2;
itemStyle = themeData.textTheme.bodyText1;
decoration = new BoxDecoration(
color: themeData.accentColor,
color: themeData.primaryColor,
borderRadius: BorderRadius.only(
topLeft: new Radius.circular(50.0),
bottomLeft: new Radius.circular(50.0),
));
} else if (isSelectedLastDay != null && isSelectedLastDay) {
itemStyle = themeData.accentTextTheme.body2;
itemStyle = themeData.textTheme.bodyText1;
decoration = new BoxDecoration(
color: themeData.accentColor,
color: themeData.primaryColor,
borderRadius: BorderRadius.only(
topRight: new Radius.circular(50.0),
bottomRight: new Radius.circular(50.0),
));
} else if (isInRange != null && isInRange) {
decoration = new BoxDecoration(
color: themeData.accentColor.withOpacity(0.1),
color: themeData.primaryColor.withOpacity(0.1),
shape: BoxShape.rectangle);
} else if (disabled) {
itemStyle = themeData.textTheme.body1!
itemStyle = themeData.textTheme.bodyText2!
.copyWith(color: themeData.disabledColor);
} else if (currentDate.year == year &&
currentDate.month == month &&
currentDate.day == day) {
// The current day gets a different text color.
itemStyle =
themeData.textTheme.body2!.copyWith(color: themeData.accentColor);
themeData.textTheme.bodyText1!.copyWith(color: themeData.primaryColor);
}

Widget dayWidget = new Container(
Expand Down Expand Up @@ -561,7 +563,7 @@ class DayPicker extends StatelessWidget {
child: new ExcludeSemantics(
child: new Text(
localizations.formatMonthYear(displayedMonth),
style: themeData.textTheme.subhead,
style: themeData.textTheme.subtitle1,
),
),
),
Expand Down Expand Up @@ -941,7 +943,7 @@ class _YearPickerState extends State<YearPicker> {
Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context));
final ThemeData themeData = Theme.of(context);
final TextStyle? style = themeData.textTheme.body1;
final TextStyle? style = themeData.textTheme.bodyText2;
return new ListView.builder(
controller: scrollController,
itemExtent: _itemExtent,
Expand All @@ -952,7 +954,7 @@ class _YearPickerState extends State<YearPicker> {
(widget.selectedLastDate != null &&
year == widget.selectedLastDate!.year);
final TextStyle? itemStyle = isSelected
? themeData.textTheme.headline!
? themeData.textTheme.headline5!
.copyWith(color: themeData.accentColor)
: style;
return new InkWell(
Expand Down
10 changes: 5 additions & 5 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.8.1"
boolean_selector:
dependency: transitive
description:
Expand All @@ -28,7 +28,7 @@ packages:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.1"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -73,7 +73,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.7.0"
path:
dependency: transitive
description:
Expand All @@ -92,7 +92,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -127,7 +127,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
version: "0.4.2"
typed_data:
dependency: transitive
description:
Expand Down