bottom_sheet_rebuild_test.dart 1.11 KB
Newer Older
1 2 3 4 5 6 7 8
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

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

void main() {
9
  testWidgets('Verify that a BottomSheet can be rebuilt with ScaffoldFeatureController.setState()', (WidgetTester tester) async {
10 11 12
    final GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
    PersistentBottomSheetController<Null> bottomSheet;
    int buildCount = 0;
13

14
    await tester.pumpWidget(new MaterialApp(
15 16 17 18 19
      home: new Scaffold(
        key: scaffoldKey,
        body: new Center(child: new Text('body'))
      )
    ));
20

21 22 23 24 25 26 27 28
    bottomSheet = scaffoldKey.currentState.showBottomSheet/*<Null>*/((_) {
      return new Builder(
        builder: (BuildContext context) {
          buildCount += 1;
          return new Container(height: 200.0);
        }
      );
    });
29

30
    await tester.pump();
31
    expect(buildCount, equals(1));
32

33
    bottomSheet.setState((){ });
34
    await tester.pump();
35
    expect(buildCount, equals(2));
36 37 38
  });

}