mirror of
https://github.com/flutter/samples.git
synced 2025-11-09 06:18:49 +00:00
Centralize analysis options (#957)
This commit is contained in:
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
19
analysis_options.yaml
Normal file
19
analysis_options.yaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
include: package:flutter_lints/flutter.yaml
|
||||||
|
|
||||||
|
analyzer:
|
||||||
|
strong-mode:
|
||||||
|
implicit-casts: false
|
||||||
|
implicit-dynamic: false
|
||||||
|
|
||||||
|
linter:
|
||||||
|
rules:
|
||||||
|
avoid_types_on_closure_parameters: true
|
||||||
|
avoid_void_async: true
|
||||||
|
cancel_subscriptions: true
|
||||||
|
close_sinks: true
|
||||||
|
directives_ordering: true
|
||||||
|
package_api_docs: true
|
||||||
|
package_prefixed_library_names: true
|
||||||
|
test_types_in_equals: true
|
||||||
|
throw_in_finally: true
|
||||||
|
unnecessary_statements: true
|
||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,21 +1,6 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
linter:
|
||||||
rules:
|
rules:
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
# Required because of the numbered sources in lib/src/basics
|
# Required because of the numbered sources in lib/src/basics
|
||||||
file_names: false
|
file_names: false
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,22 +1,6 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
analyzer:
|
||||||
exclude:
|
exclude:
|
||||||
- lib/model/rule.g.dart
|
- lib/model/rule.g.dart
|
||||||
- test/widget_test.mocks.dart
|
- test/widget_test.mocks.dart
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,22 +1,6 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
analyzer:
|
||||||
exclude:
|
exclude:
|
||||||
- lib/json_serializable/*.g.dart
|
- lib/json_serializable/*.g.dart
|
||||||
- lib/built_value/*.g.dart
|
- lib/built_value/*.g.dart
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
@@ -1,19 +1 @@
|
|||||||
include: package:flutter_lints/flutter.yaml
|
include: ../analysis_options.yaml
|
||||||
|
|
||||||
analyzer:
|
|
||||||
strong-mode:
|
|
||||||
implicit-casts: false
|
|
||||||
implicit-dynamic: false
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
avoid_types_on_closure_parameters: true
|
|
||||||
avoid_void_async: true
|
|
||||||
cancel_subscriptions: true
|
|
||||||
close_sinks: true
|
|
||||||
directives_ordering: true
|
|
||||||
package_api_docs: true
|
|
||||||
package_prefixed_library_names: true
|
|
||||||
test_types_in_equals: true
|
|
||||||
throw_in_finally: true
|
|
||||||
unnecessary_statements: true
|
|
||||||
|
|||||||
11
web/particle_background/analysis_options.yaml
Normal file
11
web/particle_background/analysis_options.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
include: ../../analysis_options.yaml
|
||||||
|
|
||||||
|
analyzer:
|
||||||
|
strong-mode:
|
||||||
|
implicit-casts: true
|
||||||
|
implicit-dynamic: true
|
||||||
|
|
||||||
|
linter:
|
||||||
|
rules:
|
||||||
|
constant_identifier_names: false
|
||||||
|
|
||||||
@@ -3,12 +3,14 @@ import 'dart:math';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:particle_background/simple_animations_package.dart';
|
import 'package:particle_background/simple_animations_package.dart';
|
||||||
|
|
||||||
void main() => runApp(ParticleApp());
|
void main() => runApp(const ParticleApp());
|
||||||
|
|
||||||
class ParticleApp extends StatelessWidget {
|
class ParticleApp extends StatelessWidget {
|
||||||
|
const ParticleApp({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return const MaterialApp(
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
body: ParticleBackgroundPage(),
|
body: ParticleBackgroundPage(),
|
||||||
),
|
),
|
||||||
@@ -17,10 +19,12 @@ class ParticleApp extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ParticleBackgroundPage extends StatelessWidget {
|
class ParticleBackgroundPage extends StatelessWidget {
|
||||||
|
const ParticleBackgroundPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: const [
|
||||||
Positioned.fill(child: AnimatedBackground()),
|
Positioned.fill(child: AnimatedBackground()),
|
||||||
Positioned.fill(child: Particles(30)),
|
Positioned.fill(child: Particles(30)),
|
||||||
Positioned.fill(child: CenteredText()),
|
Positioned.fill(child: CenteredText()),
|
||||||
@@ -32,7 +36,7 @@ class ParticleBackgroundPage extends StatelessWidget {
|
|||||||
class Particles extends StatefulWidget {
|
class Particles extends StatefulWidget {
|
||||||
final int numberOfParticles;
|
final int numberOfParticles;
|
||||||
|
|
||||||
Particles(this.numberOfParticles);
|
const Particles(this.numberOfParticles, {key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ParticlesState createState() => _ParticlesState();
|
_ParticlesState createState() => _ParticlesState();
|
||||||
@@ -54,7 +58,7 @@ class _ParticlesState extends State<Particles> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Rendering(
|
return Rendering(
|
||||||
startTime: Duration(seconds: 30),
|
startTime: const Duration(seconds: 30),
|
||||||
onTick: _simulateParticles,
|
onTick: _simulateParticles,
|
||||||
builder: (context, time) {
|
builder: (context, time) {
|
||||||
return CustomPaint(
|
return CustomPaint(
|
||||||
@@ -65,14 +69,16 @@ class _ParticlesState extends State<Particles> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_simulateParticles(Duration time) {
|
_simulateParticles(Duration time) {
|
||||||
particles.forEach((particle) => particle.maintainRestart(time));
|
for (var particle in particles) {
|
||||||
|
particle.maintainRestart(time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ParticleModel {
|
class ParticleModel {
|
||||||
Animatable tween;
|
late Animatable tween;
|
||||||
double size;
|
late double size;
|
||||||
AnimationProgress animationProgress;
|
late AnimationProgress animationProgress;
|
||||||
Random random;
|
Random random;
|
||||||
|
|
||||||
ParticleModel(this.random) {
|
ParticleModel(this.random) {
|
||||||
@@ -113,13 +119,13 @@ class ParticlePainter extends CustomPainter {
|
|||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
final paint = Paint()..color = Colors.white.withAlpha(50);
|
final paint = Paint()..color = Colors.white.withAlpha(50);
|
||||||
|
|
||||||
particles.forEach((particle) {
|
for (var particle in particles) {
|
||||||
var progress = particle.animationProgress.progress(time);
|
var progress = particle.animationProgress.progress(time);
|
||||||
final animation = particle.tween.transform(progress);
|
final animation = particle.tween.transform(progress);
|
||||||
final position =
|
final position =
|
||||||
Offset(animation["x"] * size.width, animation["y"] * size.height);
|
Offset(animation["x"] * size.width, animation["y"] * size.height);
|
||||||
canvas.drawCircle(position, size.width * 0.2 * particle.size, paint);
|
canvas.drawCircle(position, size.width * 0.2 * particle.size, paint);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -127,20 +133,24 @@ class ParticlePainter extends CustomPainter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class AnimatedBackground extends StatelessWidget {
|
class AnimatedBackground extends StatelessWidget {
|
||||||
|
const AnimatedBackground({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final tween = MultiTrackTween([
|
final tween = MultiTrackTween([
|
||||||
Track("color1").add(Duration(seconds: 3),
|
Track("color1").add(
|
||||||
ColorTween(begin: Color(0xff8a113a), end: Colors.lightBlue.shade900)),
|
const Duration(seconds: 3),
|
||||||
Track("color2").add(Duration(seconds: 3),
|
ColorTween(
|
||||||
ColorTween(begin: Color(0xff440216), end: Colors.blue.shade600))
|
begin: const Color(0xff8a113a), end: Colors.lightBlue.shade900)),
|
||||||
|
Track("color2").add(const Duration(seconds: 3),
|
||||||
|
ColorTween(begin: const Color(0xff440216), end: Colors.blue.shade600))
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return ControlledAnimation(
|
return ControlledAnimation(
|
||||||
playback: Playback.MIRROR,
|
playback: Playback.MIRROR,
|
||||||
tween: tween,
|
tween: tween,
|
||||||
duration: tween.duration,
|
duration: tween.duration,
|
||||||
builder: (context, animation) {
|
builder: (context, dynamic animation) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
@@ -155,12 +165,12 @@ class AnimatedBackground extends StatelessWidget {
|
|||||||
|
|
||||||
class CenteredText extends StatelessWidget {
|
class CenteredText extends StatelessWidget {
|
||||||
const CenteredText({
|
const CenteredText({
|
||||||
Key key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Center(
|
return const Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Welcome to Flutter for web",
|
"Welcome to Flutter for web",
|
||||||
style: TextStyle(color: Colors.white, fontWeight: FontWeight.w200),
|
style: TextStyle(color: Colors.white, fontWeight: FontWeight.w200),
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
// https://pub.dev/packages/simple_animations
|
// https://pub.dev/packages/simple_animations
|
||||||
|
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
/// Widget to easily create a continuous animation.
|
/// Widget to easily create a continuous animation.
|
||||||
///
|
///
|
||||||
@@ -22,16 +23,17 @@ import 'package:flutter/scheduler.dart';
|
|||||||
/// [startTimeSimulationTicks] property.)
|
/// [startTimeSimulationTicks] property.)
|
||||||
class Rendering extends StatefulWidget {
|
class Rendering extends StatefulWidget {
|
||||||
final Widget Function(BuildContext context, Duration timeElapsed) builder;
|
final Widget Function(BuildContext context, Duration timeElapsed) builder;
|
||||||
final Function(Duration timeElapsed) onTick;
|
final Function(Duration timeElapsed)? onTick;
|
||||||
final Duration startTime;
|
final Duration startTime;
|
||||||
final int startTimeSimulationTicks;
|
final int startTimeSimulationTicks;
|
||||||
|
|
||||||
Rendering(
|
const Rendering(
|
||||||
{this.builder,
|
{required this.builder,
|
||||||
this.onTick,
|
this.onTick,
|
||||||
this.startTime = Duration.zero,
|
this.startTime = Duration.zero,
|
||||||
this.startTimeSimulationTicks = 20})
|
this.startTimeSimulationTicks = 20,
|
||||||
: assert(builder != null, "Builder needs to defined.");
|
Key? key})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_RenderingState createState() => _RenderingState();
|
_RenderingState createState() => _RenderingState();
|
||||||
@@ -39,8 +41,8 @@ class Rendering extends StatefulWidget {
|
|||||||
|
|
||||||
class _RenderingState extends State<Rendering>
|
class _RenderingState extends State<Rendering>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
Ticker _ticker;
|
late Ticker _ticker;
|
||||||
Duration _timeElapsed = Duration(milliseconds: 0);
|
Duration _timeElapsed = const Duration(milliseconds: 0);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -57,7 +59,7 @@ class _RenderingState extends State<Rendering>
|
|||||||
|
|
||||||
void _onRender(Duration effectiveElapsed) {
|
void _onRender(Duration effectiveElapsed) {
|
||||||
if (widget.onTick != null) {
|
if (widget.onTick != null) {
|
||||||
widget.onTick(effectiveElapsed);
|
widget.onTick!(effectiveElapsed);
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
_timeElapsed = effectiveElapsed;
|
_timeElapsed = effectiveElapsed;
|
||||||
@@ -66,14 +68,14 @@ class _RenderingState extends State<Rendering>
|
|||||||
|
|
||||||
void _simulateStartTimeTicks() {
|
void _simulateStartTimeTicks() {
|
||||||
if (widget.onTick != null) {
|
if (widget.onTick != null) {
|
||||||
Iterable.generate(widget.startTimeSimulationTicks + 1).forEach((i) {
|
for (var i in Iterable.generate(widget.startTimeSimulationTicks + 1)) {
|
||||||
final simulatedTime = Duration(
|
final simulatedTime = Duration(
|
||||||
milliseconds: (widget.startTime.inMilliseconds *
|
milliseconds: (widget.startTime.inMilliseconds *
|
||||||
i /
|
i /
|
||||||
widget.startTimeSimulationTicks)
|
widget.startTimeSimulationTicks)
|
||||||
.round());
|
.round());
|
||||||
widget.onTick(simulatedTime);
|
widget.onTick!(simulatedTime);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,29 +118,28 @@ class _RenderingState extends State<Rendering>
|
|||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
class MultiTrackTween extends Animatable<Map<String, dynamic>> {
|
class MultiTrackTween extends Animatable<Map<String, dynamic>> {
|
||||||
final _tracksToTween = Map<String, _TweenData>();
|
final _tracksToTween = <String, _TweenData>{};
|
||||||
var _maxDuration = 0;
|
var _maxDuration = 0;
|
||||||
|
|
||||||
MultiTrackTween(List<Track> tracks)
|
MultiTrackTween(List<Track> tracks)
|
||||||
: assert(tracks != null && tracks.length > 0,
|
: assert(tracks.isNotEmpty, "Add a List<Track> to configure the tween."),
|
||||||
"Add a List<Track> to configure the tween."),
|
assert(tracks.where((track) => track.items.isEmpty).isEmpty,
|
||||||
assert(tracks.where((track) => track.items.length == 0).length == 0,
|
|
||||||
"Each Track needs at least one added Tween by using the add()-method.") {
|
"Each Track needs at least one added Tween by using the add()-method.") {
|
||||||
_computeMaxDuration(tracks);
|
_computeMaxDuration(tracks);
|
||||||
_computeTrackTweens(tracks);
|
_computeTrackTweens(tracks);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _computeMaxDuration(List<Track> tracks) {
|
void _computeMaxDuration(List<Track> tracks) {
|
||||||
tracks.forEach((track) {
|
for (var track in tracks) {
|
||||||
final trackDuration = track.items
|
final trackDuration = track.items
|
||||||
.map((item) => item.duration.inMilliseconds)
|
.map((item) => item.duration.inMilliseconds)
|
||||||
.reduce((sum, item) => sum + item);
|
.reduce((sum, item) => sum + item);
|
||||||
_maxDuration = max(_maxDuration, trackDuration);
|
_maxDuration = max(_maxDuration, trackDuration);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _computeTrackTweens(List<Track> tracks) {
|
void _computeTrackTweens(List<Track> tracks) {
|
||||||
tracks.forEach((track) {
|
for (var track in tracks) {
|
||||||
final trackDuration = track.items
|
final trackDuration = track.items
|
||||||
.map((item) => item.duration.inMilliseconds)
|
.map((item) => item.duration.inMilliseconds)
|
||||||
.reduce((sum, item) => sum + item);
|
.reduce((sum, item) => sum + item);
|
||||||
@@ -159,7 +160,7 @@ class MultiTrackTween extends Animatable<Map<String, dynamic>> {
|
|||||||
|
|
||||||
_tracksToTween[track.name] =
|
_tracksToTween[track.name] =
|
||||||
_TweenData(tween: sequence, maxTime: trackDuration / _maxDuration);
|
_TweenData(tween: sequence, maxTime: trackDuration / _maxDuration);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the highest duration specified by [Track]s.
|
/// Returns the highest duration specified by [Track]s.
|
||||||
@@ -186,10 +187,10 @@ class MultiTrackTween extends Animatable<Map<String, dynamic>> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, dynamic> transform(double t) {
|
Map<String, dynamic> transform(double t) {
|
||||||
final Map<String, dynamic> result = Map();
|
final Map<String, dynamic> result = {};
|
||||||
_tracksToTween.forEach((name, tweenData) {
|
_tracksToTween.forEach((name, tweenData) {
|
||||||
final double tTween = max(0, min(t, tweenData.maxTime - 0.0001));
|
final double tTween = max(0, min(t, tweenData.maxTime! - 0.0001));
|
||||||
result[name] = tweenData.tween.transform(tTween);
|
result[name] = tweenData.tween!.transform(tTween);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -200,7 +201,7 @@ class Track<T> {
|
|||||||
final String name;
|
final String name;
|
||||||
final List<_TrackItem> items = [];
|
final List<_TrackItem> items = [];
|
||||||
|
|
||||||
Track(this.name) : assert(name != null, "Track name must not be null.");
|
Track(this.name);
|
||||||
|
|
||||||
/// Adds a "piece of animation" to a [Track].
|
/// Adds a "piece of animation" to a [Track].
|
||||||
///
|
///
|
||||||
@@ -209,7 +210,7 @@ class Track<T> {
|
|||||||
///
|
///
|
||||||
/// Optionally you can set a named parameter [curve] that applies an easing
|
/// Optionally you can set a named parameter [curve] that applies an easing
|
||||||
/// curve to the tween.
|
/// curve to the tween.
|
||||||
Track<T> add(Duration duration, Animatable<T> tween, {Curve curve}) {
|
Track<T> add(Duration duration, Animatable<T> tween, {Curve? curve}) {
|
||||||
items.add(_TrackItem(duration, tween, curve: curve));
|
items.add(_TrackItem(duration, tween, curve: curve));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -217,11 +218,9 @@ class Track<T> {
|
|||||||
|
|
||||||
class _TrackItem<T> {
|
class _TrackItem<T> {
|
||||||
final Duration duration;
|
final Duration duration;
|
||||||
Animatable<T> tween;
|
late Animatable<T> tween;
|
||||||
|
|
||||||
_TrackItem(this.duration, Animatable<T> _tween, {Curve curve})
|
_TrackItem(this.duration, Animatable<T> _tween, {Curve? curve}) {
|
||||||
: assert(duration != null, "Please set a duration."),
|
|
||||||
assert(_tween != null, "Please set a tween.") {
|
|
||||||
if (curve != null) {
|
if (curve != null) {
|
||||||
tween = _tween.chain(CurveTween(curve: curve));
|
tween = _tween.chain(CurveTween(curve: curve));
|
||||||
} else {
|
} else {
|
||||||
@@ -231,8 +230,8 @@ class _TrackItem<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _TweenData<T> {
|
class _TweenData<T> {
|
||||||
final Animatable<T> tween;
|
final Animatable<T>? tween;
|
||||||
final double maxTime;
|
final double? maxTime;
|
||||||
|
|
||||||
_TweenData({this.tween, this.maxTime});
|
_TweenData({this.tween, this.maxTime});
|
||||||
}
|
}
|
||||||
@@ -305,31 +304,27 @@ class ControlledAnimation<T> extends StatefulWidget {
|
|||||||
final Animatable<T> tween;
|
final Animatable<T> tween;
|
||||||
final Curve curve;
|
final Curve curve;
|
||||||
final Duration duration;
|
final Duration duration;
|
||||||
final Duration delay;
|
final Duration? delay;
|
||||||
final Widget Function(BuildContext buildContext, T animatedValue) builder;
|
final Widget Function(BuildContext buildContext, T animatedValue)? builder;
|
||||||
final Widget Function(BuildContext, Widget child, T animatedValue)
|
final Widget Function(BuildContext, Widget? child, T animatedValue)?
|
||||||
builderWithChild;
|
builderWithChild;
|
||||||
final Widget child;
|
final Widget? child;
|
||||||
final AnimationStatusListener animationControllerStatusListener;
|
final AnimationStatusListener? animationControllerStatusListener;
|
||||||
final double startPosition;
|
final double startPosition;
|
||||||
|
|
||||||
ControlledAnimation(
|
const ControlledAnimation(
|
||||||
{this.playback = Playback.PLAY_FORWARD,
|
{this.playback = Playback.PLAY_FORWARD,
|
||||||
this.tween,
|
required this.tween,
|
||||||
this.curve = Curves.linear,
|
this.curve = Curves.linear,
|
||||||
this.duration,
|
required this.duration,
|
||||||
this.delay,
|
this.delay,
|
||||||
this.builder,
|
this.builder,
|
||||||
this.builderWithChild,
|
this.builderWithChild,
|
||||||
this.child,
|
this.child,
|
||||||
this.animationControllerStatusListener,
|
this.animationControllerStatusListener,
|
||||||
this.startPosition = 0.0,
|
this.startPosition = 0.0,
|
||||||
Key key})
|
Key? key})
|
||||||
: assert(duration != null,
|
: assert(
|
||||||
"Please set property duration. Example: Duration(milliseconds: 500)"),
|
|
||||||
assert(tween != null,
|
|
||||||
"Please set property tween. Example: Tween(from: 0.0, to: 100.0)"),
|
|
||||||
assert(
|
|
||||||
(builderWithChild != null && child != null && builder == null) ||
|
(builderWithChild != null && child != null && builder == null) ||
|
||||||
(builder != null && builderWithChild == null && child == null),
|
(builder != null && builderWithChild == null && child == null),
|
||||||
"Either use just builder and keep buildWithChild and child null. "
|
"Either use just builder and keep buildWithChild and child null. "
|
||||||
@@ -346,8 +341,8 @@ class ControlledAnimation<T> extends StatefulWidget {
|
|||||||
|
|
||||||
class _ControlledAnimationState<T> extends State<ControlledAnimation>
|
class _ControlledAnimationState<T> extends State<ControlledAnimation>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
AnimationController _controller;
|
late AnimationController _controller;
|
||||||
Animation<T> _animation;
|
late Animation<T?> _animation;
|
||||||
bool _isDisposed = false;
|
bool _isDisposed = false;
|
||||||
bool _waitForDelay = true;
|
bool _waitForDelay = true;
|
||||||
bool _isCurrentlyMirroring = false;
|
bool _isCurrentlyMirroring = false;
|
||||||
@@ -362,19 +357,19 @@ class _ControlledAnimationState<T> extends State<ControlledAnimation>
|
|||||||
|
|
||||||
_animation = widget.tween
|
_animation = widget.tween
|
||||||
.chain(CurveTween(curve: widget.curve))
|
.chain(CurveTween(curve: widget.curve))
|
||||||
.animate(_controller);
|
.animate(_controller) as Animation<T?>;
|
||||||
|
|
||||||
if (widget.animationControllerStatusListener != null) {
|
if (widget.animationControllerStatusListener != null) {
|
||||||
_controller.addStatusListener(widget.animationControllerStatusListener);
|
_controller.addStatusListener(widget.animationControllerStatusListener!);
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize() async {
|
Future<void> initialize() async {
|
||||||
if (widget.delay != null) {
|
if (widget.delay != null) {
|
||||||
await Future.delayed(widget.delay);
|
await Future.delayed(widget.delay!);
|
||||||
}
|
}
|
||||||
_waitForDelay = false;
|
_waitForDelay = false;
|
||||||
executeInstruction();
|
executeInstruction();
|
||||||
@@ -387,7 +382,7 @@ class _ControlledAnimationState<T> extends State<ControlledAnimation>
|
|||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void executeInstruction() async {
|
Future<void> executeInstruction() async {
|
||||||
if (_isDisposed || _waitForDelay) {
|
if (_isDisposed || _waitForDelay) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -423,9 +418,9 @@ class _ControlledAnimationState<T> extends State<ControlledAnimation>
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (widget.builder != null) {
|
if (widget.builder != null) {
|
||||||
return widget.builder(context, _animation.value);
|
return widget.builder!(context, _animation.value);
|
||||||
} else if (widget.builderWithChild != null && widget.child != null) {
|
} else if (widget.builderWithChild != null && widget.child != null) {
|
||||||
return widget.builderWithChild(context, widget.child, _animation.value);
|
return widget.builderWithChild!(context, widget.child, _animation.value);
|
||||||
}
|
}
|
||||||
_controller.stop(canceled: true);
|
_controller.stop(canceled: true);
|
||||||
throw FlutterError(
|
throw FlutterError(
|
||||||
@@ -452,10 +447,7 @@ class AnimationProgress {
|
|||||||
final Duration startTime;
|
final Duration startTime;
|
||||||
|
|
||||||
/// Creates an [AnimationProgress].
|
/// Creates an [AnimationProgress].
|
||||||
AnimationProgress({this.duration, this.startTime})
|
AnimationProgress({required this.duration, required this.startTime});
|
||||||
: assert(duration != null, "Please specify an animation duration."),
|
|
||||||
assert(
|
|
||||||
startTime != null, "Please specify a start time of the animation.");
|
|
||||||
|
|
||||||
/// Queries the current progress value based on the specified [startTime] and
|
/// Queries the current progress value based on the specified [startTime] and
|
||||||
/// [duration] as a value between `0.0` and `1.0`. It will automatically
|
/// [duration] as a value between `0.0` and `1.0`. It will automatically
|
||||||
|
|||||||
@@ -20,6 +20,20 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_lints:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_lints
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.4"
|
||||||
|
lints:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: lints
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.1"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ description: Example for the simple_animations package
|
|||||||
homepage: https://github.com/felixblaschke/simple_animations
|
homepage: https://github.com/felixblaschke/simple_animations
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.2.0 <3.0.0"
|
sdk: '>=2.12.0 <3.0.0'
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
flutter_lints: ^1.0.4
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- preview.png
|
- preview.png
|
||||||
|
|||||||
Reference in New Issue
Block a user