Removed old Stack layout and added a simple-to-extend interface for the
new drawer header. Also added a specialized UserAccountsDrawerHeader
consistent with Material Design guidelines.
We now use a different approach for ios projects where the developer controls
the Xcode project file. This patch removes the old ".generated" approach in
favor of the new approach.
Anywhere that accepted IconData now accepts either an Icon or an
ImageIcon.
Places that used to take an IconData in an `icon` argument, notably
IconButton and DrawerItem, now take a Widget in that slot. You can wrap
the value that used to be passed in in an Icon constructor to get the
same result.
Icon itself now takes the icon as a positional argument, for brevity.
ThemeData now has an iconTheme as well as a primaryIconTheme, the same
way it has had a textTheme and primaryTextTheme for a while.
IconTheme.of() always returns a value now (though that value itself may
have nulls in it). It defaults to the ThemeData.iconTheme.
IconThemeData.fallback() is a new method that returns an icon theme data
structure with all fields filled in.
IconTheme.merge() is a new constructor that takes a context and creates
a widget that mixes in the new values with the inherited values.
Most places that introduced an IconTheme widget now use IconTheme.merge.
IconThemeData.merge and IconThemeData.copyWith act in a way analogous to
the similarly-named members of TextStyle.
ImageIcon is introduced. It acts like Icon but takes an ImageProvider
instead of an IconData.
Also: Fix the analyzer to actually check the stocks app.
This makes it possible to substitute 'flutter run' for 'flutter test'
and actually watch a test run on a device.
For any test that depends on flutter_test:
1. Remove any import of 'package:test/test.dart'.
2. Replace `testWidgets('...', (WidgetTester tester) {`
with `testWidgets('...', (WidgetTester tester) async {`
3. Add an "await" in front of calls to any of the following:
* tap()
* tapAt()
* fling()
* flingFrom()
* scroll()
* scrollAt()
* pump()
* pumpWidget()
4. Replace any calls to `tester.flushMicrotasks()` with calls to
`await tester.idle()`.
There's a guarding API that you can use, if you have particularly
complicated tests, to get better error messages. Search for
TestAsyncUtils.
TextAlign applies to a whole paragraph instead of applying to an individual
text span. This patch moves the property out of TextStyle and into a separate
property on Text and RichText.
* Move global analysis options file to the repo root
Also restore the analysis options file for stocks example, since
the global options trigger warnings on generated intl files.
* Remove obsolete analysis options file for Material Gallery example
* Refactor widget test framework
Instead of:
```dart
test("Card Collection smoke test", () {
testWidgets((WidgetTester tester) {
```
...you now say:
```dart
testWidgets("Card Collection smoke test", (WidgetTester tester) {
```
Instead of:
```dart
expect(tester, hasWidget(find.text('hello')));
```
...you now say:
```dart
expect(find.text('hello'), findsOneWidget);
```
Instead of the previous API (exists, widgets, widget, stateOf,
elementOf, etc), you now have the following comprehensive API. All these
are functions that take a Finder, except the all* properties.
* `any()` - true if anything matches, c.f. `Iterable.any`
* `allWidgets` - all the widgets in the tree
* `widget()` - the one and only widget that matches the finder
* `firstWidget()` - the first widget that matches the finder
* `allElements` - all the elements in the tree
* `element()` - the one and only element that matches the finder
* `firstElement()` - the first element that matches the finder
* `allStates` - all the `State`s in the tree
* `state()` - the one and only state that matches the finder
* `firstState()` - the first state that matches the finder
* `allRenderObjects` - all the render objects in the tree
* `renderObject()` - the one and only render object that matches the finder
* `firstRenderObject()` - the first render object that matches the finder
There's also `layers' which returns the list of current layers.
`tap`, `fling`, getCenter, getSize, etc, take Finders, like the APIs
above, and expect there to only be one matching widget.
The finders are:
* `find.text(String text)`
* `find.widgetWithText(Type widgetType, String text)`
* `find.byKey(Key key)`
* `find.byType(Type type)`
* `find.byElementType(Type type)`
* `find.byConfig(Widget config)`
* `find.byWidgetPredicate(WidgetPredicate predicate)`
* `find.byElementPredicate(ElementPredicate predicate)`
The matchers (for `expect`) are:
* `findsNothing`
* `findsWidgets`
* `findsOneWidget`
* `findsNWidgets(n)`
* `isOnStage`
* `isOffStage`
* `isInCard`
* `isNotInCard`
Benchmarks now use benchmarkWidgets instead of testWidgets.
Also, for those of you using mockers, `serviceMocker` now automatically
handles the binding initialization.
This patch also:
* changes how tests are run so that we can more easily swap the logic
out for a "real" mode instead of FakeAsync.
* introduces CachingIterable.
* changes how flutter_driver interacts with the widget tree to use the
aforementioned new API rather than ElementTreeTester, which is gone.
* removes ElementTreeTester.
* changes the semantics of a test for scrollables because we couldn't
convince ourselves that the old semantics made sense; it only worked
before because flushing the microtasks after every event was broken.
* fixes the flushing of microtasks after every event.
* Reindent the tests
* Fix review comments
Previously, the client of PopupMenuButton needed to build all the menu times
when building the PopupMenuButton. This can get expensive if, for example, each
item in a scrollable list has a popup menu associated with it.
Now the client passes a builder function to the PopupMenuButton that gets
invoked only when its time to show the menu items.
Previously, border with '0' was ambiguous. Sometimes we treated it as
hairline borders, sometimes as "don't show the border", though even in
the latter case we did some graphics work sometimes. Now we have an
explicit BorderStyle.none flag to not draw the border efficiently.
* left -> leading (Removes an LTR bias)
* center -> title (Widget was actually centered)
* right -> actions (Removes an LTR bias, asymmetric with leading)
Fixes#2348
Specifically:
* Handle null styles in TextSpan without crashing in toString().
* Handle null children in TextSpan child lists without crashing in
toString().
* Handle entirely empty TextSpans in toString() explicitly.
* Assert that TextSpans don't contain nulls in various places. This is
done more often than one might think necessary, because it turns out
that TextSpan takes a (mutable) List for one of its arguments, so
who knows what it will contain at any given time. By asserting all
over the place, hopefully we'll catch it near the change if they do
change it.
* Add a RichText example to Stocks to exercise RichText and TextSpans.
See also: https://github.com/flutter/flutter/issues/2514, https://github.com/flutter/flutter/issues/2519
After running a widget test, we now clear out the widget tree and check that we
didn't leak any timers or animations.
Also, fix several bugs that this addtional check revealed.
Fixes#2481
Rather than managing all the Material Design icons manually, we now
manage them using an icon font. The icon font contains glyphs for each
icon in an efficient vector format.
This patch updates the FLX tooling to include the MaterialIcons font and
updates the Icon widget to use the font instead of asset images.
Fixes#2313Fixes#2218Fixes#2009Fixes#994
Each layer is supposed to reexport the parts of the previous layer
that are part of its API.
- In painting.dart, export from dart:ui all the Canvas-related APIs
that make sense to be used at higher levels, e.g. PaintingStyle.
- Delete painting/shadows.dart. It was dead code.
- In rendering/object.dart, export all of painting.dart.
- In widgets/basic.dart, export all of painting.dart and
animation.dart. Some classes in animation/ are renamed to make this
less disruptive and confusing to the namespace.
- Split out Stocks back into an import model rather than a part model,
so that it's easier to manage its dependencies on a per-file basis.
- Move Ticker to scheduler library.
- Remove as many redundant imports as possible now.
- Some minor nit picking cleanup in various files.
Introduces a new Tooltip class.
Adds support for tooltips to IconButton and Scaffold.
Adds some tooltips to various demos.
Also some tweaks to stack.dart that I made before I decided not to go
down a "CustomPositioned" route.
The Firebase server seems to have changed behavior and is not giving us a List
instead of a Map. This patch switches us back to GitHub, which just serves the
same flat files all the time.
- Add an option to enable debugPaintSizeEnabled.
- Add an option to enable the StatisticsOverlay.
- Add support for the StatisticsOverlay in MaterialApp.
- Change the layout behaviour of RenderStatisticsBox:
- Give it a zero intrinsic width.
- Give it an accurate intrinsic height that depends on the flags
set. (Also, move the enum to the rendering/ layer from the
widgets/ layer to enable this.)
- Make the box automatically size itself full-width and the correct
height, so that you can actually embed it (though most of the
time you'd just put it in a Stack so this doesn't matter as
much, really).
- Some style nit fixes in statistics_box.dart.
This patch also changed ScrollableList2 to use an Iterable instead of an
List for its children. This change lets clients map their underlying
data lazily. If the clients actually have a concrete list, we skip the
extra copy and grab the child list directly.
The TabBarSelection change animation needs to start where the fling's drag gesture ended rather than from zero. The intial vlaue of progress for the TabBarSelection's performance is now converted from the range used during an interactive drag, to the range used when animating from the previously selected tab to the new one.
TabBarSelection now requires a maxIndex parameter.
This matches the naming pattern expected from package:test
`flutter test` doesn't care, since it finds all _test.dart
files and runs them regardless of directory.
@Hixie
I had to add a setLocale method to WidgetTester and
split the code in FlutterBinding which handled locale
changes to allow me to dispatch a locale change w/o actually
changing what the c++ code reports as the locale.
Also added the test to Travis.
@abarth @jason-simmons