Repository: flutter
Issue: WidgetTester finds text even when it is not visible on screen
Labels: a: tests,framework,f: material design,has reproducible steps,P2,found in release: 2.2,team-framework,triaged-framework

## Issue

Finders run in WidgetTester find elements even when they are not rendered.

As an example, this happens with the ExpansionPanel widget. If isExpanded is false, the body of ExpansionPanel is not rendered. WidgetTester can't tell, and finds the test.

## Steps to Reproduce

1. Run `flutter create bug`.
2. Update the files as follows:

Replace lib/main.dart with this code:
```
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Expansion Panel Demo'),
      ),
      body: SingleChildScrollView(
        child: ExpansionPanelList(
          children: [
            _closedPanel(),
            _openPanel(),
          ]
        ),
      ),
    );
  }

  ExpansionPanel _closedPanel() {
    return ExpansionPanel(
      headerBuilder: (context, isExpanded) => Text('Closed Panel'),
      body: Text('Hidden Body'),
      isExpanded: false,
    );
  }

  ExpansionPanel _openPanel() {
    return ExpansionPanel(
      headerBuilder: (context, isExpanded) => Text('Open Panel'),
      body: Text('Visible Body'),
      isExpanded: true,
    );
  }
}
```

Replace test/widget_test.dart with this code:
```
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:bug/main.dart';

void main() {
  testWidgets('Expansion panel body not visible', (WidgetTester tester) async {
    await tester.pumpWidget(MyApp());
    expect(find.text('Visible Body'), findsOneWidget);
    expect(find.text('Hidden Body'), findsNothing);
  });
}
```

3. Run `flutter test`

**Expected results:** 

 The test expectation `expect(find.text('Hidden Body'), findsNothing)` should pass


**Actual results:** 

 The test expectation `expect(find.text('Hidden Body'), findsNothing)` fails. The test thinks the Hidden Body widget is rendered.


<details>
  <summary>Logs</summary>
```
$ flutter test
00:04 +0: Expansion panel body not visible                                     
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
  Expected: no matching nodes in the widget tree
  Actual: _TextFinder:<exactly one widget with text "Hidden Body" (ignoring offstage widgets):
Text("Hidden Body", dependencies: [DefaultTextStyle, MediaQuery])>
   Which: means one was found but none were expected

When the exception was thrown, this was the stack:
#4      main.<anonymous closure> (file:///Users/brian/sb/widget_tester/bug/test/widget_test.dart:10:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)
...

This was caught by the test expectation on the following line:
  file:///Users/brian/sb/widget_tester/bug/test/widget_test.dart line 10
The test description was:
  Expansion panel body not visible
════════════════════════════════════════════════════════════════════════════════════════════════════
00:04 +0 -1: Expansion panel body not visible [E]                              
  Test failed. See exception logs above.
  The test description was: Expansion panel body not visible
  
00:04 +0 -1: Some tests failed.                                                
```

</details>