• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5/// This function can be used to call a const constructor in such a way as to
6/// create a new instance rather than creating the common const instance.
7///
8/// ```dart
9/// class A {
10///   const A(this.i);
11///   int i;
12/// }
13///
14/// main () {
15///   // prevent prefer_const_constructors lint
16///   new A(nonconst(null));
17///
18///   // prevent prefer_const_declarations lint
19///   final int $null = nonconst(null);
20///   final A a = nonconst(const A(null));
21/// }
22/// ```
23T nonconst<T>(T t) => t;
24