probe_agent: widgets of package:material_ui and cupertino_ui get wrong answers for is enabled/disabled, is checked and the tooltip selector (Flutter 3.50)

Open
#852 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
dart, flutter

Research direction

Start with the type checks in probe_agent/lib/src/executor.dart, finder.dart, and device_view.dart, then review the measured cases in test/measure_test.dart. Compare handling of legacy and standalone Material and Cupertino widgets, especially enabled state, checked state, and tooltip lookup. Done means those cases pass for migrated widgets on a device while the existing legacy behavior and obscured-field protection remain correct.

Written by the indexing model from the issue text.

Description

bug

What happens

Flutter 3.50 deprecates package:flutter/material.dart and package:flutter/cupertino.dart in favour of the standalone packages material_ui and cupertino_ui ("Migrate to standalone material_ui and cupertino_ui packages", docs.flutter.dev, page dated 2026-11-09). The agent decides what a widget is by its Dart type, taken from package:flutter/material.dart and package:flutter/cupertino.dart (probe_agent/lib/src/executor.dart, finder.dart, device_view.dart). A widget of material_ui is a different class, so on an app that has migrated, some steps give a wrong answer, one of them a silent false pass.

Measured

A scratch app on Flutter 3.50.0 with material_ui 1.11.1 and cupertino_ui 1.1.7 (what ^1.0.0 resolved to), the agent of main (a path dependency), a widget test that runs the agent's own request handler on a screen of each library's widgets. The control is the same screen built from package:flutter/material.dart. One run, no device.

Step package:flutter/material.dart (control) material_ui / cupertino_ui
see "Submit" (text) and tap "Submit" on an ElevatedButton ok ok
see #go is enabled (enabled button) ok ok
see #off is disabled (button with onPressed: null) ok fails: "#off" is enabled
see #off is enabled (the same disabled button) fails: is disabled passes (false pass)
type "x" into #f and see #f contains "x" on a TextField ok ok
see #cb is checked (Checkbox) and see #sw is checked (Switch) ok fail: "is not a checkable control"
see #cs is checked (CupertinoSwitch) not run fails: "is not a checkable control"
tap "Add item" (an IconButton found by its tooltip) ok fails: Widget not found
type into a CupertinoTextField, contains not run ok
see #pw is filled (obscured TextField) ok ok
see "hunter2" (the value of an obscured field must not be found) not found, as designed not found, as designed
see #f is focused ok ok

So what runs through the widgets library (text, hit testing, EditableText, focus) works, and the obscured-field protection holds (it goes through EditableText). What is decided by a Material or Cupertino class does not: disabled state of buttons, checked state of checkboxes, switches and radios, the tooltip selector.

Not measured

