74 Commits

Author SHA1 Message Date
Tomasz Gucio
99c7e9f088
Add spaces after flow control statements (#126320) 2023-05-15 11:07:30 +02:00
Ian Hickson
3fe5740153
Documentation improvements (#122787)
Documentation improvements
2023-03-22 18:58:57 +00:00
Michael Goderbauer
25e38a2a87
Bump lower Dart SDK constraints to 3.0 & add class modifiers (#122546)
Bump lower Dart SDK constraints to 3.0 & add class modifiers
2023-03-21 20:21:58 +00:00
Greg Spencer
fb9133b881
Add ListenableBuilder with examples (#116543)
* Add ListenableBuilder with examples

* Add tests

* Add tests

* Fix Test

* Change AnimatedBuilder to be a subclass of ListenableBuilder
2022-12-07 01:15:22 +00:00
chunhtai
3a3a0db13e
Disallow dispose during listener callback (#114530)
* Disallow dispose during listener callback

* addressing comment

* add comments to code

* Addressing comments

* fix test
2022-11-18 09:29:59 -08:00
Polina Cherkasova
0a35cf95eb
Instrument State, Layer, RenderObject and Element. (#111328) 2022-09-20 16:39:46 -07:00
Polina Cherkasova
3860498972
Fix performance regression. (#111615) 2022-09-14 17:11:12 -07:00
Greg Spencer
228ea2c28e
Fix references to symbols to use brackets instead of backticks (#111331) 2022-09-12 18:31:45 +00:00
Polina Cherkasova
a3c3dc864c
Create class MemoryAllocations. (#110230) 2022-09-09 17:23:10 -07:00
chunhtai
6225bea261
Can call ChangeNotifier.hasListeners after disposed (#108931) 2022-08-04 17:21:06 +00:00
Dan Field
201be6bdf5
Update docs on ChangeNotifier.dispose and KeepAliveHandle.release (#108384) 2022-07-26 22:09:05 +00:00
Alexandre Ardhuin
526ca0d498
Export public API types from foundation/scheduler/gestures/semantics (#106409) 2022-06-24 21:21:05 +00:00
Alexandre Ardhuin
0cdb3bf582
Export public API types from foundation/*.dart library. (#105648) 2022-06-09 11:53:11 -07:00
Greg Spencer
16b7348155
Switch debugAssertNotDisposed to be a static (#104772)
This reverts part of the change made in #103456 to expose a debug check for subclasses of ChangeNotifier to avoid code duplication. Instead of making debugAssertNotDisposed a public instance function, it is now a public static function. It makes it harder to call, slightly, but it means that everyone who implemented ChangeNotifier instead of extending it doesn't get broken.
2022-05-31 10:33:46 -07:00
Pierre-Louis
9cc72df781
Use curly_braces_in_flow_control_structures for foundation, gestures, painting, physics (#104610)
* Use `curly_braces_in_flow_control_structures` for `foundation`

* Use `curly_braces_in_flow_control_structures` for `gestures`

* Use `curly_braces_in_flow_control_structures` for `painting`

* Use `curly_braces_in_flow_control_structures` for `physics`

* fix comments

* remove trailing space

* fix TODO style
2022-05-25 19:55:22 +02:00
Greg Spencer
f6c3ee310f
Add ShortcutsRegistry (#103456)
This adds a ShortcutsRegistry for ShortcutActivator to Intent mappings that can be modified from its descendants.

This is so that descendants can make shortcuts dynamically available to a larger portion of the app than just their descendants. This is a precursor needed by the new MenuBar, for instance, so that the menu bar itself can be placed where it likes, but the shortcuts it defines can be in effect for most, if not all, of the UI surface in the app. For example, the "Ctrl-Q" quit binding would need to work even if the focused widget wasn't a child of the MenuBar.

This just provides the shortcut to intent mapping, the actions activated by the intent are described in the context where they make sense. For example, defining a "Ctrl-C" shortcut mapped to a "CopyIntent" should perform different functions if it happens while a TextField has focus vs when a drawing has focus, so those different areas would need to define different actions mapped to "CopyIntent". A hypothetical "QuitIntent" would probably be active for the entire app, so would be mapped in an Actions widget near the top of the hierarchy.
2022-05-19 13:17:42 -07:00
Pierre-Louis
9d4e81678b
Fix deprecated_new_in_comment_reference for material library (#100289)
* fix deprecated_new_in_comment_reference for `material` library

in a future version of the SDK, these will be flagged, fix them now

* Update pubspec.yaml
2022-03-21 20:18:40 +01:00
Alberto
b44cbe1dd5
feat: Added docstring examples to AnimatedBuilder and ChangeNotifier (#98628) 2022-02-28 12:41:20 -08:00
chunhtai
286c9751d3
Add explanation to ChangeNotifier (#98295) 2022-02-15 18:15:18 -08:00
chunhtai
5f3bee55ad
Allow remove listener on disposed change notifier (#97988) 2022-02-09 11:10:13 -08:00
Michael Goderbauer
5684b9f69e
Enable no_leading_underscores_for_local_identifiers (#96422) 2022-01-21 14:43:59 -08:00
Dan Field
ab0a335973
Ban sync*/async* from user facing code (#95050) 2021-12-12 13:05:03 -08:00
Ahmed Ashour
a3dc90c4f5
Add space before curly parentheses. (#85306) 2021-07-01 13:51:05 -07:00
Michael Goderbauer
2a8dba4af6
Treat some exceptions as unhandled when a debugger is attached (#78649) 2021-04-15 10:49:02 -07:00
Romain Rastel
10d5ec875d
Improve the performances of ChangeNotifier (#71947) 2021-04-14 16:49:03 -07:00
Alexandre Ardhuin
a6832d4d32
add missing trailing commas (#79299) 2021-03-29 21:29:02 -07:00
Greg Spencer
8c03ff8c1d
Mark keys that match a shortcut, but have no action defined as "not handled". (#67359)
- - When I added notification of key events before processing them as text, it made it so that shortcut key bindings like the spacebar would prevent spaces from being inserted into text fields, which is obviously not desirable (and so that change was reverted). At the same time, we do want to make it possible to override key events so that they can do things like intercept a tab key or arrow keys that change the focus.

This PR changes the behavior of the Shortcuts widget so that if it has a shortcut defined, but no action is bound to the intent, then instead of responding that the key is "handled", it responds as if nothing handled it. This allows the engine to continue to process the key as text entry.

This PR includes:

- Modification of the callback type for key handlers to return a KeyEventResult instead of a bool, so that we can return more information (i.e. the extra state of "stop propagation").
- Modification of the ActionDispatcher.invokeAction contract to require that Action.isEnabled return true before calling it. It will now assert if the action isn't enabled when invokeAction is called. This is to allow optimization of the number of calls to isEnabled, since the shortcuts widget now wants to know if the action was enabled before deciding to either handle the key or to return ignored.
- Modification to ShortcutManager.handleKeypress to return KeyEventResult.ignored for keys which don't have an enabled action associated with them.
- Adds an attribute to DoNothingAction that allows it to mark a key as not handled, even though it does have an action associated with it. This will allow disabling of a shortcut for a subtree.
2020-10-19 11:26:50 -07:00
Remi Rousselet
68c31d3d09
Use a LinkedList to improve the performance of ChangeNotifier (#62330)
* Use a LinkedList in ChangeNotifier implementation to take O(N^2) notification time to O(N)
2020-08-26 11:34:03 -07:00
Todd Volkert
e91b833933
Minor doc updates (#62008) 2020-07-22 18:28:08 -07:00
Alexandre Ardhuin
978a2e7bf6
migrate foundation to nullsafety (#61188)
* migrate foundation to nullsafety

* address review comments
2020-07-15 18:55:27 +02:00
Alexandre Ardhuin
4d7525f05c
Opt out nnbd in packages/flutter (#59186)
* add language version 2.8 in packages/flutter

* enable non-nullable analyzer flag
2020-06-11 14:11:30 +02:00
Greg Spencer
0f68b46f6a
Revise Action API (#42940)
This updates the Action API in accordance with the design doc for the changes: flutter.dev/go/actions-and-shortcuts-design-revision

Fixes #53276
2020-04-07 16:49:39 -07:00
Greg Spencer
d19c44344b
Add sample for InheritedNotifier, convert two others to DartPa… (#52349)
This adds a sample for InheritedNotifier, and converts a couple of other samples to be DartPad samples. I also added a new sample template stateful_widget_material_ticker, which adds a TickerProviderStateMixin to the state object so that animation controllers can be created there easily.
2020-03-10 15:23:45 -07:00
Albertus Angga Raharja
aad941e3fa
Avoid using FlutterError.fromParts when possible (#43696)
This PR is a follow up of https://github.com/flutter/flutter/pull/42640
Some changes of that PR includes redundant changes using FlutterError.fromParts constructor even though it's not necessary.

Some minor changes are:

- Remove one unnecessary todo
- Fix indent consistencies
2020-02-20 07:51:53 -08:00
Alexandre Ardhuin
4f9b6cf017
enable lint prefer_final_in_for_each (#47724) 2020-01-07 16:32:04 +01:00
Ian Hickson
449f4a6673
License update (#45373)
* Update project.pbxproj files to say Flutter rather than Chromium

Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright.

* Update the copyright notice checker to require a standard notice on all files

* Update copyrights on Dart files. (This was a mechanical commit.)

* Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine.

Some were already marked "The Flutter Authors", not clear why. Their
dates have been normalized. Some were missing the blank line after the
license. Some were randomly different in trivial ways for no apparent
reason (e.g. missing the trailing period).

* Clean up the copyrights in non-Dart files. (Manual edits.)

Also, make sure templates don't have copyrights.

* Fix some more ORGANIZATIONNAMEs
2019-11-27 15:04:02 -08:00
Albertus Angga Raharja
b31ca1aaca
Add more structure to errors (continuation of #34684) (#42640)
* Add structured errors in Animations, TabView, ChangeNotifier

* Add structured error on MaterialPageRoute, BoxBorder, DecorationImagePainter, TextSpan

* Add structured errors in Debug

* Fix test errors

* Add structured errors in Scaffold and Stepper

* Add structured errors in part of Rendering Layer

* Fix failing test due to FloatingPoint precision

* Fix failing tests due to precision error and not using final

* Fix failing test due to floating precision error with RegEx instead

* Add structured error in CustomLayout and increase test coverage

* Add structured error & its test in ListBody

* Add structured error in ProxyBox and increase test coverage

* Add structured error message in Viewport

* Fix styles and add more assertions on ErrorHint and DiagnosticProperty

* Add structured error in scheduler/binding and scheduler/ticker

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>

* Add structured error in AssetBundle and TextInput

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>

* Add structured errors in several widgets #1

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>

* Remove unused import

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>

* Add assertions on hint messages

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>

* Fix catch spacing

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>

* Add structured error in several widgets part 2 and increase code coverage

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>

* Add structured error in flutter_test/widget_tester

* Fix floating precision accuracy by using RegExp

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>

* Remove todo to add tests in Scaffold showBottomSheet

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>

* Fix reviews by indenting lines and fixing the assertion orders

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>

* Fix failing tests due to renaming class

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>

* Try skipping the NetworkBundleTest

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>

* Remove leading space in material/debug error hint

Signed-off-by: Albertus Angga Raharja <albertusangga@google.com>
2019-10-28 11:00:49 -07:00
Jacob Richman
63aa5b3647
Refactor core uses of FlutterError. (#30983)
Make FlutterError objects more structured so they can be displayed better in debugging tools such as Dart DevTools.
2019-05-01 11:20:12 -07:00
Michael Goderbauer
3c8dabefe7
Be more explicit when ValueNotifier notifies (#30461) 2019-04-04 00:13:07 -07:00
Alexandre Ardhuin
a6af422874
some spaces formatting (#29452)
* some space formattings

* always use blocks in if-else if a block is used

* format spaces in for and while

* allow multiline if conditions

* fix missing space
2019-03-20 23:23:31 +01:00
Alexandre Ardhuin
387f885481
Add missing trailing commas (#28673)
* add trailing commas on list/map/parameters

* add trailing commas on Invocation with nb of arg>1

* add commas for widget containing widgets

* add trailing commas if instantiation contains trailing comma

* revert bad change
2019-03-01 08:17:55 +01:00
Michael Goderbauer
6d20ff2446
Remove all obsolete "// ignore:" (#27271) 2019-01-30 08:56:12 -08:00
Michael Goderbauer
b13eacc717
Fix Listenable.merge to not leak (#26313) 2019-01-10 12:17:45 -08:00
Alexandre Ardhuin
e41f1463cd
make see also sections uniform (#25513) 2018-12-18 21:45:20 +01:00
Ian Hickson
c319b890b3
Allow ChangeNotifier to be mixed in again (#23631)
Luckily this class didn't actually need to extend its superclass, it
only implements the interface. So we can change `extends` to
`implements` and that's close enough, while allowing the class to be
mixed in again.
2018-10-29 19:44:36 -07:00
Ian Hickson
931328596a
[H] Created a variant of InheritedWidget specifically for Listenables (#23393)
* Created a variant of InheritedWidget specifically for Listenables

* Add more documentation per review comments
2018-10-27 16:51:39 -07:00
Alexandre Ardhuin
d927c93310
Unnecessary new (#20138)
* enable lint unnecessary_new

* fix tests

* fix tests

* fix tests
2018-09-12 08:29:29 +02:00
Ian Hickson
b9a7f1b915
Add a hasListeners to ChangeNotifier (#14946)
I found that some ValueListeners want to know when they should start
doing work (e.g. if the value comes from polling a network resource).
2018-02-28 16:37:36 -08:00
Ian Hickson
3ac9449ad4
Fix the confusing-zero case with NestedScrollView. (#14133)
* Fix the confusing-zero case with NestedScrollView.

* Update mock_canvas.dart

* Update tabs_demo.dart

* more tweaks
2018-01-18 20:21:15 -08:00
Greg Spencer
0259be90b8
Fix spelling errors in all the dartdocs. (#13061)
I got tired of drive-by spelling fixes, so I figured I'd just take care of them all at once.

This only corrects errors in the dartdocs, not regular comments, and I skipped any sample code in the dartdocs. It doesn't touch any identifiers in the dartdocs either. No code changes, just comments.
2017-11-17 10:05:21 -08:00