Skip to content

Commit

Permalink
Merge pull request #32 from albertms10/refactor/bump-versions-as-of-f…
Browse files Browse the repository at this point in the history
…lutter-2.8

refactor: bump versions as of Flutter 2.8
  • Loading branch information
albertms10 committed Dec 19, 2021
2 parents c1ab4ba + 9cd8260 commit 26ef401
Show file tree
Hide file tree
Showing 19 changed files with 81 additions and 64 deletions.
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ analyzer:
implicit_dynamic_parameter: ignore
implicit_dynamic_variable: ignore
import_of_legacy_library_into_null_safe: ignore
library_private_types_in_public_api: ignore
prefer_asserts_with_message: ignore
prefer_int_literals: ignore
public_member_api_docs: ignore
sort_constructors_first: ignore
8 changes: 4 additions & 4 deletions lib/src/model/booking/booking_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class BookingManager with ChangeNotifier {
required List<dynamic> bookings,
required List<dynamic> recurringBookings,
}) : bookings = SplayTreeSet.from(
bookings.map<Booking>((booking) => Booking.from(booking)),
bookings.cast<Map<String, dynamic>>().map<Booking>(Booking.from),
),
recurringBookings = SplayTreeSet.from(
recurringBookings.map<RecurringBooking>(
(recurringBooking) => RecurringBooking.from(recurringBooking),
),
recurringBookings
.cast<Map<String, dynamic>>()
.map<RecurringBooking>(RecurringBooking.from),
);

