Skip to content

Commit 349b3d0

Browse files
committed
- Removed unnecessary code
- Updated `pubspec.yaml` repository URL
1 parent 2029f4d commit 349b3d0

12 files changed

+192
-148
lines changed

example/analysis_options.yaml

Lines changed: 60 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,63 @@
1-
# This file configures the analyzer, which statically analyzes Dart code to
2-
# check for errors, warnings, and lints.
3-
#
4-
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5-
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6-
# invoked from the command line by running `flutter analyze`.
7-
8-
# The following line activates a set of recommended lints for Flutter apps,
9-
# packages, and plugins designed to encourage good coding practices.
10-
include: package:flutter_lints/flutter.yaml
1+
analyzer:
2+
strong-mode:
3+
implicit-dynamic: false
4+
errors:
5+
missing_required_param: warning
6+
missing_return: warning
117

128
linter:
13-
# The lint rules applied to this project can be customized in the
14-
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15-
# included above or to enable additional rules. A list of all available lints
16-
# and their documentation is published at https://dart.dev/lints.
17-
#
18-
# Instead of disabling a lint rule for the entire project in the
19-
# section below, it can also be suppressed for a single line of code
20-
# or a specific dart file by using the `// ignore: name_of_lint` and
21-
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22-
# producing the lint.
239
rules:
24-
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25-
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
26-
27-
# Additional information about this file can be found at
28-
# https://dart.dev/guides/language/analysis-options
10+
- avoid_catching_errors
11+
- avoid_function_literals_in_foreach_calls
12+
- avoid_private_typedef_functions
13+
- avoid_renaming_method_parameters
14+
- avoid_returning_null_for_void
15+
- avoid_unused_constructor_parameters
16+
- avoid_void_async
17+
- await_only_futures
18+
- camel_case_types
19+
- cancel_subscriptions
20+
- comment_references
21+
- constant_identifier_names
22+
- control_flow_in_finally
23+
- directives_ordering
24+
- empty_statements
25+
- file_names
26+
- hash_and_equals
27+
- implementation_imports
28+
- join_return_with_assignment
29+
- lines_longer_than_80_chars
30+
- missing_whitespace_between_adjacent_strings
31+
- no_runtimeType_toString
32+
- non_constant_identifier_names
33+
- only_throw_errors
34+
- overridden_fields
35+
- package_names
36+
- package_prefixed_library_names
37+
- prefer_asserts_in_initializer_lists
38+
- prefer_const_constructors
39+
- prefer_const_declarations
40+
- prefer_expression_function_bodies
41+
- prefer_final_locals
42+
- prefer_function_declarations_over_variables
43+
- prefer_initializing_formals
44+
- prefer_inlined_adds
45+
- prefer_interpolation_to_compose_strings
46+
- prefer_is_not_operator
47+
- prefer_null_aware_operators
48+
- prefer_relative_imports
49+
- prefer_typing_uninitialized_variables
50+
- prefer_void_to_null
51+
- provide_deprecation_message
52+
- sort_pub_dependencies
53+
- test_types_in_equals
54+
- throw_in_finally
55+
- unnecessary_brace_in_string_interps
56+
- unnecessary_lambdas
57+
- unnecessary_null_aware_assignments
58+
- unnecessary_overrides
59+
- unnecessary_parenthesis
60+
- unnecessary_statements
61+
- unnecessary_string_interpolations
62+
- use_string_buffers
63+
- void_checks

