Repository: flutter
Issue: `Slider::onChanged` fires twice after window is resized horizontally.
Labels: framework,f: material design,has reproducible steps,found in release: 3.3,found in release: 3.4,team-design,triaged-design


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:** <!-- what did you see? -->
Horizontal slider resizes to the maximum value every time

<details>
<summary>MainFlutterWindow.swift</summary>

```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? Dictionary<String, Any>,
          let width = args["width"] as? Double,
          var height = args["height"] as? Double {
          height += self.titlebarHeight
          let currentFrame: NSRect = self.frame
          let nextFrame: NSRect = NSMakeRect(
            currentFrame.minX - (width - currentFrame.width) / 2,
            currentFrame.minY - (height - currentFrame.height) / 2,
            width,
            height
          )
          self.setFrame(nextFrame, display: true, animate: false)
          result(true)
        } else {
          result(FlutterError.init(code: "bad args", message: nil, details: nil))
        }
      }
      else if call.method == "get bounds" {
        let bounds: NSRect = self.screen!.frame
        result([
          "x": bounds.width,
          "y": bounds.height,
        ])
      }
    })
  }
}
```
</details>

<details>
<summary>main.dart</summary>

```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<void> resize(Size size) async {
    await ResizeApp.platform.invokeMethod<void>(
      'resize',
      <String, dynamic>{
        'width': size.width,
        'height': size.height,
      }
    );
  }

  Future<Size> get bounds async {
    final Map<String, double>? result =
      await ResizeApp.platform.invokeMapMethod('get bounds');

    if ( result == null
      || result['x'] == null
      || result['y'] == null
    ) {
      throw const FormatException('Platform channel "get bounds" gave an invalid argument.');
    }

    return Size(result['x']!, result['y']!);
  }

  @override
  State<ResizeApp> createState() => _ResizeAppState();
}

class _ResizeAppState extends State<ResizeApp> {

  Size? _bounds;

  Future<Size> get bounds async {
    if(_bounds != null) {
      return _bounds!;
    }
    _bounds = await widget.bounds;
    return _bounds!;
  }


  @override
  Widget build(BuildContext context) {


    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: SizedBox(
              height: ResizeApp.constraints.height,
              width: ResizeApp.constraints.width,
              child: FutureBuilder<Size>(
              future: bounds,
              builder: (BuildContext context, AsyncSnapshot<Size> snapshot) {
                  if(!snapshot.hasData) {
                    return const CircularProgressIndicator();
                  }
                  final Size currentSize = MediaQuery.of(context).size;
                  return Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                      Text(
                        key: ResizeApp.widthLabel,
                        'width: ${currentSize.width}'
                      ),
                      Slider(
                        key: ResizeApp.widthSlider,
                        value: currentSize.width,
                        max: snapshot.data!.width,
                        onChanged: (double value) {
                          final Size nextSize = Size(
                            value.clamp(ResizeApp.constraints.width, snapshot.data!.width),
                            currentSize.height,
                          );
                          widget.resize(nextSize);
                        },
                      ),
                      Text(
                       key: ResizeApp.heightLabel,
                        'height: ${currentSize.height}'
                      ),
                      Slider(
                        key: ResizeApp.heightSlider,
                        value: currentSize.height,
                        max: snapshot.data!.height,
                        onChanged: (double value) {
                          print(value);
                          final Size nextSize = Size(
                            currentSize.width,
                            value.clamp(ResizeApp.constraints.height, snapshot.data!.height),
                          );
                          widget.resize(nextSize);
                        },
                      ),
                    ],
                  );
                },
              ),
            ),
        ),
      )
    );
  }
}
```
</details>