Flutter makes it easy and fast to build beautiful apps for mobile and beyond
BSD 3-Clause "New" or "Revised" License
165.72k
stars
27.37k
forks
source link
`Slider::onChanged` fires twice after window is resized horizontally. #112290
Open
a-wallen opened 2 years ago
https://user-images.githubusercontent.com/44445638/192026531-6aff356a-78c1-4591-91c8-2425ca62a179.mov
Behavior works as expected for the vertical slider, but not the horizontal one. Instead of dragging, I am tapping the slider for clarity.
Steps to Reproduce
I suppose this will work for any platform, but I am running a macos app.
Expected results: Horizontal slider resizes the window like the vertical slider
Actual results: Horizontal slider resizes to the maximum value every time
MainFlutterWindow.swift
```swift // Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import Cocoa import FlutterMacOS extension NSWindow { var titlebarHeight: CGFloat { frame.height - contentRect(forFrameRect: frame).height } } class MainFlutterWindow: NSWindow { override func awakeFromNib() { let flutterViewController = FlutterViewController.init() let windowFrame = self.frame self.contentViewController = flutterViewController self.setFrame(windowFrame, display: true) RegisterMethodChannel(registry: flutterViewController) RegisterGeneratedPlugins(registry: flutterViewController) super.awakeFromNib() } func RegisterMethodChannel(registry: FlutterPluginRegistry) { let registrar = registry.registrar(forPlugin: "resize") let channel = FlutterMethodChannel(name: "samples.flutter.dev/resize", binaryMessenger: registrar.messenger) channel.setMethodCallHandler({ (call, result) in if call.method == "resize" { if let args = call.arguments as? Dictionarymain.dart
```dart // Copyright 2014 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() async { runApp(const ResizeApp()); } class ResizeApp extends StatefulWidget { const ResizeApp({super.key}); static const MethodChannel platform = MethodChannel('samples.flutter.dev/resize'); static const Key heightLabel = Key('height label'); static const Key widthLabel = Key('width label'); static const Key heightSlider = Key('height slider'); static const Key widthSlider = Key('width slider'); static const Size constraints = Size(150, 150); Future