Teach drag start behaviors to DragGestureRecognizer (#26246)
* the onStart callback will report the location of the pointer where it wins the gesture arena by default instead of the pointer down location. Fixes all tests related to changing this default value.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/gestures.dart' show DragStartBehavior;
|
||||
|
||||
import '../../gallery/demo.dart';
|
||||
|
||||
@@ -79,6 +80,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
drawerDragStartBehavior: DragStartBehavior.down,
|
||||
key: _scaffoldKey,
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
@@ -106,6 +108,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
),
|
||||
otherAccountsPictures: <Widget>[
|
||||
GestureDetector(
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
onTap: () {
|
||||
_onOtherAccountsTap(context);
|
||||
},
|
||||
@@ -120,6 +123,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
onTap: () {
|
||||
_onOtherAccountsTap(context);
|
||||
},
|
||||
@@ -149,6 +153,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
|
||||
removeTop: true,
|
||||
child: Expanded(
|
||||
child: ListView(
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
children: <Widget>[
|
||||
Stack(
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/gestures.dart' show DragStartBehavior;
|
||||
|
||||
import '../../gallery/demo.dart';
|
||||
|
||||
@@ -67,6 +68,7 @@ class _PasswordFieldState extends State<PasswordField> {
|
||||
labelText: widget.labelText,
|
||||
helperText: widget.helperText,
|
||||
suffixIcon: GestureDetector(
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_obscureText = !_obscureText;
|
||||
@@ -167,6 +169,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
drawerDragStartBehavior: DragStartBehavior.down,
|
||||
key: _scaffoldKey,
|
||||
appBar: AppBar(
|
||||
title: const Text('Text fields'),
|
||||
@@ -180,6 +183,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
|
||||
autovalidate: _autovalidate,
|
||||
onWillPop: _warnUserAboutInvalidData,
|
||||
child: SingleChildScrollView(
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/gestures.dart' show DragStartBehavior;
|
||||
|
||||
import 'backdrop.dart';
|
||||
import 'demos.dart';
|
||||
@@ -256,6 +257,7 @@ class _DemosPage extends StatelessWidget {
|
||||
label: category.name,
|
||||
explicitChildNodes: true,
|
||||
child: ListView(
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
key: PageStorageKey<String>(category.name),
|
||||
padding: EdgeInsets.only(top: 8.0, bottom: windowBottomPadding),
|
||||
children: kGalleryCategoryToDemos[category].map<Widget>((GalleryDemo demo) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart' show debugDumpRenderTree, debugDumpLayerTree, debugDumpSemanticsTree, DebugSemanticsDumpOrder;
|
||||
import 'package:flutter/scheduler.dart' show timeDilation;
|
||||
import 'package:flutter/gestures.dart' show DragStartBehavior;
|
||||
import 'stock_data.dart';
|
||||
import 'stock_list.dart';
|
||||
import 'stock_strings.dart';
|
||||
@@ -110,6 +111,7 @@ class StockHomeState extends State<StockHome> {
|
||||
Widget _buildDrawer(BuildContext context) {
|
||||
return Drawer(
|
||||
child: ListView(
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
children: <Widget>[
|
||||
const DrawerHeader(child: Center(child: Text('Stocks'))),
|
||||
const ListTile(
|
||||
@@ -317,11 +319,13 @@ class StockHomeState extends State<StockHome> {
|
||||
return DefaultTabController(
|
||||
length: 2,
|
||||
child: Scaffold(
|
||||
drawerDragStartBehavior: DragStartBehavior.down,
|
||||
key: _scaffoldKey,
|
||||
appBar: _isSearching ? buildSearchBar() : buildAppBar(),
|
||||
floatingActionButton: buildFloatingActionButton(),
|
||||
drawer: _buildDrawer(context),
|
||||
body: TabBarView(
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
children: <Widget>[
|
||||
_buildStockTab(context, StockHomeTab.market, widget.stocks.allSymbols),
|
||||
_buildStockTab(context, StockHomeTab.portfolio, portfolioSymbols),
|
||||
|
||||
Reference in New Issue
Block a user