You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter 3.7中Windows桌面端CupertinoPicker存在选项无法选中问题

Flutter 3.7 Windows桌面端CupertinoPicker部分选项无法选中问题

升级至Flutter 3.7版本后,在Windows桌面环境下使用CupertinoPicker组件时,会出现部分选项无法被选中的异常问题。

以下是可复现该问题的Dart代码:

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

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

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {

  int _index = 0;

  List<String> team = <String>["Olaf","Victor","Rita"] ;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: CupertinoPicker(
            itemExtent: 50,
            onSelectedItemChanged: (selectedIndex) {
              _index = selectedIndex;
            },
            children: List.generate(team.length, (index) {
              return Text(team[index]);
            }),
        ),
      ),
    );
  }
}

该问题已在Flutter官方GitHub仓库提交相关Issue。

内容的提问来源于stack exchange,提问作者deczaloth

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 22:55:56