Skip to content

CupertinoSlidingSegmentedControl causes rendering issues on Android #174100

@Limatationz

Description

@Limatationz

Steps to reproduce

Using CupertinoSlidingSegmentedControl in an MaterialApp causes rendering issues.
If you run the sample code on an Android Device (this one was an emulator using api 35) and changing the slider you can see smaller issues. When pushing a new route that includes a CupertinoSlidingSegmentedControl (with the + button of the sample) it leads to major rendering issues.
The sample is working fine with flutter 3.32.8.
On IOS the sample is working with flutter 3.35.1. Seems like this is an Android only problem.

Expected results

UI should render correctly.

Actual results

Rendering issues when using the CupertinoSlidingSegmentedControl on Android.

Code sample

Code sample
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(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const TestView(),
    );
  }
}

class TestView extends StatefulWidget {
  const TestView({super.key});

  @override
  State<TestView> createState() => _TestViewState();
}

class _TestViewState extends State<TestView> {
  int selectedSegment = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Test View"),
        actions: [
          IconButton(
            onPressed: () {
              Navigator.of(
                context,
              ).push(MaterialPageRoute(builder: (_) => TestView()));
            },
            icon: Icon(Icons.add),
          ),
        ],
      ),
      body: Padding(
        padding: EdgeInsets.zero,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            CupertinoSlidingSegmentedControl<int>(
              children: {
                0: Text(
                  'site 1',
                  style: Theme.of(context).textTheme.bodyMedium,
                ),
                1: Text(
                  'site 2',
                  style: Theme.of(context).textTheme.bodyMedium,
                ),
              },
              onValueChanged: (selected) {
                setState(() {
                  selectedSegment = selected ?? 0;
                });
              },
              backgroundColor: Colors.grey.withValues(alpha: 0.3),
              // Set the background color,
              thumbColor: Colors.white,
              groupValue: selectedSegment,
            ),
            const SizedBox(height: 12),
            Expanded(
              child: (selectedSegment == 0) ? _testView() : _testView2(),
            ),
          ],
        ),
      ),
    );
  }

  Widget _testView() {
    return ListView(
      children: List.generate(
        100,
        (index) => ListTile(title: Text("Site 1. Index $index")),
      ),
    );
  }

  Widget _testView2() {
    return ListView(
      children: List.generate(
        50,
        (index) => ListTile(title: Text("Site 2. Index $index")),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
3.32.8 3.35.1
Image Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
flutter doctor --verbose
[✓] Flutter (Channel stable, 3.35.1, on macOS 15.6 24G84 darwin-arm64, locale de-DE) [407ms]
    • Flutter version 3.35.1 on channel stable at /Volumes/ExternErik/fvm_versions/3.35.1
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 20f8274939 (6 days ago), 2025-08-14 10:53:09 -0700
    • Engine revision 1e9a811bf8
    • Dart version 3.9.0
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-swift-package-manager, enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [1.487ms]
    • Android SDK at /Users/erik/Library/Android/sdk
    • Emulator version 35.6.11.0 (build_id 13610412) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • Java binary at: /Users/erik/.sdkman/candidates/java/current/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment Temurin-21.0.7+6 (build 21.0.7+6-LTS)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [1.611ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16F6
    • CocoaPods version 1.16.2

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

[✓] Android Studio (version 2025.1) [7ms]
    • Android Studio at /Users/erik/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 21.0.6+-13391695-b895.109)

[✓] VS Code (version 1.103.0) [5ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.116.0

[✓] Connected device (6 available) [6,3s]
    • sdk gphone16k arm64 (mobile) • emulator-5554                            • android-arm64  • Android 15 (API 35) (emulator)
    • macOS (desktop)              • macos                                    • darwin-arm64   • macOS 15.6 24G84 darwin-arm64
    • Chrome (web)                 • chrome                                   • web-javascript • Google Chrome 139.0.7258.128
    ! Error: Browsing on the local area network for Test Watch. Ensure the device is unlocked and discoverable via Bluetooth. (code -27)

[✓] Network resources [291ms]
    • All expected network resources are available.

• No issues found!
Process finished with exit code 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: regressionIt was better in the past than it is nowe: impellerImpeller rendering backend issues and features requestsengineflutter/engine repository. See also e: labels.f: cupertinoflutter/packages/flutter/cupertino repositoryfound in release: 3.33Found to occur in 3.33found in release: 3.35Found to occur in 3.35frameworkflutter/packages/flutter repository. See also f: labels.fyi-designFor the attention of Design Languages teamhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyteam-engineOwned by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions