-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up macro examples and README.md, remove run.dart script (#3582)
- Delete run.dart script and update the README.md to indicate you can just pass `--enable-experiment=macros`. - Break up `user_main.dart` into separate scripts for each macro example, which allows you to run the ones that do work, and also keeps the example apps more targetted. These were only combined into one previously to make it easier to run them through `run.dart`. - Update the observable example so it is runnable. - Update the data class example to create the unnamed constructor instead of one called `gen`.
- Loading branch information
Showing
11 changed files
with
100 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:macro_proposal/auto_dispose.dart'; | ||
|
||
void main() { | ||
var state = MyState(a: ADisposable(), b: BDisposable(), c: 'hello world'); | ||
state.dispose(); | ||
} | ||
|
||
@AutoDispose() | ||
class MyState extends State { | ||
final ADisposable a; | ||
final ADisposable? a2; | ||
final BDisposable b; | ||
final String c; | ||
|
||
MyState({required this.a, this.a2, required this.b, required this.c}); | ||
|
||
@override | ||
String toString() => 'MyState!'; | ||
} | ||
|
||
class State { | ||
void dispose() { | ||
print('disposing of $this'); | ||
} | ||
} | ||
|
||
class ADisposable implements Disposable { | ||
void dispose() { | ||
print('disposing of ADisposable'); | ||
} | ||
} | ||
|
||
class BDisposable implements Disposable { | ||
void dispose() { | ||
print('disposing of BDisposable'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:macro_proposal/data_class.dart'; | ||
|
||
void main() { | ||
var joe = User(age: 25, name: 'Joe', username: 'joe1234'); | ||
print(joe); | ||
|
||
var phoenix = joe.copyWith(name: 'Phoenix', age: 23); | ||
print(phoenix); | ||
} | ||
|
||
@DataClass() | ||
class User { | ||
final int age; | ||
final String name; | ||
final String username; | ||
} | ||
|
||
@DataClass() | ||
class Manager extends User { | ||
final List<User> reports; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.