work around const lints (#14416)
* work around const lints * update nonconst doc
This commit is contained in:
committed by
GitHub
parent
08823595b0
commit
12ceaefb18
@@ -12,6 +12,7 @@ export 'src/binding.dart';
|
||||
export 'src/controller.dart';
|
||||
export 'src/finders.dart';
|
||||
export 'src/matchers.dart';
|
||||
export 'src/nonconst.dart';
|
||||
export 'src/stack_manipulation.dart';
|
||||
export 'src/test_async_utils.dart';
|
||||
export 'src/test_pointer.dart';
|
||||
|
||||
23
packages/flutter_test/lib/src/nonconst.dart
Normal file
23
packages/flutter_test/lib/src/nonconst.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
/// This function can be used to call a const constructor in such a way as to
|
||||
/// create a new instance rather than creating the common const instance.
|
||||
///
|
||||
/// ```dart
|
||||
/// class A {
|
||||
/// const A(this.i);
|
||||
/// int i;
|
||||
/// }
|
||||
///
|
||||
/// main () {
|
||||
/// // prevent prefer_const_constructors lint
|
||||
/// new A(nonconst(null));
|
||||
///
|
||||
/// // prevent prefer_const_declarations lint
|
||||
/// final int $null = nonconst(null);
|
||||
/// final A a = nonconst(const A(null));
|
||||
/// }
|
||||
/// ```
|
||||
T nonconst<T>(T t) => t;
|
||||
Reference in New Issue
Block a user