Skip to content

Commit 6e58b7a

Browse files
author
Illia Romanenko
committed
add pedantic, apply suggestions, format source code files
1 parent 93af2ab commit 6e58b7a

File tree

10 files changed

+100
-95
lines changed

10 files changed

+100
-95
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:pedantic/analysis_options.yaml

flutter_vlc_player/example/lib/controls_overlay.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ class ControlsOverlay extends StatelessWidget {
4545
children: [
4646
IconButton(
4747
onPressed: () async {
48-
if (controller.value.duration != null)
48+
if (controller.value.duration != null) {
4949
await controller.seekTo(
5050
controller.value.position -
5151
Duration(seconds: 10));
52+
}
5253
},
5354
color: Colors.white,
5455
iconSize: 60.0,
@@ -64,10 +65,11 @@ class ControlsOverlay extends StatelessWidget {
6465
),
6566
IconButton(
6667
onPressed: () async {
67-
if (controller.value.duration != null)
68+
if (controller.value.duration != null) {
6869
await controller.seekTo(
6970
controller.value.position +
7071
Duration(seconds: 10));
72+
}
7173
},
7274
color: Colors.white,
7375
iconSize: 60.0,

flutter_vlc_player/example/lib/multiple_tab.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:flutter/cupertino.dart';
22
import 'package:flutter/material.dart';
3-
43
import 'package:flutter_vlc_player/vlc_player_flutter.dart';
4+
55
import 'vlc_player_with_controls.dart';
66

77
class MultipleTab extends StatefulWidget {
@@ -22,9 +22,9 @@ class _MultipleTabState extends State<MultipleTab> {
2222
@override
2323
void initState() {
2424
super.initState();
25-
controllers = List<VlcPlayerController>();
25+
controllers = <VlcPlayerController>[];
2626
for (var i = 0; i < urls.length; i++) {
27-
VlcPlayerController controller = VlcPlayerController.network(
27+
var controller = VlcPlayerController.network(
2828
urls[i],
2929
hwAcc: HwAcc.FULL,
3030
autoPlay: false,

flutter_vlc_player/example/lib/single_tab.dart

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import 'dart:typed_data';
44
import 'package:flutter/cupertino.dart';
55
import 'package:flutter/material.dart';
66
import 'package:flutter/services.dart';
7-
7+
import 'package:flutter_vlc_player/vlc_player_flutter.dart';
88
import 'package:path_provider/path_provider.dart';
99

1010
import 'video_data.dart';
11-
import 'package:flutter_vlc_player/vlc_player_flutter.dart';
1211
import 'vlc_player_with_controls.dart';
1312

1413
class SingleTab extends StatefulWidget {
@@ -18,22 +17,22 @@ class SingleTab extends StatefulWidget {
1817

1918
class _SingleTabState extends State<SingleTab> {
2019
VlcPlayerController _controller;
21-
GlobalKey _key = GlobalKey<VlcPlayerWithControlsState>();
20+
final _key = GlobalKey<VlcPlayerWithControlsState>();
2221
//
2322
List<VideoData> listVideos;
2423
int selectedVideoIndex;
2524

2625
Future<File> _loadVideoToFs() async {
2726
final videoData = await rootBundle.load('assets/sample.mp4');
2827
final videoBytes = Uint8List.view(videoData.buffer);
29-
String dir = (await getTemporaryDirectory()).path;
30-
File temp = new File('$dir/temp.file');
28+
var dir = (await getTemporaryDirectory()).path;
29+
var temp = File('$dir/temp.file');
3130
temp.writeAsBytesSync(videoBytes);
3231
return temp;
3332
}
3433

3534
void fillVideos() {
36-
listVideos = List<VideoData>();
35+
listVideos = <VideoData>[];
3736
//
3837
listVideos.add(VideoData(
3938
name: 'Network Video 1',
@@ -44,8 +43,7 @@ class _SingleTabState extends State<SingleTab> {
4443
//
4544
listVideos.add(VideoData(
4645
name: 'Network Video 2',
47-
path:
48-
'https://media.w3.org/2010/05/sintel/trailer.mp4',
46+
path: 'https://media.w3.org/2010/05/sintel/trailer.mp4',
4947
type: VideoType.network,
5048
));
5149
//
@@ -58,7 +56,7 @@ class _SingleTabState extends State<SingleTab> {
5856
//
5957
listVideos.add(VideoData(
6058
name: 'File Video 1',
61-
path: "System File Example",
59+
path: 'System File Example',
6260
type: VideoType.file,
6361
));
6462
//
@@ -70,14 +68,14 @@ class _SingleTabState extends State<SingleTab> {
7068
}
7169

7270
@override
73-
void initState() {
71+
void initState() {
7472
super.initState();
7573

7674
//
7775
fillVideos();
7876
selectedVideoIndex = 0;
7977
//
80-
VideoData initVideo = listVideos[selectedVideoIndex];
78+
var initVideo = listVideos[selectedVideoIndex];
8179
switch (initVideo.type) {
8280
case VideoType.network:
8381
_controller = VlcPlayerController.network(
@@ -100,7 +98,7 @@ class _SingleTabState extends State<SingleTab> {
10098
);
10199
break;
102100
case VideoType.file:
103-
File file = File(initVideo.path);
101+
var file = File(initVideo.path);
104102
_controller = VlcPlayerController.file(
105103
file,
106104
onInit: () async {
@@ -114,7 +112,6 @@ class _SingleTabState extends State<SingleTab> {
114112
case VideoType.asset:
115113
_controller = VlcPlayerController.asset(
116114
initVideo.path,
117-
// package: "test",
118115
onInit: () async {
119116
await _controller.startRendererScanning();
120117
},
@@ -140,7 +137,7 @@ class _SingleTabState extends State<SingleTab> {
140137
itemCount: listVideos.length,
141138
physics: NeverScrollableScrollPhysics(),
142139
itemBuilder: (BuildContext context, int index) {
143-
VideoData video = listVideos[index];
140+
var video = listVideos[index];
144141
IconData iconData;
145142
switch (video.type) {
146143
case VideoType.network:
@@ -185,28 +182,28 @@ class _SingleTabState extends State<SingleTab> {
185182
break;
186183
case VideoType.file:
187184
Scaffold.of(context).showSnackBar(
188-
SnackBar(
189-
content: Text("Copying file to temporary storage..."),
190-
),
191-
);
185+
SnackBar(
186+
content: Text('Copying file to temporary storage...'),
187+
),
188+
);
192189
await Future.delayed(Duration(seconds: 1));
193-
// File file = File(video.path);
194-
File tempVideo = await _loadVideoToFs();
190+
var tempVideo = await _loadVideoToFs();
195191
await Future.delayed(Duration(seconds: 1));
196192
Scaffold.of(context).showSnackBar(
197-
SnackBar(
198-
content: Text("Now trying to play..."),
199-
),
200-
);
193+
SnackBar(
194+
content: Text('Now trying to play...'),
195+
),
196+
);
201197
await Future.delayed(Duration(seconds: 1));
202-
if (await tempVideo.exists())
198+
if (await tempVideo.exists()) {
203199
await _controller.setMediaFromFile(tempVideo);
204-
else
200+
} else {
205201
Scaffold.of(context).showSnackBar(
206202
SnackBar(
207-
content: Text("File load error."),
203+
content: Text('File load error.'),
208204
),
209205
);
206+
}
210207
break;
211208
case VideoType.asset:
212209
await _controller.setMediaFromAsset(video.path);

flutter_vlc_player/example/lib/vlc_player_with_controls.dart

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import 'dart:typed_data';
2-
import 'package:flutter/rendering.dart';
3-
import 'package:flutter_vlc_player/vlc_player_flutter.dart';
42

53
import 'package:flutter/material.dart';
4+
import 'package:flutter/rendering.dart';
5+
import 'package:flutter_vlc_player/vlc_player_flutter.dart';
66

77
import 'controls_overlay.dart';
88

@@ -12,7 +12,7 @@ class VlcPlayerWithControls extends StatefulWidget {
1212

1313
VlcPlayerWithControls({
1414
Key key,
15-
this.controller,
15+
@required this.controller,
1616
this.showControls = true,
1717
}) : assert(controller != null, 'You must provide a vlc controller'),
1818
super(key: key);
@@ -33,8 +33,8 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
3333
//
3434
double sliderValue = 0.0;
3535
double volumeValue = 50;
36-
String position = "";
37-
String duration = "";
36+
String position = '';
37+
String duration = '';
3838
int numberOfCaptions = 0;
3939
int numberOfAudioTracks = 0;
4040

@@ -59,7 +59,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
5959
}
6060

6161
void listener() async {
62-
if (!this.mounted) return;
62+
if (!mounted) return;
6363
//
6464
if (_controller.value.isInitialized) {
6565
var oPosition = _controller.value.position;
@@ -177,8 +177,9 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
177177
color: Colors.white,
178178
onPressed: () async {
179179
playbackSpeedIndex++;
180-
if (playbackSpeedIndex >= playbackSpeeds.length)
180+
if (playbackSpeedIndex >= playbackSpeeds.length) {
181181
playbackSpeedIndex = 0;
182+
}
182183
return await _controller.setPlaybackSpeed(
183184
playbackSpeeds.elementAt(playbackSpeedIndex));
184185
},
@@ -381,14 +382,14 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
381382
void _getSubtitleTracks() async {
382383
if (!_controller.value.isPlaying) return;
383384

384-
Map<int, String> subtitleTracks = await _controller.getSpuTracks();
385+
var subtitleTracks = await _controller.getSpuTracks();
385386
//
386-
if (subtitleTracks != null && subtitleTracks.length > 0) {
387-
int selectedSubId = await showDialog(
387+
if (subtitleTracks != null && subtitleTracks.isNotEmpty) {
388+
var selectedSubId = await showDialog(
388389
context: context,
389390
builder: (BuildContext context) {
390391
return AlertDialog(
391-
title: Text("Select Subtitle"),
392+
title: Text('Select Subtitle'),
392393
content: Container(
393394
width: double.maxFinite,
394395
height: 250,
@@ -423,14 +424,14 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
423424
void _getAudioTracks() async {
424425
if (!_controller.value.isPlaying) return;
425426

426-
Map<int, String> audioTracks = await _controller.getAudioTracks();
427+
var audioTracks = await _controller.getAudioTracks();
427428
//
428-
if (audioTracks != null && audioTracks.length > 0) {
429-
int selectedAudioTrackId = await showDialog(
429+
if (audioTracks != null && audioTracks.isNotEmpty) {
430+
var selectedAudioTrackId = await showDialog(
430431
context: context,
431432
builder: (BuildContext context) {
432433
return AlertDialog(
433-
title: Text("Select Audio"),
434+
title: Text('Select Audio'),
434435
content: Container(
435436
width: double.maxFinite,
436437
height: 250,
@@ -458,20 +459,21 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
458459
);
459460
},
460461
);
461-
if (selectedAudioTrackId != null)
462+
if (selectedAudioTrackId != null) {
462463
await _controller.setAudioTrack(selectedAudioTrackId);
464+
}
463465
}
464466
}
465467

466468
void _getRendererDevices() async {
467-
Map<String, String> castDevices = await _controller.getRendererDevices();
469+
var castDevices = await _controller.getRendererDevices();
468470
//
469-
if (castDevices != null && castDevices.length > 0) {
470-
String selectedCastDeviceName = await showDialog(
471+
if (castDevices != null && castDevices.isNotEmpty) {
472+
var selectedCastDeviceName = await showDialog(
471473
context: context,
472474
builder: (BuildContext context) {
473475
return AlertDialog(
474-
title: Text("Display Devices"),
476+
title: Text('Display Devices'),
475477
content: Container(
476478
width: double.maxFinite,
477479
height: 250,
@@ -502,20 +504,20 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
502504
await _controller.castToRenderer(selectedCastDeviceName);
503505
} else {
504506
Scaffold.of(context)
505-
.showSnackBar(SnackBar(content: Text("No Display Device Found!")));
507+
.showSnackBar(SnackBar(content: Text('No Display Device Found!')));
506508
}
507509
}
508510

509511
void _createCameraImage() async {
510-
Uint8List snapshot = await _controller.takeSnapshot();
512+
var snapshot = await _controller.takeSnapshot();
511513
_overlayEntry?.remove();
512514
_overlayEntry = _createSnapshotThumbnail(snapshot);
513515
Overlay.of(context).insert(_overlayEntry);
514516
}
515517

516518
OverlayEntry _createSnapshotThumbnail(Uint8List snapshot) {
517-
double right = initSnapshotRightPosition;
518-
double bottom = initSnapshotBottomPosition;
519+
var right = initSnapshotRightPosition;
520+
var bottom = initSnapshotBottomPosition;
519521
return OverlayEntry(
520522
builder: (context) => Positioned(
521523
right: right,

flutter_vlc_player/lib/src/flutter_vlc_player.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:flutter/widgets.dart';
22

3-
import 'vlc_player_platform.dart';
43
import 'vlc_player_controller.dart';
4+
import 'vlc_player_platform.dart';
55

66
class VlcPlayer extends StatefulWidget {
77
final VlcPlayerController controller;
@@ -38,7 +38,7 @@ class _VlcPlayerState extends State<VlcPlayer>
3838
_listener = () {
3939
if (!mounted) return;
4040
//
41-
final bool isInitialized = widget.controller.value.isInitialized;
41+
final isInitialized = widget.controller.value.isInitialized;
4242
if (isInitialized != _isInitialized) {
4343
setState(() {
4444
_isInitialized = isInitialized;

0 commit comments

Comments
 (0)