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

Skip to content

Cupertino switch doesn't toggle on pressing Enter key from the physical keyboard #101023

Closed
@woutervanwijk

Description

@woutervanwijk

Steps to Reproduce

1 Create an app with a Switch.adaptive and a (normal) Switch and run it on ios or mac or mac browser
2 Use the keyboard to Tab to the switch
3 The Switch.adaptive will not do anything when using a keyaboard. It will get the focus, but this isn't visible and if you press space or enter, it doesn't react

Expected results:
When you press space or enter, the switch should switch
When it gets the focus it should change color or be marked

Actual results:
Nothing happes. It gets focus, but it's not visible

Code sample
import 'package:flutter/material.dart';

const Color darkBlue = Color.fromARGB(255, 18, 32, 47);

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(
        scaffoldBackgroundColor: darkBlue,
      ),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Center(
          child: MyWidget(),
        ),
      ),
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(children: [
      Switch.adaptive(
        value: true,
        onChanged: (value) {
        },),
      Switch  (
        value: true,
        onChanged: (value) {
        },),
    ]);
      
  }
}
Logs
[✓] Flutter (Channel stable, 2.10.4, on macOS 12.3 21E230 darwin-arm, locale
    nl-NL)
    • Flutter version 2.10.4 at /Users/wouter/Library/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c860cba910 (5 days ago), 2022-03-25 00:23:12 -0500
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/wouter/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_SDK_ROOT = /Users/wouter/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.65.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.36.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.3 21E230 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 99.0.4844.84

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Labels

P0Critical issues such as a build break or regressiona: desktopRunning on desktopf: cupertinoflutter/packages/flutter/cupertino repositoryf: focusFocus traversal, gaining or losing focusfound in release: 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions