work around const lints (#14416)

* work around const lints

* update nonconst doc
This commit is contained in:
Alexandre Ardhuin
2018-02-02 08:06:42 +01:00
committed by GitHub
parent 08823595b0
commit 12ceaefb18
15 changed files with 63 additions and 54 deletions

View File

@@ -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';

View 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;