Skip to content

Drawer fix#20015

Merged
jslavitz merged 7 commits intoflutter:masterfrom
jslavitz:drawerFix2
Aug 1, 2018
Merged

Drawer fix#20015
jslavitz merged 7 commits intoflutter:masterfrom
jslavitz:drawerFix2

Conversation

@jslavitz
Copy link
Contributor

Fixes #19704

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought - maybe this is worth doing to avoid the assert. What if instead of not building one drawer when the other is opened - you changed the order in which they were built such that the open drawer is on top?

Might be a simple change that will still fix the issue without requiring an assert.


import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter/material.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import the appropriate source files from material (like below) instead of the entire lib. The circular import will break the docs shard

/// Typically called by [ScaffoldState.openDrawer].
void open() {
_controller.fling(velocity: 1.0);
if(widget.drawerCallback != null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space between if and (, here and elsewhere

behavior: HitTestBehavior.translucent,
excludeFromSemantics: true,
child: new Container(width: _kEdgeDragWidth)
key: _gestureDetectorKey,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert unrelated change, here and elsewhere


void _drawerOpenedCallback(bool isOpened) {
_drawerOpened = isOpened;
setState(() {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For more idiomatic setState:

setState(() {
  _drawerOpened = isOpened;
});

removeBottomPadding: false,
);
if(!_endDrawerOpened) {
if (widget.drawer != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine these if statements -
if (widget.drawer != null && !_endDrawerOpened)

removeRightPadding: textDirection == TextDirection.rtl,
removeBottomPadding: false,
);
if (!_drawerOpened) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

right: false,
bottom: false,
child: new Scaffold(
endDrawer: new Drawer(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ident by 2 lines

import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';

import 'package:flutter/material.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to fix this import 📁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I get like 100 errors if I take it out... How do I know which specific files to include?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the auto import suggestion in intellij you should see an option that imports from '/material/src` - just pick those and then make them relative.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I didn't need that import, must have not been filtering for the errors in the current file before.

@jslavitz jslavitz dismissed jonahwilliams’s stale review July 31, 2018 16:45

Fixed the issues!

@jonahwilliams jonahwilliams removed the request for review from gspencergoog July 31, 2018 17:48
@jonahwilliams
Copy link
Contributor

Ignore the result of travis BTW

@jonahwilliams
Copy link
Contributor

@jslavitz This is good to submit

@jslavitz jslavitz merged commit d2ab29d into flutter:master Aug 1, 2018
@jslavitz jslavitz deleted the drawerFix2 branch August 1, 2018 17:14
GlobalKey key,
@required this.child,
@required this.alignment,
this.drawerCallback,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be called onFoo, not fooCallback

final DrawerAlignment alignment;

/// Optional callback that is called when a [Drawer] is opened or closed.
final DrawerCallback drawerCallback;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe onDrawerChange or some such.

Or maybe even better, have two callbacks, onOpen and onClose.

numNotificationsAtLastFrame = listenerState.numNotifications;
});

testWidgets('Simultaneous drawers on either side', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this moved to the ScaffoldGeometry test section?

@Hixie
Copy link
Contributor

Hixie commented Aug 3, 2018

This seems to have regressed the stock_animation_close_first_frame_average benchmark a little.

@jslavitz
Copy link
Contributor Author

jslavitz commented Aug 3, 2018

Where can I check out that benchmark? Maybe we could just do the set state using Future so that it doesn't get called on the first frame of the animation?

@Hixie
Copy link
Contributor

Hixie commented Aug 3, 2018

I don't really understand what caused the regression. Nothing here looks like it should be slow.

https://flutter-dashboard.appspot.com/benchmarks.html has the results of the benchmarks
The benchmarks themselves are in dev/devicelab, there's a README there that explains how to run them locally.

@jslavitz
Copy link
Contributor Author

jslavitz commented Aug 4, 2018

So what benchmark am I looking at? The only thing I can figure is that the set state calls slowed it down? Outside of that, I agree, nothing should be causing performance issues.

@jonahwilliams
Copy link
Contributor

@jslavitz lets look at them on Monday

@Hixie
Copy link
Contributor

Hixie commented Aug 10, 2018

Did y'all come to any conclusion on this?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The endDrawer can be dragged over the drawer

4 participants