mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2026-08-29 11:09:54 +00:00
chore: modernize Flutter examples — null safety, latest APIs, Kotlin DSL Gradle (#148)
* updates * Update Gradle wrapper script to fetch latest version online and allow --version override * chore(analytics_integration): migrate Gradle build scripts to Kotlin DSL Convert Groovy build files to Kotlin DSL and bump Gradle wrapper. * chore(animation_example): migrate Gradle build scripts to Kotlin DSL Convert Groovy build files to Kotlin DSL. * chore(biometrics): migrate Gradle build scripts to Kotlin DSL Convert Groovy build files to Kotlin DSL. * chore(bmi_calculator): test test body * chore(bottom_sheet): test test body * chore(custom_home_drawer): migrate Gradle build scripts to Kotlin DSL Convert Groovy build files to Kotlin DSL and bump Gradle wrapper. * chore(covid19_mobile_app): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(dropdown_button): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(enabling_splash_screen): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(expense_planner): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(firebase_crash_reporting): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(firebase_google_authentication): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(flutter_date_pickers-master): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(getx_counter_app): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(google_signin): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(grid_layout): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(handling_routes): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(image_editor): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(image_from_network): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(infinite_list): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(load_local_image): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(load_local_json): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(lunch_app): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(navigation_drawer): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(news_memes_app): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(persist_key_value): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(push_notifications): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(save_data_locally_with_sqlite): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(scan_qr_code): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(simple_material_app): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(sliver_app_bar_example): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(stateful_widget): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(stateless_widgets): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(statless_counter_app): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(tic_tac_toe): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(tip_calculator): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(todo_list_using_provider): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(unit_testing): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(using_alert_dialog): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_bottom_nav_bar): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_custom_fonts): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_edittext): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_expansionpanel): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(using_firebase_db): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(using_gradient): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_http_get): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_interactiveviewer): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(using_listview): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_listwheelscrollview): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(using_platform_adaptive): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(using_snackbar): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_stepper): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_tabs): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_theme): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(view_pdf_file): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore: ignore .trash directory * chore: remove IDE configs and PR template * chore(infinite_list): remove legacy nested android project * refactor(infinite_list): migrate theme to ColorScheme API * refactor(using_theme): migrate to ColorScheme API * refactor(analytics_integration): migrate Firebase Analytics API * refactor(firebase_google_authentication): migrate Google Sign-In API * refactor(covid19_mobile_app): migrate theme and buttons to current API * refactor(covid19_mobile_app): replace bezier_chart with fl_chart * refactor(image_editor): migrate image plugins and button styles * refactor(scan_qr_code): migrate mobile_scanner API * refactor(lunch_app): migrate to null safety * refactor(todo_list_using_provider): migrate to null safety * refactor(unit_testing): migrate to null safety * refactor(using_firebase_db): migrate Firebase Database API * fix(update_gradle_wrapper): edit gradle-wrapper.properties directly * refactor(push_notifications): migrate Firebase Messaging API * refactor(using_http_get): migrate to null safety * refactor(using_listview): migrate to null safety * refactor(using_listwheelscrollview): migrate to null safety * refactor(view_pdf_file): migrate to null safety * refactor(bottom_sheet): migrate to null safety * refactor(stateless_widgets): migrate to null safety * chore: regenerate Gradle wrapper * refactor: move maintenance scripts to Makefile * chore: remove generated and IDE files * fix: migrate image_editor to current plugins * fix: migrate news_memes_app share to share_plus * fix: migrate view_pdf_file to syncfusion pdf viewer * fix: update deprecated APIs * style: remove commented-out code
This commit is contained in:
committed by
GitHub
parent
80fe9bed92
commit
8745f7cf5a
@@ -84,18 +84,18 @@ class DatePickerStyles {
|
||||
/// Return new [DatePickerStyles] object where fields
|
||||
/// with null values set with defaults from theme.
|
||||
DatePickerStyles fulfillWithTheme(ThemeData theme) {
|
||||
Color accentColor = theme.accentColor;
|
||||
Color accentColor = theme.colorScheme.secondary;
|
||||
|
||||
TextStyle? _displayedPeriodTitle =
|
||||
displayedPeriodTitle ?? theme.textTheme.subtitle1;
|
||||
displayedPeriodTitle ?? theme.textTheme.titleMedium;
|
||||
TextStyle? _currentDateStyle = currentDateStyle ??
|
||||
theme.textTheme.bodyText1?.copyWith(color: theme.accentColor);
|
||||
theme.textTheme.bodyLarge?.copyWith(color: theme.colorScheme.secondary);
|
||||
TextStyle? _disabledDateStyle = disabledDateStyle ??
|
||||
theme.textTheme.bodyText2?.copyWith(color: theme.disabledColor);
|
||||
theme.textTheme.bodyMedium?.copyWith(color: theme.disabledColor);
|
||||
TextStyle? _selectedDateStyle =
|
||||
selectedDateStyle ?? theme.accentTextTheme.bodyText1;
|
||||
selectedDateStyle ?? theme.textTheme.bodyLarge;
|
||||
TextStyle? _defaultDateTextStyle =
|
||||
defaultDateTextStyle ?? theme.textTheme.bodyText2;
|
||||
defaultDateTextStyle ?? theme.textTheme.bodyMedium;
|
||||
BoxDecoration _selectedSingleDateDecoration =
|
||||
selectedSingleDateDecoration ??
|
||||
BoxDecoration(
|
||||
@@ -104,7 +104,7 @@ class DatePickerStyles {
|
||||
|
||||
DayHeaderStyle? _dayHeaderStyle = dayHeaderStyle;
|
||||
if (dayHeaderStyleBuilder == null && _dayHeaderStyle == null) {
|
||||
_dayHeaderStyle = DayHeaderStyle(textStyle: theme.textTheme.caption);
|
||||
_dayHeaderStyle = DayHeaderStyle(textStyle: theme.textTheme.bodySmall);
|
||||
}
|
||||
|
||||
return DatePickerStyles(
|
||||
@@ -142,7 +142,7 @@ class DatePickerStyles {
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
hashValues(
|
||||
Object.hash(
|
||||
displayedPeriodTitle,
|
||||
currentDateStyle,
|
||||
disabledDateStyle,
|
||||
@@ -210,7 +210,7 @@ class DatePickerRangeStyles extends DatePickerStyles {
|
||||
/// where fields with null values set with defaults from given theme.
|
||||
@override
|
||||
DatePickerRangeStyles fulfillWithTheme(ThemeData theme) {
|
||||
Color accentColor = theme.accentColor;
|
||||
Color accentColor = theme.colorScheme.secondary;
|
||||
|
||||
DatePickerStyles commonStyles = super.fulfillWithTheme(theme);
|
||||
|
||||
@@ -328,7 +328,7 @@ class DatePickerRangeStyles extends DatePickerStyles {
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
hashValues(
|
||||
Object.hash(
|
||||
selectedPeriodStartDecoration,
|
||||
selectedPeriodStartTextStyle,
|
||||
selectedPeriodLastDecoration,
|
||||
@@ -353,7 +353,7 @@ class DatePickerRangeStyles extends DatePickerStyles {
|
||||
/// User styles for the day header in date picker.
|
||||
@immutable
|
||||
class DayHeaderStyle {
|
||||
/// If null - textTheme.caption from the Theme will be used.
|
||||
/// If null - textTheme.bodySmall from the Theme will be used.
|
||||
final TextStyle? textStyle;
|
||||
|
||||
/// If null - no decoration will be applied for the day header;
|
||||
@@ -379,7 +379,7 @@ class DayHeaderStyle {
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => hashValues(
|
||||
int get hashCode => Object.hash(
|
||||
textStyle,
|
||||
decoration
|
||||
);
|
||||
|
||||
@@ -12,10 +12,10 @@ class DayBasedChangeablePickerPresenter {
|
||||
|
||||
/// Last date user can select.
|
||||
final DateTime lastDate;
|
||||
|
||||
|
||||
/// Localization.
|
||||
final MaterialLocalizations localizations;
|
||||
|
||||
|
||||
/// If empty day cells before 1st day of showing month should be filled with
|
||||
/// date from the last week of the previous month.
|
||||
final bool showPrevMonthDates;
|
||||
@@ -23,11 +23,11 @@ class DayBasedChangeablePickerPresenter {
|
||||
/// If empty day cells after last day of showing month should be filled with
|
||||
/// date from the first week of the next month.
|
||||
final bool showNextMonthDates;
|
||||
|
||||
|
||||
/// Index of the first day in week.
|
||||
/// 0 is Sunday, 6 is Saturday.
|
||||
final int firstDayOfWeekIndex;
|
||||
|
||||
|
||||
/// View model stream for the [DayBasedChangeablePicker].
|
||||
Stream<DayBasedChangeablePickerState> get data => _controller.stream;
|
||||
|
||||
@@ -35,26 +35,18 @@ class DayBasedChangeablePickerPresenter {
|
||||
DayBasedChangeablePickerState? get lastVal => _lastVal;
|
||||
|
||||
/// Creates presenter to use for [DayBasedChangeablePicker].
|
||||
DayBasedChangeablePickerPresenter({
|
||||
required this.firstDate,
|
||||
required this.lastDate,
|
||||
required this.localizations,
|
||||
required this.showPrevMonthDates,
|
||||
required this.showNextMonthDates,
|
||||
int? firstDayOfWeekIndex
|
||||
}): firstDayOfWeekIndex = firstDayOfWeekIndex
|
||||
?? localizations.firstDayOfWeekIndex;
|
||||
DayBasedChangeablePickerPresenter(
|
||||
{required this.firstDate,
|
||||
required this.lastDate,
|
||||
required this.localizations,
|
||||
required this.showPrevMonthDates,
|
||||
required this.showNextMonthDates,
|
||||
int? firstDayOfWeekIndex})
|
||||
: firstDayOfWeekIndex =
|
||||
firstDayOfWeekIndex ?? localizations.firstDayOfWeekIndex;
|
||||
|
||||
/// Update state according to the [selectedDate] if it needs.
|
||||
void setSelectedDate(DateTime selectedDate) {
|
||||
// bool firstAndLastNotNull = _firstShownDate != null
|
||||
// && _lastShownDate != null;
|
||||
//
|
||||
// bool selectedOnCurPage = firstAndLastNotNull
|
||||
// && !selectedDate.isBefore(_firstShownDate)
|
||||
// && !selectedDate.isAfter(_lastShownDate);
|
||||
// if (selectedOnCurPage) return;
|
||||
|
||||
changeMonth(selectedDate);
|
||||
}
|
||||
|
||||
@@ -76,19 +68,19 @@ class DayBasedChangeablePickerPresenter {
|
||||
|
||||
/// Update state to change month to the [newMonth].
|
||||
void changeMonth(DateTime newMonth) {
|
||||
bool sameMonth = _lastVal != null
|
||||
&& DatePickerUtils.sameMonth(_lastVal!.currentMonth, newMonth);
|
||||
bool sameMonth = _lastVal != null &&
|
||||
DatePickerUtils.sameMonth(_lastVal!.currentMonth, newMonth);
|
||||
if (sameMonth) return;
|
||||
|
||||
int monthPage = DatePickerUtils.monthDelta(firstDate, newMonth);
|
||||
DateTime prevMonth = DatePickerUtils
|
||||
.addMonthsToMonthDate(firstDate, monthPage - 1);
|
||||
DateTime prevMonth =
|
||||
DatePickerUtils.addMonthsToMonthDate(firstDate, monthPage - 1);
|
||||
|
||||
DateTime curMonth = DatePickerUtils
|
||||
.addMonthsToMonthDate(firstDate, monthPage);
|
||||
DateTime curMonth =
|
||||
DatePickerUtils.addMonthsToMonthDate(firstDate, monthPage);
|
||||
|
||||
DateTime nextMonth = DatePickerUtils
|
||||
.addMonthsToMonthDate(firstDate, monthPage + 1);
|
||||
DateTime nextMonth =
|
||||
DatePickerUtils.addMonthsToMonthDate(firstDate, monthPage + 1);
|
||||
|
||||
String prevMonthStr = localizations.formatMonthYear(prevMonth);
|
||||
String curMonthStr = localizations.formatMonthYear(curMonth);
|
||||
@@ -101,9 +93,8 @@ class DayBasedChangeablePickerPresenter {
|
||||
? null
|
||||
: "${localizations.previousMonthTooltip} $prevMonthStr";
|
||||
|
||||
String? nextTooltip = isLastMonth
|
||||
? null
|
||||
: "${localizations.nextMonthTooltip} $nextMonthStr";
|
||||
String? nextTooltip =
|
||||
isLastMonth ? null : "${localizations.nextMonthTooltip} $nextMonthStr";
|
||||
|
||||
DayBasedChangeablePickerState newState = DayBasedChangeablePickerState(
|
||||
currentMonth: curMonth,
|
||||
@@ -113,14 +104,13 @@ class DayBasedChangeablePickerPresenter {
|
||||
prevTooltip: prevTooltip,
|
||||
nextTooltip: nextTooltip,
|
||||
isFirstMonth: isFirstMonth,
|
||||
isLastMonth: isLastMonth
|
||||
);
|
||||
isLastMonth: isLastMonth);
|
||||
|
||||
_updateState(newState);
|
||||
}
|
||||
|
||||
/// Closes controller.
|
||||
void dispose () {
|
||||
void dispose() {
|
||||
_controller.close();
|
||||
}
|
||||
|
||||
@@ -130,15 +120,13 @@ class DayBasedChangeablePickerPresenter {
|
||||
}
|
||||
|
||||
final StreamController<DayBasedChangeablePickerState> _controller =
|
||||
StreamController.broadcast();
|
||||
StreamController.broadcast();
|
||||
|
||||
DayBasedChangeablePickerState? _lastVal;
|
||||
}
|
||||
|
||||
|
||||
/// View Model for the [DayBasedChangeablePicker].
|
||||
class DayBasedChangeablePickerState {
|
||||
|
||||
/// Display name of the current month.
|
||||
final String curMonthDis;
|
||||
|
||||
@@ -174,4 +162,4 @@ class DayBasedChangeablePickerState {
|
||||
this.prevTooltip,
|
||||
this.nextTooltip,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ class _MonthPicker extends StatelessWidget {
|
||||
selectedDate.year == year && selectedDate.month == month;
|
||||
|
||||
BoxDecoration? decoration;
|
||||
TextStyle? itemStyle = themeData.textTheme.bodyText2;
|
||||
TextStyle? itemStyle = themeData.textTheme.bodyMedium;
|
||||
|
||||
if (isSelectedMonth) {
|
||||
itemStyle = datePickerStyles.selectedDateStyle;
|
||||
|
||||
Reference in New Issue
Block a user