Download flutter/packages/flutter_test/lib/src/nonconst.dart from luom2645/agent-workspace: direct link, hf CLI and curl.
- Browser
- Download file 667 Bytes
-
https://huggingface.co/luom2645/agent-workspace/resolve/main/flutter/packages/flutter_test/lib/src/nonconst.dart
- Command line
-
hf download hf://luom2645/agent-workspace/flutter/packages/flutter_test/lib/src/nonconst.dart
-
curl -L -o nonconst.dart https://huggingface.co/luom2645/agent-workspace/resolve/main/flutter/packages/flutter_test/lib/src/nonconst.dart
667 Bytes
| // Copyright 2014 The Flutter 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); | |
| /// final int? i; | |
| /// } | |
| /// | |
| /// void main () { | |
| /// // prevent prefer_const_constructors lint | |
| /// 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; | |