example/lib/main.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,17 @@ class _MyHomePageState extends State<MyHomePage> {
8888
scrollDirection: Axis.horizontal,
8989
children: [
9090
ElevatedButton(
91-
onPressed: isProcessing
92-
? null
93-
: () => executeFFmpegCommand('list_codecs'),
91+
onPressed:
92+
isProcessing
93+
? null
94+
: () => executeFFmpegCommand('list_codecs'),
9495
child: const Text('List Codecs'),
9596
),
9697
ElevatedButton(
97-
onPressed: isProcessing
98-
? null
99-
: () => executeFFmpegCommand('mediacodec'),
98+
onPressed:
99+
isProcessing
100+
? null
101+
: () => executeFFmpegCommand('mediacodec'),
100102
child: const Text('MediaCodec'),
101103
),
102104
],

lib/abstract_session.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ abstract class AbstractSession extends Session {
6969
]) async {
7070
try {
7171
await FFmpegKitConfig.init();
72-
final Map<dynamic, dynamic>? nativeSession = await _platform
73-
.abstractSessionCreateFFmpegSession(argumentsArray);
72+
final Map<dynamic, dynamic>? nativeSession =
73+
await _platform.abstractSessionCreateFFmpegSession(argumentsArray);
7474

7575
final session = new FFmpegSession();
7676

@@ -130,8 +130,8 @@ abstract class AbstractSession extends Session {
130130
]) async {
131131
try {
132132
await FFmpegKitConfig.init();
133-
final Map<dynamic, dynamic>? nativeSession = await _platform
134-
.abstractSessionCreateFFprobeSession(argumentsArray);
133+
final Map<dynamic, dynamic>? nativeSession =
134+
await _platform.abstractSessionCreateFFprobeSession(argumentsArray);
135135

136136
final session = new FFprobeSession();
137137

@@ -295,18 +295,18 @@ abstract class AbstractSession extends Session {
295295
return _platform
296296
.abstractSessionGetAllLogs(this.getSessionId(), waitTimeout)
297297
.then((allLogs) {
298-
if (allLogs == null) {
299-
return List.empty();
300-
} else {
301-
return allLogs
302-
.map(
303-
(dynamic logObject) => FFmpegKitFactory.mapToLog(
304-
logObject as Map<dynamic, dynamic>,
305-
),
306-
)
307-
.toList();
308-
}
309-
});
298+
if (allLogs == null) {
299+
return List.empty();
300+
} else {
301+
return allLogs
302+
.map(
303+
(dynamic logObject) => FFmpegKitFactory.mapToLog(
304+
logObject as Map<dynamic, dynamic>,
305+
),
306+
)
307+
.toList();
308+
}
309+
});
310310
} on PlatformException catch (e, stack) {
311311
print("Plugin getAllLogs error: ${e.message}");
312312
return Future.error("getAllLogs failed.", stack);

lib/extensions.dart

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ import 'return_code.dart';
44
extension XFFmpegSession on Future<FFmpegSession> {
55
Future<String> thenReturnResultOrLogs(
66
String Function(FFmpegSession) onSuccess,
7-
) => then(
8-
(session) => session.getReturnCode().then((returnCode) {
9-
if (ReturnCode.isSuccess(returnCode)) {
10-
return onSuccess(session);
11-
}
12-
return session.getAllLogs().then((logs) {
13-
final String logOutput = logs.map((log) => log.getMessage()).join('\n');
14-
throw Exception(
15-
'FFmpeg command failed with return code: $returnCode. Logs: $logOutput',
16-
);
17-
});
18-
}),
19-
);
7+
) =>
8+
then(
9+
(session) => session.getReturnCode().then((returnCode) {
10+
if (ReturnCode.isSuccess(returnCode)) {
11+
return onSuccess(session);
12+
}
13+
return session.getAllLogs().then((logs) {
14+
final String logOutput =
15+
logs.map((log) => log.getMessage()).join('\n');
16+
throw Exception(
17+
'FFmpeg command failed with return code: $returnCode. Logs: $logOutput',
18+
);
19+
});
20+
}),
21+
);
2022
}

lib/ffmpeg_kit.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ class FFmpegKit {
4949
FFmpegSessionCompleteCallback? completeCallback = null,
5050
LogCallback? logCallback = null,
5151
StatisticsCallback? statisticsCallback = null,
52-
]) async => FFmpegKit.executeWithArgumentsAsync(
53-
FFmpegKitConfig.parseArguments(command),
54-
completeCallback,
55-
logCallback,
56-
statisticsCallback,
57-
);
52+
]) async =>
53+
FFmpegKit.executeWithArgumentsAsync(
54+
FFmpegKitConfig.parseArguments(command),
55+
completeCallback,
56+
logCallback,
57+
statisticsCallback,
58+
);
5859

5960
/// Starts an asynchronous FFmpeg execution with arguments provided.
6061
///

