Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Highlighting remains visible after changes to Slider and DropdownButton widgets #122901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Mar 17, 2023 · 6 comments
Closed
Labels
r: invalid Issue is closed as not valid

Comments

@ghost
Copy link

ghost commented Mar 17, 2023

The highlighting around the slider tick remains visible after the change to the widget completes, same goes for highlighting on dropdown items. The issue was found on a linux desktop app but can be reproduced in dart pad, see code below.

Screenshot from 2023-03-17 10-02-03
Screenshot from 2023-03-17 10-02-07
Screenshot from 2023-03-17 10-02-14
Screenshot from 2023-03-17 10-02-19
Screenshot from 2023-03-17 10-02-23
Screenshot from 2023-03-17 10-02-28
Screenshot from 2023-03-17 10-02-35

// Copyright (c) 2019, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final String title;

  const MyHomePage({
    Key? key,
    required this.title,
  }) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  double sliderValue = 0;
  String dropdownValue = 'a';

  List<DropdownMenuItem> getItems() {
    List<DropdownMenuItem> items = [];
    for (String label in ['a', 'b', 'c']) {
      items.add(
        DropdownMenuItem(
          value: label,
          child: Text(label),
        ),
      );
    }
    return items;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            DropdownButton(
                value: dropdownValue,
                items: getItems(),
                onChanged: (value) {
                  setState(() {
                    dropdownValue = value;
                  });
                }),
            Slider(
              value: sliderValue,
              min: 0,
              max: 10,
              onChanged: (value) {
                setState(() {
                  sliderValue = value;
                });
              },
            ),
          ],
        ),
      ),
    );
  }
}
@jason-simmons
Copy link
Member

This behavior was implemented based on the Material 3 specification (see #113543)

@himanshu21072002
Copy link

Hi,
My name is Himanshu Gangwar, I have been working with flutter for more than one and a half year.
I want to solve this issue so can you please assign this issue to me.

@exaby73 exaby73 added the in triage Presently being triaged by the triage team label Mar 20, 2023
@exaby73
Copy link
Member

exaby73 commented Mar 20, 2023

This seems to be working as expected based on #113543. Closing for the same reason

@exaby73 exaby73 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 20, 2023
@exaby73 exaby73 added r: invalid Issue is closed as not valid and removed in triage Presently being triaged by the triage team labels Mar 20, 2023
@ghost
Copy link
Author

ghost commented Mar 20, 2023

According to the material component demo https://material-components.github.io/material-web/demos/slider/ clicking or tapping anywhere on the screen should clear the highlighting, this is not the current behavior.

@exaby73
Copy link
Member

exaby73 commented Mar 21, 2023

This is because the Slider has focus. You can achieve this by wrapping your Scaffold in a GestureDetector and onTap call FocusScope.of(context).unfocus() to unfocus any widget on the screen

@github-actions
Copy link

github-actions bot commented Apr 4, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
r: invalid Issue is closed as not valid
Projects
None yet
Development

No branches or pull requests

3 participants