flutter web drawer drawerEnableOpenDragGesture 不起作用

问题描述 投票:0回答:1

这是我的代码

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  final GlobalKey<ScaffoldState> _myKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        drawerEnableOpenDragGesture: true,
        appBar: AppBar(
          title: const Text('Demo Drawer'),
          automaticallyImplyLeading: false,
          actions: [],
        ),
        key: _myKey,
        drawer: Drawer(
          child: Text('start'),
        ),

        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () => _myKey.currentState!.openDrawer(),
                child: const Text('開啟右邊的 Drawer >'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

在模拟器中一切正常,当我在右边缘滑动时抽屉将打开。

但是当我在网络中构建时,手势不起作用。

我设置了

drawerEnableOpenDragGesture: true
但是没用

如何解决它。谢谢

flutter drawer
1个回答
0
投票

请注意,

drawerEnableOpenDragGesture
不是 Flutter web 中 Scaffold 的有效属性。相反,您可以使用 :

 endDrawerEnableOpenDragGesture: true, 
© www.soinside.com 2019 - 2024. All rights reserved.