Route handling (a material_ui Scaffold, dialog or bottom sheet: the agent's route code names BottomSheet, CupertinoPageScaffold and others), TextField(enabled: false), chips and list tiles, TextFormField, DropdownButton, the segmented and picker widgets, probe device view and Studio's inspector, and any device (iOS or Android). Whether the standalone packages re-export or wrap the in-framework classes in a way that would let one check cover both was not read in their source.

Why it matters, and what is not known

The in-framework libraries are still in packages/flutter on 3.50 (the page says "formally deprecated" and gives no removal version), so apps that have not migrated are unaffected. An app that migrates and is tested with FlutterProbe gets the answers above, and is enabled on a disabled button passes. The CLI cannot see it.

Not fixed here

This is a report with a measurement (the RELEASES log gets a note). A fix has to recognise both families of classes (by importing material_ui and cupertino_ui, which raises the Flutter floor of the agent to 3.47, by class name, or by another test of the widget) and has to be tested on a device with a migrated fixture; the choice is open.

The measurement test (scratch, test/measure_test.dart of an app that depends on material_ui, cupertino_ui and the agent)
import 'dart:convert';

import 'package:cupertino_ui/cupertino_ui.dart' as cui;
import 'package:flutter/material.dart' as fm; // the legacy in-framework library: the control
import 'package:flutter/widgets.dart';
import 'package:flutter_probe_agent/src/executor.dart';
import 'package:flutter_probe_agent/src/protocol.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:material_ui/material_ui.dart' as mu;

// What the agent does on widgets from package:material_ui / cupertino_ui compared with the same widgets from package:flutter/material.dart.
// Each case prints one line: "<library> | <step> | ok" or the error message.
final results = <String>[];

Future<String> run(ProbeExecutor ex, List<String> sent, String method, Map<String, dynamic> params) async {
  sent.clear();
  await ex.dispatch(ProbeRequest(jsonrpc: '2.0', id: 1, method: method, params: params));
  final m = jsonDecode(sent.last) as Map<String, dynamic>;
  return m.containsKey('error') ? ((m['error'] as Map)['message'] as String).split('\n').first : 'ok';
}

Map<String, dynamic> byText(String t, {String check = '', bool negated = false}) => {
      'selector': {'kind': 'text', 'text': t},
      if (check.isNotEmpty) 'check': check,
      'negated': negated,
    };
Map<String, dynamic> byId(String id, {String check = '', bool negated = false}) => {
      'selector': {'kind': 'id', 'text': '#$id'},
      if (check.isNotEmpty) 'check': check,
      'negated': negated,
    };

Widget muApp(Widget body) => mu.MaterialApp(home: mu.Scaffold(body: body));
Widget fmApp(Widget body) => fm.MaterialApp(home: fm.Scaffold(body: body));

void main() {
  for (final lib in ['flutter/material', 'material_ui']) {
    final isMu = lib == 'material_ui';
    testWidgets('measure $lib', (tester) async {
      final sent = <String>[];
      final ex = ProbeExecutor((m) => sent.add(m));
      bool checked = true;
      bool sw = true;
      final pw = TextEditingController(text: 'hunter2-SECRET');
      final field = TextEditingController();
      final body = Column(children: [
        isMu ? mu.ElevatedButton(key: const ValueKey('go'), onPressed: () {}, child: const Text('Submit')) : fm.ElevatedButton(key: const ValueKey('go'), onPressed: () {}, child: const Text('Submit')),
        isMu ? const mu.ElevatedButton(key: ValueKey('off'), onPressed: null, child: Text('Disabled one')) : const fm.ElevatedButton(key: ValueKey('off'), onPressed: null, child: Text('Disabled one')),
        isMu ? mu.TextField(key: const ValueKey('f'), controller: field) : fm.TextField(key: const ValueKey('f'), controller: field),
        isMu ? mu.TextField(key: const ValueKey('pw'), obscureText: true, controller: pw) : fm.TextField(key: const ValueKey('pw'), obscureText: true, controller: pw),
        isMu ? mu.Checkbox(key: const ValueKey('cb'), value: checked, onChanged: (v) {}) : fm.Checkbox(key: const ValueKey('cb'), value: checked, onChanged: (v) {}),
        isMu ? mu.Switch(key: const ValueKey('sw'), value: sw, onChanged: (v) {}) : fm.Switch(key: const ValueKey('sw'), value: sw, onChanged: (v) {}),
        isMu ? mu.IconButton(key: const ValueKey('ib'), tooltip: 'Add item', icon: const Icon(IconData(0xe047)), onPressed: () {}) : fm.IconButton(key: const ValueKey('ib'), tooltip: 'Add item', icon: const Icon(IconData(0xe047)), onPressed: () {}),
      ]);
      await tester.pumpWidget(isMu ? muApp(body) : fmApp(body));
      await tester.pumpAndSettle();
      Future<void> rec(String step, String method, Map<String, dynamic> p) async => results.add('$lib | $step | ${await run(ex, sent, method, p)}');
      await rec('see "Submit"', ProbeMethods.see, byText('Submit'));
      await rec('tap "Submit"', ProbeMethods.tap, byText('Submit'));
      await rec('see #go is enabled', ProbeMethods.see, byId('go', check: 'enabled'));
      await rec('see #off is disabled', ProbeMethods.see, byId('off', check: 'disabled'));
      await rec('see #off is enabled (should fail)', ProbeMethods.see, byId('off', check: 'enabled'));
      await rec('type "x" into #f', ProbeMethods.type_, {'selector': {'kind': 'id', 'text': '#f'}, 'text': 'x'});
      await rec('see #f contains "x"', ProbeMethods.see, {...byId('f', check: 'contains'), 'check_val': 'x'});
      await rec('see #cb is checked', ProbeMethods.see, byId('cb', check: 'checked'));
      await rec('see #sw is checked', ProbeMethods.see, byId('sw', check: 'checked'));
      await rec('tap "Add item" (tooltip)', ProbeMethods.tap, byText('Add item'));
      await rec('see #pw is filled', ProbeMethods.see, byId('pw', check: 'filled'));
      await rec('see "hunter2" (must NOT find the password)', ProbeMethods.see, byText('hunter2'));
      await rec('see #f is focused', ProbeMethods.see, byId('f', check: 'focused'));
    });
  }
  testWidgets('cupertino_ui', (tester) async {
    final sent = <String>[];
    final ex = ProbeExecutor((m) => sent.add(m));
    await tester.pumpWidget(mu.MaterialApp(home: mu.Scaffold(body: Column(children: [
      cui.CupertinoTextField(key: const ValueKey('ct'), placeholder: 'Type here'),
      cui.CupertinoSwitch(key: const ValueKey('cs'), value: true, onChanged: (v) {}),
    ]))));
    await tester.pumpAndSettle();
    results.add('cupertino_ui | type "x" into #ct | ${await run(ex, sent, ProbeMethods.type_, {'selector': {'kind': 'id', 'text': '#ct'}, 'text': 'x'})}');
    results.add('cupertino_ui | see #ct contains "x" | ${await run(ex, sent, ProbeMethods.see, {...byId('ct', check: 'contains'), 'check_val': 'x'})}');
    results.add('cupertino_ui | see #cs is checked | ${await run(ex, sent, ProbeMethods.see, byId('cs', check: 'checked'))}');
  });
  tearDownAll(() {
    // ignore: avoid_print
    print('\n=== RESULTS ===\n${results.join('\n')}\n=== END ===');
  });
}
Dominant language
Go
Stars
6
Forks
3
Avg merge
6h 28m
Merged PRs (30d)
362

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AlphaWaveSystems/flutter-probe

All issues in AlphaWaveSystems/flutter-probe

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.