Skip to content

Commit fcc1378

Browse files
authored
🚀 Migrate to Flutter 3 (#93)
1 parent c143844 commit fcc1378

15 files changed

+80
-321
lines changed

‎CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change log
22

3+
## 3.2.0
4+
5+
Migrate to Flutter 3, drop supports for previous Flutter versions.
6+
7+
- Remove deprecated `Miui10AnimBuilder`.
8+
39
## 3.1.5
410

511
- `_ToastContainer` -> `ToastContainer`.

‎analysis_options.yaml

Lines changed: 3 additions & 226 deletions
Original file line numberDiff line numberDiff line change
@@ -1,229 +1,6 @@
1-
# Specify analysis options.
2-
#
3-
# Until there are meta linter rules, each desired lint must be explicitly enabled.
4-
# See: https://github.com/dart-lang/linter/issues/288
5-
#
6-
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
7-
# See the configuration guide for more
8-
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
9-
#
10-
# There are other similar analysis options files in the flutter repos,
11-
# which should be kept in sync with this file:
12-
#
13-
# - analysis_options.yaml (this file)
14-
# - packages/flutter/lib/analysis_options_user.yaml
15-
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
16-
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
17-
#
18-
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
19-
# Android Studio, and the `flutter analyze` command.
20-
21-
analyzer:
22-
strong-mode:
23-
implicit-casts: false
24-
implicit-dynamic: false
25-
errors:
26-
# treat missing required parameters as a warning (not a hint)
27-
missing_required_param: warning
28-
# treat missing returns as a warning (not a hint)
29-
missing_return: warning
30-
# allow having TODOs in the code
31-
todo: ignore
32-
# allow self-reference to deprecated members (we do this because otherwise we have
33-
# to annotate every member in every test, assert, etc, when we deprecate something)
34-
deprecated_member_use_from_same_package: ignore
35-
# Ignore analyzer hints for updating pubspecs when using Future or
36-
# Stream and not importing dart:async
37-
# Please see https://github.com/flutter/flutter/pull/24528 for details.
38-
sdk_version_async_exported_from_core: ignore
39-
exclude:
40-
- "bin/cache/**"
41-
# the following two are relative to the stocks example and the flutter package respectively
42-
# see https://github.com/dart-lang/sdk/issues/28463
43-
- "lib/i18n/messages_*.dart"
44-
- "lib/src/http/**"
45-
- "test_fixes/**"
1+
include: package:flutter_lints/flutter.yaml
462

473
linter:
484
rules:
49-
# these rules are documented on and in the same order as
50-
# the Dart Lint rules page to make maintenance easier
51-
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
52-
- always_declare_return_types
53-
- always_put_control_body_on_new_line
54-
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
55-
- always_require_non_null_named_parameters
56-
- always_specify_types
57-
# - always_use_package_imports # we do this commonly
58-
- annotate_overrides
59-
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
60-
# - avoid_as # required for implicit-casts: true
61-
- avoid_bool_literals_in_conditional_expressions
62-
# - avoid_catches_without_on_clauses # we do this commonly
63-
# - avoid_catching_errors # we do this commonly
64-
- avoid_classes_with_only_static_members
65-
# - avoid_double_and_int_checks # only useful when targeting JS runtime
66-
- avoid_empty_else
67-
- avoid_equals_and_hash_code_on_mutable_classes
68-
# - avoid_escaping_inner_quotes # not yet tested
69-
- avoid_field_initializers_in_const_classes
70-
- avoid_function_literals_in_foreach_calls
71-
# - avoid_implementing_value_types # not yet tested
72-
- avoid_init_to_null
73-
# - avoid_js_rounded_ints # only useful when targeting JS runtime
74-
- avoid_null_checks_in_equality_operators
75-
# - avoid_positional_boolean_parameters # not yet tested
76-
# - avoid_print # not yet tested
77-
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
78-
# - avoid_redundant_argument_values # not yet tested
79-
- avoid_relative_lib_imports
80-
- avoid_renaming_method_parameters
81-
- avoid_return_types_on_setters
82-
# - avoid_returning_null # there are plenty of valid reasons to return null
83-
# - avoid_returning_null_for_future # not yet tested
84-
- avoid_returning_null_for_void
85-
# - avoid_returning_this # there are plenty of valid reasons to return this
86-
# - avoid_setters_without_getters # not yet tested
87-
- avoid_shadowing_type_parameters
88-
- avoid_single_cascade_in_expression_statements
89-
- avoid_slow_async_io
90-
# - avoid_type_to_string # we do this commonly
91-
- avoid_types_as_parameter_names
92-
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
93-
# - avoid_unnecessary_containers # not yet tested
94-
- avoid_unused_constructor_parameters
95-
- avoid_void_async
96-
# - avoid_web_libraries_in_flutter # not yet tested
97-
- await_only_futures
98-
- camel_case_extensions
99-
- camel_case_types
100-
- cancel_subscriptions
101-
# - cascade_invocations # not yet tested
102-
- cast_nullable_to_non_nullable
103-
# - close_sinks # not reliable enough
104-
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
105-
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
106-
- control_flow_in_finally
107-
# - curly_braces_in_flow_control_structures # not required by flutter style
108-
# - diagnostic_describe_all_properties # not yet tested
109-
- directives_ordering
110-
# - do_not_use_environment # we do this commonly
111-
- empty_catches
112-
- empty_constructor_bodies
113-
- empty_statements
114-
- exhaustive_cases
115-
# - file_names # not yet tested
116-
- flutter_style_todos
117-
- hash_and_equals
118-
- implementation_imports
119-
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
120-
- iterable_contains_unrelated_type
121-
# - join_return_with_assignment # not required by flutter style
122-
- leading_newlines_in_multiline_strings
123-
- library_names
124-
- library_prefixes
125-
# - lines_longer_than_80_chars # not required by flutter style
126-
- list_remove_unrelated_type
127-
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
128-
# - missing_whitespace_between_adjacent_strings # not yet tested
129-
- no_adjacent_strings_in_list
130-
# - no_default_cases # too many false positives
131-
- no_duplicate_case_values
132-
- no_logic_in_create_state
133-
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
134-
- non_constant_identifier_names
135-
- null_check_on_nullable_type_parameter
136-
# - null_closures # not required by flutter style
137-
# - omit_local_variable_types # opposite of always_specify_types
138-
# - one_member_abstracts # too many false positives
139-
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
140-
- overridden_fields
141-
- package_api_docs
142-
# - package_names # non conforming packages in sdk
143-
- package_prefixed_library_names
144-
# - parameter_assignments # we do this commonly
145-
- prefer_adjacent_string_concatenation
146-
- prefer_asserts_in_initializer_lists
147-
# - prefer_asserts_with_message # not required by flutter style
148-
- prefer_collection_literals
149-
- prefer_conditional_assignment
150-
- prefer_const_constructors
151-
- prefer_const_constructors_in_immutables
152-
- prefer_const_declarations
153-
- prefer_const_literals_to_create_immutables
154-
# - prefer_constructors_over_static_methods # far too many false positives
155-
- prefer_contains
156-
# - prefer_double_quotes # opposite of prefer_single_quotes
157-
- prefer_equal_for_default_values
158-
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
159-
- prefer_final_fields
160-
- prefer_final_in_for_each
161-
- prefer_final_locals
162-
- prefer_for_elements_to_map_fromIterable
163-
- prefer_foreach
164-
# - prefer_function_declarations_over_variables # not yet tested
165-
- prefer_generic_function_type_aliases
166-
- prefer_if_elements_to_conditional_expressions
167-
- prefer_if_null_operators
168-
- prefer_initializing_formals
169-
- prefer_inlined_adds
170-
# - prefer_int_literals # not yet tested
171-
# - prefer_interpolation_to_compose_strings # not yet tested
172-
- prefer_is_empty
173-
- prefer_is_not_empty
174-
- prefer_is_not_operator
175-
- prefer_iterable_whereType
176-
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
177-
# - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
178-
# - prefer_relative_imports # not yet tested
179-
- prefer_single_quotes
180-
- prefer_spread_collections
181-
- prefer_typing_uninitialized_variables
182-
- prefer_void_to_null
183-
# - provide_deprecation_message # not yet tested
184-
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
185-
- recursive_getters
186-
# - sized_box_for_whitespace # not yet tested
187-
- slash_for_doc_comments
188-
# - sort_child_properties_last # not yet tested
189-
- sort_constructors_first
190-
# - sort_pub_dependencies # prevents separating pinned transitive dependencies
191-
- sort_unnamed_constructors_first
192-
- test_types_in_equals
193-
- throw_in_finally
194-
- tighten_type_of_initializing_formals
195-
# - type_annotate_public_apis # subset of always_specify_types
196-
- type_init_formals
197-
# - unawaited_futures # too many false positives
198-
# - unnecessary_await_in_return # not yet tested
199-
- unnecessary_brace_in_string_interps
200-
- unnecessary_const
201-
# - unnecessary_final # conflicts with prefer_final_locals
202-
- unnecessary_getters_setters
203-
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
204-
- unnecessary_new
205-
- unnecessary_null_aware_assignments
206-
# - unnecessary_null_checks # not yet tested
207-
- unnecessary_null_in_if_null_operators
208-
- unnecessary_nullable_for_final_variable_declarations
209-
- unnecessary_overrides
210-
- unnecessary_parenthesis
211-
# - unnecessary_raw_strings # not yet tested
212-
- unnecessary_statements
213-
- unnecessary_string_escapes
214-
- unnecessary_string_interpolations
215-
- unnecessary_this
216-
- unrelated_type_equality_checks
217-
# - unsafe_html # not yet tested
218-
- use_full_hex_values_for_flutter_colors
219-
# - use_function_type_syntax_for_parameters # not yet tested
220-
- use_is_even_rather_than_modulo
221-
# - use_key_in_widget_constructors # not yet tested
222-
- use_late_for_private_fields_and_variables
223-
- use_raw_strings
224-
- use_rethrow_when_possible
225-
# - use_setters_to_change_properties # not yet tested
226-
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
227-
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
228-
- valid_regexps
229-
- void_checks
5+
- avoid_print
6+
- use_super_parameters

‎example/lib/main.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'dart:async';
22

33
import 'package:flutter/material.dart';
4-
import 'package:oktoast/oktoast.dart' hide Miui10AnimBuilder;
4+
import 'package:oktoast/oktoast.dart';
55

66
import 'miui10_anim.dart';
77

@@ -39,10 +39,10 @@ class MyApp extends StatelessWidget {
3939
}
4040

4141
class MyHomePage extends StatefulWidget {
42-
const MyHomePage({Key? key}) : super(key: key);
42+
const MyHomePage({super.key});
4343

4444
@override
45-
_MyHomePageState createState() => _MyHomePageState();
45+
State<MyHomePage> createState() => _MyHomePageState();
4646
}
4747

4848
class _MyHomePageState extends State<MyHomePage> {
@@ -94,7 +94,7 @@ class _MyHomePageState extends State<MyHomePage> {
9494
duration: const Duration(seconds: 3),
9595
onDismiss: () {
9696
// The method will be called on toast dismiss.
97-
print('Toast has been dismissed.');
97+
debugPrint('Toast has been dismissed.');
9898
},
9999
);
100100

‎example/pubspec.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name: example_for_oktoast
22
description: A new Flutter project.
3-
version: 1.0.0+1
3+
version: 3.2.0+2
44
publish_to: none
55

66
environment:
7-
sdk: ">=2.12.0-0 <3.0.0"
7+
sdk: ">=2.17.0 <3.0.0"
8+
flutter: ">=3.0.0"
89

910
dependencies:
1011
flutter:

‎lib/oktoast.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ export 'src/core/position.dart';
44
export 'src/core/toast.dart'
55
show showToast, showToastWidget, OKToast, ToastFuture, dismissAllToast;
66
export 'src/widget/animation/animation_builder.dart';
7-
export 'src/widget/animation/miui10_anim.dart';
87
export 'src/widget/animation/offset_builder.dart';
98
export 'src/widget/animation/opacity_builder.dart';

‎lib/src/core/default_themes.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ const TextStyle _defaultTextStyle = TextStyle(
1818
fontWeight: FontWeight.normal,
1919
color: Colors.white,
2020
);
21-
const _ToastTheme defaultTheme = _ToastTheme(
21+
const ToastTheme defaultTheme = ToastTheme(
2222
radius: 10,
2323
textStyle: _defaultTextStyle,
2424
position: ToastPosition.center,
2525
textDirection: TextDirection.ltr,
2626
handleTouch: false,
27-
child: SizedBox(),
2827
animationBuilder: _defaultBuildAnimation,
28+
child: SizedBox(),
2929
);

‎lib/src/core/toast.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ ToastFuture showToast(
4949
}
5050
context ??= _contextMap.values.first;
5151

52-
final _ToastTheme theme = _ToastTheme.of(context);
52+
final ToastTheme theme = ToastTheme.of(context);
5353
textStyle ??= theme.textStyle;
5454
textAlign ??= theme.textAlign;
5555
textPadding ??= theme.textPadding;
@@ -101,7 +101,7 @@ ToastFuture showToastWidget(
101101
_throwIfNoContext(_contextMap.values, 'showToastWidget');
102102
}
103103
context ??= _contextMap.values.first;
104-
final _ToastTheme theme = _ToastTheme.of(context);
104+
final ToastTheme theme = ToastTheme.of(context);
105105

106106
position ??= theme.position;
107107
handleTouch ??= theme.handleTouch;
@@ -116,7 +116,7 @@ ToastFuture showToastWidget(
116116

117117
final GlobalKey<_ToastContainerState> key = GlobalKey();
118118

119-
widget = Align(child: widget, alignment: position.align);
119+
widget = Align(alignment: position.align, child: widget);
120120

121121
final OverlayEntry entry = OverlayEntry(builder: (BuildContext ctx) {
122122
return IgnorePointer(
@@ -128,10 +128,10 @@ ToastFuture showToastWidget(
128128
duration: duration!,
129129
position: position!,
130130
movingOnWindowChange: movingOnWindowChange,
131-
child: widget,
132131
animationBuilder: animationBuilder!,
133132
animationDuration: animationDuration!,
134133
animationCurve: animationCurve!,
134+
child: widget,
135135
),
136136
),
137137
);
@@ -167,7 +167,7 @@ ToastFuture showToastWidget(
167167
if (!context.debugDoingBuild && context.owner?.debugBuilding != true) {
168168
_insertOverlayEntry();
169169
} else {
170-
WidgetsBinding.instance?.addPostFrameCallback((_) {
170+
WidgetsBinding.instance.addPostFrameCallback((_) {
171171
_insertOverlayEntry();
172172
});
173173
}

‎lib/src/core/toast_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class ToastManager {
55

66
ToastManager._();
77

8-
static late final ToastManager _instance = ToastManager._();
8+
static final ToastManager _instance = ToastManager._();
99

1010
final Set<ToastFuture> toastSet = <ToastFuture>{};
1111

‎lib/src/widget/animation/miui10_anim.dart

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)