我想使用 Dart 2 克隆一个复杂的对象(复制值),而不是引用。
例子:
class Person {
String name;
String surname;
City city;
}
class City {
String name;
String state;
}
main List<String> args {
City c1 = new City()..name = 'Blum'..state = 'SC';
Person p1 = new Person()..name = 'John'..surname = 'Xuebl'..city = c1;
Person p2 = // HERE, to clone/copy values... Something similar to p1.clone();
}
Run Code Online (Sandbox Code Playgroud)
这样做的方法(最佳实践)是什么?
更新说明:这如何在 Dart 中克隆一个对象(深拷贝)?前段时间发的。这里的重点是了解带来许多改进的 Dart 2 是否具有复制复杂对象的功能。
如果需求我设置path为protoc获得进口标准协议缓冲器(protobuf的),像empty.proto和timestamp.proto在Windows和飞镖?
当protoc为然:
protoc --dart_out=grpc:lib/src/protos/generated -Iprotos protos/organization.proto --plugin=protoc-gen-dart=D:\Users\Samuel\AppData\Roaming\Pub\Cache\bin\protoc- gen-dart.bat
出现以下错误:
google/protobuf/empty.proto:找不到文件。organization.proto:未找到导入“google/protobuf/empty.proto”或有错误。organization.proto:14:27: 未定义“google.protobuf.Empty”。
在插件上的IntelliJ 中Settings,定义了标准原型 (*.proto) 的位置:Protobuf Supportpath
此外,这path是在 IntelliJ 中定义的Project Structure\ Global Libraries:
organization.proto导入google/protobuf/empty.proto使用Empty类的代码:
syntax = "proto3";
package auge.protobuf;
import "google/protobuf/empty.proto";
service OrganizationService {
rpc GetOrganizations (google.protobuf.Empty) returns (OrganizationsResponse) {}
}
Run Code Online (Sandbox Code Playgroud)
IntelliJ 分析器识别出IDEA 上的import "google/protobuf/empty.proto"和Empty类,但protoc找不到。
环境是:
我想在Dart语言中使用Tensorflow。
我在Tensorflow文档(https://www.tensorflow.org/api_docs/)中看到Dart没有引用。
是否有为Dart Lang开发Tensorflow API的计划?
我想使用RPC库来开发Dart服务器端Restful.在库存储库中,它带来了两个例子如何使用(https://github.com/dart-lang/rpc-examples/tree/master/bin):Shelf和IO.
我想更好地理解Shelf和IO之间的差异.使用Shelf而不是IO作为Web服务器的优势在哪里?
环境:
我想知道在 VM 的服务器端部署和运行 AngularDart 应用程序需要什么。
在开发过程中正在使用pub run build_runner server. 该应用程序是通过localhost:8080浏览器访问的,它运行良好。
为了准备部署,使用命令生成构建pub run build_runner build -r -o build。文件正在build目录 ok上生成。
正在使用 Google Cloud Compute 创建 VM。
以下是基本疑惑:
build生成的包复制到服务器端的 Web Server 中?不需要额外配置吗?在教程 Angular示例中,它使用 Route 来选择和控制 Angular View 组件。
我知道我们可以使用 *ngIf 指令来选择一个视图。这样,我认为这更具可读性。
请参阅示例:
路线(如教程)
template: '''
<h1>{{title}}</h1>
<nav>
<a [routerLink]="['Dashboard']">Dashboard</a>
<a [routerLink]="['Heroes']">Heroes</a>
</nav>
<router-outlet></router-outlet>
''',
...
@RouteConfig(const [
const Redirect(path: '/', redirectTo: const ['Dashboard']),
const Route(
path: '/dashboard',
name: 'Dashboard',
component: DashboardComponent,
),
const Route(
path: '/detail/:id',
name: 'HeroDetail',
component: HeroDetailComponent,
),
const Route(path: '/heroes', name: 'Heroes', component: HeroesComponent)
])
Run Code Online (Sandbox Code Playgroud)
*ngIf(替代路由)
template: '''
<h1>{{title}}</h1>
<nav>
<button on-click="optionMenu(1)">Dashboard</button>
<button on-click="optionMenu(2)">Heroes</button>
</nav>
<div *ngIf="oMenu == 1">
<my-dashboard></my-dashboard>
</div>
<div *ngIf="oMenu == 2"> …Run Code Online (Sandbox Code Playgroud) 我们有Dart的Angular 2:
https://github.com/angular/material2/blob/master/README.md#the-goal-of-angular-material
Dart的材质设计组件是否也适用于Angular 2?
我正在尝试重现以下App Layout Demo(app_layout_demo)示例:
https://github.com/dart-lang/angular_components_example/tree/master/lib/src/app_layout_demo
这些物品应该出现在抽屉里:
<material-drawer persistent #drawer="drawer" [attr.end]="end ? '' : null">
<material-list *deferredContent>
<div group class="mat-drawer-spacer"></div>
<div group>
<material-list-item>
<material-icon icon="inbox"></material-icon>Inbox
</material-list-item>
<material-list-item>
<material-icon icon="star"></material-icon>Star
</material-list-item>
<material-list-item>
<material-icon icon="send"></material-icon>Sent Mail
</material-list-item>
<material-list-item>
<material-icon icon="drafts"></material-icon>Drafts
</material-list-item>
</div>
<div group>
<div label>Tags</div>
<material-list-item>
<material-icon icon="star"></material-icon>Favorites
</material-list-item>
</div>
</material-list>
</material-drawer>
Run Code Online (Sandbox Code Playgroud)
但它没有在抽屉上显示项目.看到:
浏览器控制台中也存在错误:
EXCEPTION: Invalid argument(s): No provider found for DomService. html_dart2js.dart:3559
Run Code Online (Sandbox Code Playgroud)
可能是什么问题呢?
dart ×8
angular-dart ×4
angular ×2
dart-shelf ×1
dart-webui ×1
grpc ×1
protoc ×1
server-side ×1
tensorflow ×1