List<Map<String, dynamic>> bookingsToJson() =>
Expand Down
3 changes: 2 additions & 1 deletion lib/src/model/cabin/cabin_elements.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class CabinElements {

CabinElements.from(Map<String, dynamic> other)
: pianos = (other[_JsonFields.pianos] as List<dynamic>)
.map((piano) => Piano.from(piano))
.cast<Map<String, dynamic>>()
.map(Piano.from)
.toList(),
lecterns = other[_JsonFields.lecterns] as int,
chairs = other[_JsonFields.chairs] as int,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/cabin/cabin_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:collection' show SplayTreeMap, SplayTreeSet;
import 'dart:convert' show json;

import 'package:cabin_booking/utils/time_of_day_extension.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import '../booking/booking.dart';
Expand All @@ -15,7 +14,8 @@ import 'cabin.dart';

Iterable<Cabin> _parseCabins(String jsonString) =>
(json.decode(jsonString) as List<dynamic>)
.map<Cabin>((json) => Cabin.from(json));
.cast<Map<String, dynamic>>()
.map(Cabin.from);

class CabinManager extends WritableManager<Set<Cabin>> with ChangeNotifier {
late Set<Cabin> cabins;
Expand Down
3 changes: 2 additions & 1 deletion lib/src/model/school_year/school_year.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class SchoolYear extends DateRange {
SchoolYear.from(Map<String, dynamic> other)
: holidays = SplayTreeSet.from(
(other[_JsonFields.holidays] as List<dynamic>)
.map<Holiday>((holiday) => Holiday.from(holiday)),
.cast<Map<String, dynamic>>()
.map<Holiday>(Holiday.from),
),
super.from(other);

Expand Down
3 changes: 2 additions & 1 deletion lib/src/model/school_year/school_year_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import 'school_year.dart';

Iterable<SchoolYear> _parseSchoolYears(String jsonString) =>
(json.decode(jsonString) as List<dynamic>)
.map<SchoolYear>((json) => SchoolYear.from(json));
.cast<Map<String, dynamic>>()
.map(SchoolYear.from);

class SchoolYearManager extends WritableManager<Set<SchoolYear>>
with ChangeNotifier {
Expand Down
1 change: 1 addition & 0 deletions lib/utils/iterable_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ extension IterableExtension<E> on Iterable<E> {
if (E == num || E == int || E == double) {
nextValue ??= (current) => (current as num) + 1 as E;
} else if (E == String) {
// ignore: parameter_assignments
nextValue ??= (current) {
final charCodes = (current as String).codeUnits.map((a) => a + 1);

Expand Down
1 change: 0 additions & 1 deletion lib/widgets/booking/booking_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:cabin_booking/model.dart';
import 'package:cabin_booking/widgets/booking/booking_popup_menu.dart';
import 'package:cabin_booking/widgets/booking/booking_status_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
import 'package:timer_builder/timer_builder.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/booking/booking_status_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BookingStatusButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Tooltip(
message: _statusMessages(context)[status]!,
message: _statusMessages(context)[status],
child: Material(
color: Colors.transparent,
shape: const StadiumBorder(),
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/item/activity_line_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ActivityLineChart extends StatelessWidget {
condition: tooltipMessage != null,
conditionalBuilder: (child) {
return Tooltip(
message: tooltipMessage!,
message: tooltipMessage,
child: child,
);
},
Expand Down
21 changes: 13 additions & 8 deletions lib/widgets/item/items_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

typedef _OnSortFunction = void Function(bool);
typedef OnSortFunction = void Function({bool ascending});

class ItemsTable<T extends Item> extends StatefulWidget {
final String Function(ItemsTableRow<T>)? itemTitle;
Expand Down Expand Up @@ -77,23 +77,23 @@ class _ItemsTableState<T extends Item> extends State<ItemsTable<T>> {
setState(_selectedIndexes.clear);
}

void _onSortItem(bool ascending) {
void _onSortItem({bool ascending = true}) {
if (ascending) {
widget.rows.sort((a, b) => a.item.compareTo(b.item));
} else {
widget.rows.sort((a, b) => b.item.compareTo(a.item));
}
}

void _onSortBookingsCount(bool ascending) {
void _onSortBookingsCount({bool ascending = true}) {
if (ascending) {
widget.rows.sort((a, b) => a.bookingsCount.compareTo(b.bookingsCount));
} else {
widget.rows.sort((a, b) => b.bookingsCount.compareTo(a.bookingsCount));
}
}

void _onSortAccumulatedDuration(bool ascending) {
void _onSortAccumulatedDuration({bool ascending = true}) {
if (ascending) {
widget.rows.sort(
(a, b) => a.occupiedDuration.compareTo(b.occupiedDuration),
Expand All @@ -105,12 +105,12 @@ class _ItemsTableState<T extends Item> extends State<ItemsTable<T>> {
}
}

void onSortColumn(int columnIndex, bool ascending) {
<_OnSortFunction>[
void onSortColumn(int columnIndex, {bool ascending = true}) {
<OnSortFunction>[
_onSortItem,
_onSortBookingsCount,
_onSortAccumulatedDuration,
][columnIndex](ascending);
][columnIndex](ascending: ascending);

setState(() {
_sortColumnIndex = columnIndex;
Expand Down Expand Up @@ -165,7 +165,12 @@ class _ItemsTableState<T extends Item> extends State<ItemsTable<T>> {
),
),
),
onSort: column.sortable ? onSortColumn : null,
onSort: column.sortable
? (columnIndex, ascending) {
// lambda to avoid positional boolean parameters
onSortColumn(columnIndex, ascending: ascending);
}
: null,
tooltip: column.sortable
? '${appLocalizations.sortBy} ${column.title}'
: null,
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/layout/detailed_figure.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DetailedFigure<T> extends StatelessWidget {
condition: filteredDetails.length > 1 && tooltipMessage != null,
conditionalBuilder: (child) {
return Tooltip(
message: tooltipMessage!,
message: tooltipMessage,
child: child,
);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/pages/bookings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class BookingsPage extends StatefulWidget {
const BookingsPage({Key? key}) : super(key: key);

@override
State<BookingsPage> createState() => _BookingsPageState();
_BookingsPageState createState() => _BookingsPageState();
}

class _BookingsPageState extends State<BookingsPage>
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/pages/cabins_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class CabinsPage extends StatefulWidget {
const CabinsPage({Key? key}) : super(key: key);

@override
State<CabinsPage> createState() => _CabinsPageState();
_CabinsPageState createState() => _CabinsPageState();
}

class _CabinsPageState extends State<CabinsPage>
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/pages/main_data_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MainDataLoader extends StatefulWidget {
const MainDataLoader({Key? key, required this.child}) : super(key: key);

@override
State<MainDataLoader> createState() => _MainDataLoaderState();
_MainDataLoaderState createState() => _MainDataLoaderState();
}

class _MainDataLoaderState extends State<MainDataLoader> {
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/pages/school_years_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class SchoolYearsPage extends StatefulWidget {
const SchoolYearsPage({Key? key}) : super(key: key);

@override
State<SchoolYearsPage> createState() => _SchoolYearsPageState();
_SchoolYearsPageState createState() => _SchoolYearsPageState();
}

class _SchoolYearsPageState extends State<SchoolYearsPage>
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/pages/summary_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SummaryPage extends StatefulWidget {
const SummaryPage({Key? key, this.setNavigationPage}) : super(key: key);

@override
State<SummaryPage> createState() => _SummaryPageState();
_SummaryPageState createState() => _SummaryPageState();
}

class _SummaryPageState extends State<SummaryPage>
Expand Down
Loading

0 comments on commit 26ef401

Please sign in to comment.