import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Media Control',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MediaControlScreen(),
);
}
}
class MediaControlScreen extends StatefulWidget {
@override
_MediaControlScreenState createState() => _MediaControlScreenState();
}
class _MediaControlScreenState extends State<MediaControlScreen> {
double _currentSliderValue = 0;
Widget _buildControlButtonRow() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(
icon: Icon(Icons.remove_circle_outline),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.add_circle_outline),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.skip_previous),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.play_circle_filled),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.skip_next),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.remove_circle_outline),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.add_circle_outline),
onPressed: () {},
),
],
);
}
Widget _buildTimeDisplayRow() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: TextFormField(
textAlign: TextAlign.center,
initialValue: '00:09',
),
),
Expanded(
child: TextFormField(
textAlign: TextAlign.center,
initialValue: '00:16',
),
),
Expanded(
child: TextFormField(
textAlign: TextAlign.center,
initialValue: '00:18',
),
),
],
);
}
Widget _buildSlider() {
return Slider(
value: _currentSliderValue,
min: 0,
max: 100,
divisions: 100,
label: _currentSliderValue.round().toString(),
onChanged: (double value) {
setState(() {
_currentSliderValue = value;
});
},
);
}
Widget _buildPlaybackControlRow() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(
icon: Icon(Icons.fast_rewind),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.play_arrow),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.fast_forward),
onPressed: () {},
),
],
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Media Control'),
),
body: Padding(
padding: EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_buildControlButtonRow(),
SizedBox(height: 20),
_buildTimeDisplayRow(),
_buildSlider(),
_buildPlaybackControlRow(),
],
),
),
);
}
}