title: Test breaks when using Future.delayed
body: <p><a href="https://i.stack.imgur.com/vgMqD.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/vgMqD.gif" alt="Fade in FAB"></a></p>
  
  <p>I have used a <code>Future.delayed</code> to show a FAB in 1 second using this code:</p>
  
  <pre><code>Future.delayed(const Duration(seconds: 1), () {
    setState(() {
      _showFab = true;
    });
  });
  </code></pre>
  
  <p>Now the most basic smoke test has stopped working:</p>
  
  <pre><code>void main() {
    testWidgets('smoke test', (WidgetTester tester) async {
      await tester.pumpWidget(MyApp());
  
      expect(find.byType(MyHomePage), findsOneWidget);
    });
  }
  </code></pre>
  
  <p>This is the error message:</p>
  
  <pre><code>══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
  The following assertion was thrown running a test:
  A Timer is still pending even after the widget tree was disposed.
  'package:flutter_test/src/binding.dart': Failed assertion: line 933 pos 7:
  '_currentFakeAsync.nonPeriodicTimerCount == 0'    import 'dart:async';
  </code></pre>
  
  <p>Here is all the code used:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'dart:async';
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        home: MyHomePage(),
      );
    }
  }
  
  class MyHomePage extends StatefulWidget {
    MyHomePage({Key key}) : super(key: key);
  
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
    bool _showFab = false;
  
    @override
    Widget build(BuildContext context) {
      Future.delayed(const Duration(seconds: 1), () {
        setState(() {
          _showFab = true;
        });
      });
  
      return Scaffold(
        floatingActionButton: AnimatedOpacity(
          opacity: _showFab ? 1.0 : 0.0,
          duration: Duration(milliseconds: 1400),
          child: FloatingActionButton(
            onPressed: null,
            child: Icon(Icons.add),
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>How can I change the unit test to make the test pass?</p>