Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

DisplayFeatureSubScreen.subScreensInBounds depends on the order of displayFeatures and can return a sub-screen that spans a fold

Abierto Apto para principiantes
#195,216 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
79/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
dart, flutter
Área
frontend, mobile

Línea de trabajo

Empieza con packages/flutter/lib/src/widgets/display_feature_sub_screen.dart y sigue cómo subScreensInBounds divide las subpantallas actuales para las características de pantalla verticales y horizontales. Añade una prueba de widget basada en la reproducción que compruebe ambos órdenes de las características. Se considerará terminado cuando las subpantallas resultantes y la ubicación del diálogo sean independientes del orden y ninguna cruce el pliegue.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Steps to reproduce

DisplayFeatureSubScreen.subScreensInBounds gives different sub-screens for the same display features depending on their order in MediaQuery.displayFeatures. With a fold in the middle and a second full-height feature at one edge (here a cutout band on the right, as on a foldable with a side system area), the order [fold, band] produces a sub-screen that spans the fold, so a dialog lands across the crease. The order [band, fold] gives the expected halves.

Run this widget test (Flutter 3.47.7 stable, Dart 3.13.5):

import 'dart:ui' show DisplayFeature, DisplayFeatureState, DisplayFeatureType;

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

const _band = DisplayFeature(
  bounds: Rect.fromLTRB(867, 0, 951, 669),
  type: DisplayFeatureType.cutout,
  state: DisplayFeatureState.unknown,
);
const _fold = DisplayFeature(
  bounds: Rect.fromLTRB(455.5, 0, 495.5, 669),
  type: DisplayFeatureType.fold,
  state: DisplayFeatureState.postureHalfOpened,
);

Future<Rect> _dialogRect(WidgetTester tester, List<DisplayFeature> features) async {
  tester.view.physicalSize = const Size(951, 669);
  tester.view.devicePixelRatio = 1;
  addTearDown(tester.view.reset);
  late BuildContext ctx;
  await tester.pumpWidget(MaterialApp(
    builder: (context, child) => MediaQuery(
      data: MediaQuery.of(context).copyWith(displayFeatures: features),
      child: child!,
    ),
    home: Builder(builder: (inner) { ctx = inner; return const SizedBox.expand(); }),
  ));
  showDialog<void>(
    context: ctx,
    anchorPoint: const Offset(951, 0),
    builder: (_) => const Center(child: SizedBox(key: ValueKey('d'), width: 300, height: 100)),
  );
  await tester.pumpAndSettle();
  return tester.getRect(find.byKey(const ValueKey('d')));
}

bool _crossesFold(Rect r) => r.left < _fold.bounds.right && r.right > _fold.bounds.left;

void main() {
  testWidgets('[band, fold]', (tester) async {
    final r = await _dialogRect(tester, const [_band, _fold]);
    expect(_crossesFold(r), isFalse); // passes: Rect.fromLTRB(531.3, 284.5, 831.3, 384.5)
  });
  testWidgets('[fold, band]', (tester) async {
    final r = await _dialogRect(tester, const [_fold, _band]);
    expect(_crossesFold(r), isFalse); // fails: Rect.fromLTRB(283.5, 284.5, 583.5, 384.5)
  });
}
Expected results

The sub-screens, and so the dialog's position, do not depend on the order of displayFeatures. In both cases the dialog anchored at the top-right lands in the right half, between the fold (495.5) and the band (867), as it does for [band, fold].

Actual results

With [fold, band] the dialog is centred in a sub-screen 0…867 and straddles the fold (283.5…583.5 against a fold at 455.5…495.5).

subScreensInBounds (packages/flutter/lib/src/widgets/display_feature_sub_screen.dart) splits every current sub-screen by each full-height feature without checking that the feature intersects that sub-screen, and it builds the left piece as bounds.left - screen.left without clamping to screen.right. Tracing [fold, band]:

  1. The fold splits 0…951 into 0…455.5 and 495.5…951.
  2. The band (867…951) does not intersect 0…455.5, but the vertical branch still runs: screen.left < bounds.left adds Rect.fromLTWH(0, 0, 867 - 0, …), a sub-screen 0…867 that reaches back across the fold. The second piece becomes 495.5…867.

The anchor then picks 0…867.

Suggested fix: skip a feature that does not overlap the current sub-screen (keep the sub-screen as is), or clamp the pieces to the sub-screen (min(bounds.left, screen.right) for the left piece's right edge, max(bounds.right, screen.left) for the right piece's left edge). The same applies to the horizontal branch.

Context

This shows up when an app projects more than one full-height feature, for example a fold plus a side system area on a foldable such as the iPhone Duo. We work around it by always listing the edge band before the fold.

Flutter Doctor output

Flutter 3.47.7 (stable, revision abaf9c5237), Dart 3.13.5, macOS 26.7.1. Reproduces in flutter test with no device.

Lenguaje dominante
Dart
Estrellas
180k
Forks
33.9k
Merge medio
2 d 5 h
PR fusionados (30 d)
306

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de flutter/flutter

Todos los issues de flutter/flutter

Issues similares

Más issues de Dart

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.