Skip to content

Format code #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 26 additions & 30 deletions bin/generate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,12 @@ class DiagramGenerator {
filters.add(temporaryDirectory.absolute.path);
late final List<String> filterArgs;
if (deviceTargetPlatform.startsWith('android')) {
filterArgs =
filters.isNotEmpty
? <String>[
'--route',
'args:${Uri.encodeComponent(filters.join(' '))}',
]
: <String>[];
filterArgs = filters.isNotEmpty
? <String>[
'--route',
'args:${Uri.encodeComponent(filters.join(' '))}',
]
: <String>[];
} else {
filterArgs = <String>[];
for (final String arg in filters) {
Expand Down Expand Up @@ -205,8 +204,8 @@ class DiagramGenerator {
) ||
(entry['id'] as String) == device) {
deviceId = entry['id'] as String;
deviceTargetPlatform =
(entry['targetPlatform'] as String).toLowerCase();
deviceTargetPlatform = (entry['targetPlatform'] as String)
.toLowerCase();
return true;
}
}
Expand Down Expand Up @@ -420,10 +419,9 @@ class DiagramGenerator {
}

Future<List<File>> _combineAnimations(List<File> inputFiles) async {
final List<File> errorFiles =
inputFiles
.where((File input) => path.basename(input.path) == 'error.log')
.toList();
final List<File> errorFiles = inputFiles
.where((File input) => path.basename(input.path) == 'error.log')
.toList();

if (errorFiles.length != 1) {
throw GeneratorException('Subprocess did not complete cleanly!');
Expand All @@ -442,10 +440,9 @@ class DiagramGenerator {
throw GeneratorException('Failed with errors (see $errorsFileName).');
}

final List<File> metadataFiles =
inputFiles
.where((File input) => path.extension(input.path) == '.json')
.toList();
final List<File> metadataFiles = inputFiles
.where((File input) => path.extension(input.path) == '.json')
.toList();

// Collect all the animation frames that are in the metadata files so that
// we can eliminate them from the other files that were transferred.
Expand All @@ -468,19 +465,18 @@ class DiagramGenerator {
metadata.frameFiles.map((File file) => file.absolute.path),
);
}
final List<File> staticFiles =
inputFiles.where((File input) {
if (!input.isAbsolute) {
input = File(
path.normalize(
path.join(temporaryDirectory.absolute.path, input.path),
),
);
} else {
input = File(path.normalize(input.path));
}
return !animationFiles.contains(input.absolute.path);
}).toList();
final List<File> staticFiles = inputFiles.where((File input) {
if (!input.isAbsolute) {
input = File(
path.normalize(
path.join(temporaryDirectory.absolute.path, input.path),
),
);
} else {
input = File(path.normalize(input.path));
}
return !animationFiles.contains(input.absolute.path);
}).toList();
final List<File> convertedFiles = await _buildMoviesFromMetadata(
metadataList,
);
Expand Down
4 changes: 3 additions & 1 deletion bin/test/generate_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ void main() {
'packages',
'diagram_generator',
),
): <ProcessResult>[ProcessResult(0, 0, '', '')],
): <ProcessResult>[
ProcessResult(0, 0, '', ''),
],
FakeInvocationRecord(<String>[
'optipng',
'-zc1-9',
Expand Down
20 changes: 10 additions & 10 deletions packages/animation_metadata/lib/animation_metadata.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ class AnimationMetadata {
final Map<String, Object?> metadata =
json.decode(metadataFile.readAsStringSync()) as Map<String, dynamic>;
final String baseDir = path.dirname(metadataFile.absolute.path);
final List<File> frameFiles =
(metadata[_frameFilesKey]! as List<dynamic>).map<File>((dynamic name) {
final List<File> frameFiles = (metadata[_frameFilesKey]! as List<dynamic>)
.map<File>((dynamic name) {
return File(path.normalize(path.join(baseDir, name.toString())));
}).toList();
})
.toList();
final Duration duration = Duration(
milliseconds: metadata[_durationMsKey]! as int,
);
Expand Down Expand Up @@ -66,13 +67,12 @@ class AnimationMetadata {
_videoFormatKey: videoFormat.name,
_frameRateKey: frameRate,
_widthKey: width,
_frameFilesKey:
frameFiles.map<String>((File file) {
return path.relative(
file.path,
from: path.dirname(metadataFile.absolute.path),
);
}).toList(),
_frameFilesKey: frameFiles.map<String>((File file) {
return path.relative(
file.path,
from: path.dirname(metadataFile.absolute.path),
);
}).toList(),
};
const JsonEncoder encoder = JsonEncoder.withIndent(' ');
final String jsonMetadata = encoder.convert(metadata);
Expand Down
5 changes: 3 additions & 2 deletions packages/diagram_capture/lib/diagram_capture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,9 @@ class DiagramController {
milliseconds: 1000 ~/ framerate,
);
while (timestamp != Duration.zero) {
final Duration advanceBy =
timestamp > framerateDuration ? framerateDuration : timestamp;
final Duration advanceBy = timestamp > framerateDuration
? framerateDuration
: timestamp;
timestamp -= advanceBy;
await advanceTime(advanceBy);
}
Expand Down
13 changes: 7 additions & 6 deletions packages/diagram_capture/test/diagram_capture_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ void main() {
screenDimensions: const Size(100.0, 100.0),
);

controller.builder =
(BuildContext context) => TestAnimatedDiagram(key: key, size: 50.0);
controller.builder = (BuildContext context) =>
TestAnimatedDiagram(key: key, size: 50.0);
final List<ui.Image> outputImages = await controller
.drawAnimatedDiagramToImages(
end: const Duration(milliseconds: 1200),
Expand All @@ -115,8 +115,8 @@ void main() {
screenDimensions: const Size(100.0, 100.0),
);

controller.builder =
(BuildContext context) => TestAnimatedDiagram(key: key, size: 50.0);
controller.builder = (BuildContext context) =>
TestAnimatedDiagram(key: key, size: 50.0);
final File outputFile = await controller.drawAnimatedDiagramToFiles(
end: const Duration(milliseconds: 1200),
frameRate: 5.0,
Expand Down Expand Up @@ -177,8 +177,9 @@ void main() {
expect(decodedImage.width, equals(300));
expect(decodedImage.height, equals(150));
expect(decodedImage.length, equals(45000));
final image.Pixel testPixel =
decodedImage.getRange(150, 20, 1, 1).current;
final image.Pixel testPixel = decodedImage
.getRange(150, 20, 1, 1)
.current;
expect(testPixel.a, equals(0xfe));
expect(testPixel.r, equals(0xed));
expect(testPixel.g, equals(0xbe));
Expand Down
43 changes: 21 additions & 22 deletions packages/diagram_generator/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ Future<void> main(List<String> args) async {
DiagramFlutterBinding.ensureInitialized();
late final List<String> arguments;
if (platform.isAndroid) {
arguments =
PlatformDispatcher.instance.defaultRouteName.length > 5
? Uri.decodeComponent(
PlatformDispatcher.instance.defaultRouteName.substring(5),
).split(' ')
: <String>[];
arguments = PlatformDispatcher.instance.defaultRouteName.length > 5
? Uri.decodeComponent(
PlatformDispatcher.instance.defaultRouteName.substring(5),
).split(' ')
: <String>[];
} else {
arguments = args;
}
Expand All @@ -72,16 +71,15 @@ Future<void> main(List<String> args) async {
final List<String> categories = flags['category'] as List<String>;
final List<String> names = flags['name'] as List<String>;
final List<String> steps = flags['step'] as List<String>;
final Set<DiagramPlatform> platforms =
(flags['platform'] as List<String>).map<DiagramPlatform>((
String platformStr,
) {
final Set<DiagramPlatform> platforms = (flags['platform'] as List<String>)
.map<DiagramPlatform>((String platformStr) {
assert(
diagramStepPlatformNames.containsKey(platformStr),
'Invalid platform $platformStr',
);
return diagramStepPlatformNames[platformStr]!;
}).toSet();
})
.toSet();

print(
'Filters:\n categories: $categories\n names: $names\n steps: $steps',
Expand All @@ -102,17 +100,18 @@ Future<void> main(List<String> args) async {
Zone.current
.fork(
specification: ZoneSpecification(
handleUncaughtError: (
Zone self,
ZoneDelegate parent,
Zone zone,
Object error,
StackTrace stackTrace,
) {
print('Exception! $error\n$stackTrace');
errorLog.writeln(error);
errorLog.writeln(stackTrace);
},
handleUncaughtError:
(
Zone self,
ZoneDelegate parent,
Zone zone,
Object error,
StackTrace stackTrace,
) {
print('Exception! $error\n$stackTrace');
errorLog.writeln(error);
errorLog.writeln(stackTrace);
},
),
)
.runGuarded(() async {
Expand Down
31 changes: 14 additions & 17 deletions packages/diagram_viewer/lib/pages/diagram_catalog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ class CatalogTile extends StatelessWidget {
child: Text(
name,
style: TextStyle(
color:
Theme.of(context).brightness == Brightness.light
? Colors.white
: Colors.black,
color: Theme.of(context).brightness == Brightness.light
? Colors.white
: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 16.0,
),
Expand Down Expand Up @@ -136,9 +135,8 @@ class StepTile extends StatelessWidget {
final List<DiagramMetadata> diagrams = await step.diagrams;
Navigator.of(context).push(
MaterialPageRoute<void>(
builder:
(BuildContext context) =>
DiagramViewerPage(step: step, diagrams: diagrams),
builder: (BuildContext context) =>
DiagramViewerPage(step: step, diagrams: diagrams),
),
);
}
Expand All @@ -148,16 +146,15 @@ class StepTile extends StatelessWidget {
return ListTile(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
title: Text(step.runtimeType.toString()),
trailing:
step.platforms.containsAll(DiagramPlatform.values)
? null
: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
for (final DiagramPlatform platform in step.platforms)
Chip(label: Text(platform.name)),
],
),
trailing: step.platforms.containsAll(DiagramPlatform.values)
? null
: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
for (final DiagramPlatform platform in step.platforms)
Chip(label: Text(platform.name)),
],
),
visualDensity: const VisualDensity(vertical: -4),
onTap: () => openDiagramStepViewer(context, step),
);
Expand Down
7 changes: 3 additions & 4 deletions packages/diagram_viewer/lib/pages/diagram_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ class _DiagramViewerPageState extends State<DiagramViewerPage>
padding: const EdgeInsets.all(8.0),
child: Material(
shape: const StadiumBorder(),
color:
theme.brightness == Brightness.light
? theme.primaryColor
: theme.colorScheme.surface,
color: theme.brightness == Brightness.light
? theme.primaryColor
: theme.colorScheme.surface,
elevation: 4,
),
),
Expand Down
4 changes: 3 additions & 1 deletion packages/diagram_viewer/test/diagram_viewer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ void main() {
final DiagramStep step = TestDiagramStep();
final List<DiagramMetadata> diagrams = await step.diagrams;
await tester.pumpWidget(
DiagramViewerApp(home: DiagramViewerPage(step: step, diagrams: diagrams)),
DiagramViewerApp(
home: DiagramViewerPage(step: step, diagrams: diagrams),
),
);
await tester.pump(const Duration(minutes: 1));
for (final DiagramMetadata diagram in diagrams) {
Expand Down
41 changes: 21 additions & 20 deletions packages/diagrams/lib/src/alert_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,27 @@ class _AlertDialogDiagramState extends State<AlertDialogDiagram>
initialRoute: '/',
onGenerateRoute: (RouteSettings settings) {
return PageRouteBuilder<void>(
pageBuilder: (
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) {
return Scaffold(
appBar: AppBar(title: const Text('AlertDialog Demo')),
body: Center(
child: Builder(
builder: (BuildContext context) {
return OutlinedButton(
key: _openDialogKey,
child: const Text('Show Dialog'),
onPressed: () => _neverSatisfied(context),
);
},
),
),
);
},
pageBuilder:
(
BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
) {
return Scaffold(
appBar: AppBar(title: const Text('AlertDialog Demo')),
body: Center(
child: Builder(
builder: (BuildContext context) {
return OutlinedButton(
key: _openDialogKey,
child: const Text('Show Dialog'),
onPressed: () => _neverSatisfied(context),
);
},
),
),
);
},
);
},
),
Expand Down
Loading