// Copyright 2018 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/widgets.dart';classBadWidgetextendsStatefulWidget{@overrideState<StatefulWidget>createState()=>newBadWidgetState();}classBadWidgetStateextendsState<BadWidget>{BadWidgetState(){setState((){_count=1;});}int_count=0;@overrideWidgetbuild(BuildContextcontext){returnnewText(_count.toString());}}voidmain(){testWidgets('setState() catches being used inside a constructor',(WidgetTestertester)async{awaittester.pumpWidget(newBadWidget());expect(tester.takeException(),constisInstanceOf<FlutterError>());});}