lib/ffmpeg_kit_config.dart

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,7 @@ class FFmpegKitConfig {
369369
/// execution results for MediaInformation sessions.
370370
static void enableMediaInformationSessionCompleteCallback([
371371
MediaInformationSessionCompleteCallback?
372-
mediaInformationSessionCompleteCallback =
373-
null,
372+
mediaInformationSessionCompleteCallback = null,
374373
]) {
375374
FFmpegKitFactory.setGlobalMediaInformationSessionCompleteCallback(
376375
mediaInformationSessionCompleteCallback,
@@ -379,8 +378,8 @@ class FFmpegKitConfig {
379378

380379
/// Returns the global MediaInformationSessionCompleteCallback set.
381380
static MediaInformationSessionCompleteCallback?
382-
getMediaInformationSessionCompleteCallback() =>
383-
FFmpegKitFactory.getGlobalMediaInformationSessionCompleteCallback();
381+
getMediaInformationSessionCompleteCallback() =>
382+
FFmpegKitFactory.getGlobalMediaInformationSessionCompleteCallback();
384383

385384
/// Returns the current log level.
386385
static int getLogLevel() => _activeLogLevel;
@@ -488,8 +487,8 @@ class FFmpegKitConfig {
488487
try {
489488
await init();
490489
return _platform.ffmpegKitConfigGetLastSession().then(
491-
FFmpegKitFactory.mapToNullableSession,
492-
);
490+
FFmpegKitFactory.mapToNullableSession,
491+
);
493492
} on PlatformException catch (e, stack) {
494493
print("Plugin getLastSession error: ${e.message}");
495494
return Future.error("getLastSession failed.", stack);
@@ -501,8 +500,8 @@ class FFmpegKitConfig {
501500
try {
502501
await init();
503502
return _platform.ffmpegKitConfigGetLastCompletedSession().then(
504-
FFmpegKitFactory.mapToNullableSession,
505-
);
503+
FFmpegKitFactory.mapToNullableSession,
504+
);
506505
} on PlatformException catch (e, stack) {
507506
print("Plugin getLastCompletedSession error: ${e.message}");
508507
return Future.error("getLastCompletedSession failed.", stack);
@@ -594,7 +593,7 @@ class FFmpegKitConfig {
594593

595594
/// Returns all MediaInformation sessions in the session history.
596595
static Future<List<MediaInformationSession>>
597-
getMediaInformationSessions() async {
596+
getMediaInformationSessions() async {
598597
try {
599598
await FFmpegKitConfig.init();
600599
return _platform.ffprobeKitListMediaInformationSessions().then((
@@ -628,18 +627,18 @@ class FFmpegKitConfig {
628627
return _platform
629628
.ffmpegKitConfigGetSessionsByState(sessionState.index)
630629
.then((sessions) {
631-
if (sessions == null) {
632-
return List.empty();
633-
} else {
634-
return sessions
635-
.map(
636-
(dynamic sessionObject) => FFmpegKitFactory.mapToSession(
637-
sessionObject as Map<dynamic, dynamic>,
638-
),
639-
)
640-
.toList();
641-
}
642-
});
630+
if (sessions == null) {
631+
return List.empty();
632+
} else {
633+
return sessions
634+
.map(
635+
(dynamic sessionObject) => FFmpegKitFactory.mapToSession(
636+
sessionObject as Map<dynamic, dynamic>,
637+
),
638+
)
639+
.toList();
640+
}
641+
});
643642
} on PlatformException catch (e, stack) {
644643
print("Plugin getSessionsByState error: ${e.message}");
645644
return Future.error("getSessionsByState failed.", stack);

lib/ffmpeg_session.dart

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,18 @@ class FFmpegSession extends AbstractSession {
7272
return FFmpegKitPlatform.instance
7373
.ffmpegSessionGetAllStatistics(this.getSessionId(), waitTimeout)
7474
.then((allStatistics) {
75-
if (allStatistics == null) {
76-
return List.empty();
77-
} else {
78-
return allStatistics
79-
.map(
80-
(dynamic statisticsObject) =>
81-
FFmpegKitFactory.mapToStatistics(
82-
statisticsObject as Map<dynamic, dynamic>,
83-
),
84-
)
85-
.toList();
86-
}
87-
});
75+
if (allStatistics == null) {
76+
return List.empty();
77+
} else {
78+
return allStatistics
79+
.map(
80+
(dynamic statisticsObject) => FFmpegKitFactory.mapToStatistics(
81+
statisticsObject as Map<dynamic, dynamic>,
82+
),
83+
)
84+
.toList();
85+
}
86+
});
8887
} on PlatformException catch (e, stack) {
8988
print("Plugin getAllStatistics error: ${e.message}");
9089
return Future.error("getAllStatistics failed.", stack);
@@ -100,19 +99,18 @@ class FFmpegSession extends AbstractSession {
10099
return FFmpegKitPlatform.instance
101100
.ffmpegSessionGetStatistics(this.getSessionId())
102101
.then((statistics) {
103-
if (statistics == null) {
104-
return List.empty();
105-
} else {
106-
return statistics
107-
.map(
108-
(dynamic statisticsObject) =>
109-
FFmpegKitFactory.mapToStatistics(
110-
statisticsObject as Map<dynamic, dynamic>,
111-
),
112-
)
113-
.toList();
114-
}
115-
});
102+
if (statistics == null) {
103+
return List.empty();
104+
} else {
105+
return statistics
106+
.map(
107+
(dynamic statisticsObject) => FFmpegKitFactory.mapToStatistics(
108+
statisticsObject as Map<dynamic, dynamic>,
109+
),
110+
)
111+
.toList();
112+
}
113+
});
116114
} on PlatformException catch (e, stack) {
117115
print("Plugin getStatistics error: ${e.message}");
118116
return Future.error("getStatistics failed.", stack);

0 commit comments

Comments
 (0)