-
Notifications
You must be signed in to change notification settings - Fork 0
Dummies
Efra Espada edited this page Oct 6, 2024
·
6 revisions
Dummies are dart classes that provide the dummy content of your sample (or samples). For working with dummies, @Preview annotations require an extra configuration.
your_widget_folder
|
|-- preview
| |
| |-- dummy
| | |
| | |-- gs_image.dummy.dart <-- dummy created (only created if not exist)
| |
| |-- gs_image.preview.dart <-- preview created (always regenerated)
|
|--gs_image.dart <-- widget file
Notice the suffix
previewis defined inpubspec.yaml
dart run catalog:preview
After running the preview command, a dummy file is generated if it does not exist.
gs_image.dummy.dart
/// AUTOGENERATED FILE.
///
/// Use this file for modify the preview of GsImagePreview
///
import 'package:catalog/catalog.dart';
class GsImageDummy extends PreviewDummy {
@override
List<Dummy> get dummies => [];
}
Every Dummy element you include in the dummies variable is displayed as a different sample of your widget preview.
gs_image.dummy.dart
/// AUTOGENERATED FILE.
///
/// Use this file for modify the preview of GsImagePreview
///
import 'package:catalog/catalog.dart';
import 'package:landa/data/model/profile.dart';
class GsImageDummy extends PreviewDummy {
@override
List<Dummy> get dummies => [
Dummy(
parameters: {
'profile': Profile().fromJson(
{
'id': '1107d2a893dd295e57f',
'name': 'Efra Espada',
'username': 'efraespada',
},
),
'size': 150,
'height': 150,
'width': 150.0,
'elevation': 2.0,
},
),
];
}