Skip to content
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

Updated to support the latest version of Flutter #115

Open
wants to merge 5 commits 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
14 changes: 6 additions & 8 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ linter:
prefer_iterable_whereType: true
prefer_function_declarations_over_variables: true
unnecessary_lambdas: true
prefer_equal_for_default_values: true
avoid_init_to_null: true
unnecessary_getters_setters: true
unnecessary_getters: true
prefer_expression_function_bodies: true
unnecessary_this: true
unnecessary_const: true
Expand All @@ -51,11 +49,10 @@ linter:
prefer_final_fields: true
use_setters_to_change_properties: true
avoid_setters_without_getters: true
avoid_returning_null: true
avoid_returning_this: true
type_annotate_public_apis: true
prefer_typing_uninitialized_variables: true
# omit_local_variable_types: true
# omit_local_variable_types: true
avoid_types_on_closure_parameters: true
avoid_return_types_on_setters: true
prefer_generic_function_type_aliases: true
Expand All @@ -66,11 +63,9 @@ linter:
avoid_equals_and_hash_code_on_mutable_classes: true
avoid_null_checks_in_equality_operators: true


# PEDANTIC
# (duplicated rules are removed)
always_declare_return_types: true
always_require_non_null_named_parameters: true
annotate_overrides: true
avoid_empty_else: true
avoid_shadowing_type_parameters: true
Expand All @@ -83,12 +78,15 @@ linter:
prefer_contains: true
prefer_for_elements_to_map_fromIterable: true
prefer_if_null_operators: true
# prefer_single_quotes: true
# prefer_single_quotes: true
prefer_spread_collections: true
recursive_getters: true
type_init_formals: true
unawaited_futures: true
unnecessary_new: true
unnecessary_null_in_if_null_operators: true
unrelated_type_equality_checks: true
valid_regexps: true
valid_regexps: true
analyzer:
errors:
comment_references: ignore
9 changes: 3 additions & 6 deletions example/lib/color_picker_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ import 'package:flutter_material_color_picker/flutter_material_color_picker.dart

/// Dialog with some Material colors ([materialColors]) to pick one of them.
class ColorPickerDialog extends StatefulWidget {

/// Initially selected color.
///
/// If pre-selected color is not from [materialColors] [Colors.blue] will be
/// used.
final Color selectedColor;

///
const ColorPickerDialog({
Key? key,
required this.selectedColor
}) : super(key: key);
const ColorPickerDialog({Key? key, required this.selectedColor})
: super(key: key);

@override
State<StatefulWidget> createState() => _ColorPickerDialogState();
Expand Down Expand Up @@ -61,7 +58,7 @@ class _ColorPickerDialogState extends State<ColorPickerDialog> {
);
}

void _onMainColorChange (Color? newColor) {
void _onMainColorChange(Color? newColor) {
if (newColor == null) return;

setState(() {
Expand Down
1 change: 0 additions & 1 deletion example/lib/date_pickers_widgets/range_picker_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class RangePickerPage extends StatefulWidget {
}

class _RangePickerPageState extends State<RangePickerPage> {

final DateTime _firstDate = DateTime.now().subtract(Duration(days: 3450));
final DateTime _lastDate = DateTime.now().add(Duration(days: 345));

Expand Down
34 changes: 17 additions & 17 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ packages:
dependency: "direct main"
description:
name: cupertino_icons
sha256: caac504f942f41dfadcf45229ce8c47065b93919a12739f20d6173a883c5ec73
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
url: "https://pub.dev"
source: hosted
version: "1.0.2"
version: "1.0.8"
fake_async:
dependency: transitive
description:
Expand All @@ -68,7 +68,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.4.2"
version: "0.5.0"
flutter_localizations:
dependency: "direct main"
description: flutter
Expand All @@ -78,10 +78,10 @@ packages:
dependency: "direct main"
description:
name: flutter_material_color_picker
sha256: "64432c3b13bbcc6f428bae9d2e75b1b3da1e6f3219979e08a3bd9f176781d9f2"
sha256: ca1e7749d228c9155ea24bce98e647cdbffa350e6f334f6c001f841cd3d9c987
url: "https://pub.dev"
source: hosted
version: "1.1.0+2"
version: "1.2.0"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -99,18 +99,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.4"
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
Expand All @@ -131,18 +131,18 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.15.0"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -200,10 +200,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.7.0"
version: "0.7.2"
vector_math:
dependency: transitive
description:
Expand All @@ -216,10 +216,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.1"
version: "14.2.5"
sdks:
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
20 changes: 5 additions & 15 deletions lib/src/date_picker_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'styles/date_picker_styles.dart';

///
mixin CommonDatePickerFunctions {

/// Builds widgets showing abbreviated days of week. The first widget in the
/// returned list corresponds to the first day of week for the current locale.
///
Expand All @@ -23,11 +22,8 @@ mixin CommonDatePickerFunctions {
/// _ _ _ _ 1 2 3
/// 4 5 6 7 8 9 10
/// ```
List<Widget> getDayHeaders(
DayHeaderStyleBuilder headerStyleBuilder,
List<String> narrowWeekdays,
int firstDayOfWeekIndex) {

List<Widget> getDayHeaders(DayHeaderStyleBuilder headerStyleBuilder,
List<String> narrowWeekdays, int firstDayOfWeekIndex) {
final List<Widget> result = <Widget>[];

for (int i = firstDayOfWeekIndex; true; i = (i + 1) % 7) {
Expand All @@ -37,12 +33,7 @@ mixin CommonDatePickerFunctions {
Widget header = ExcludeSemantics(
child: Container(
decoration: headerStyle?.decoration,
child: Center(
child: Text(
weekday,
style: headerStyle?.textStyle
)
),
child: Center(child: Text(weekday, style: headerStyle?.textStyle)),
),
);

Expand Down Expand Up @@ -86,8 +77,7 @@ mixin CommonDatePickerFunctions {
/// into the [MaterialLocalizations.narrowWeekdays] list.
/// - [MaterialLocalizations.narrowWeekdays] list provides localized names of
/// days of week, always starting with Sunday and ending with Saturday.
int computeFirstDayOffset(
int year, int month, int firstDayOfWeekFromSunday) {
int computeFirstDayOffset(int year, int month, int firstDayOfWeekFromSunday) {
// 0-based day of week, with 0 representing Monday.
final int weekdayFromMonday = DateTime(year, month).weekday - 1;
// firstDayOfWeekFromSunday recomputed to be Monday-based
Expand All @@ -96,4 +86,4 @@ mixin CommonDatePickerFunctions {
// and the day corresponding to the 1-st of the month.
return (weekdayFromMonday - firstDayOfWeekFromMonday) % 7;
}
}
}
5 changes: 4 additions & 1 deletion lib/src/day_based_changable_picker.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// ignore_for_file: comment_references

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

import 'package:intl/intl.dart' as intl;

import 'basic_day_based_widget.dart';
Expand Down Expand Up @@ -160,6 +161,8 @@ class _DayBasedChangeablePickerState<T>

final ThemeData theme = Theme.of(context);
_resultStyles = widget.datePickerStyles.fulfillWithTheme(theme);

widget.selectablePicker.onDayTapped(widget.selection.earliest);
}

@override
Expand Down
Loading