This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class AlbumArt extends StatefulWidget { | |
const AlbumArt({required this.image, required this.isPlaying, Key? key}) | |
: super(key: key); | |
final String image; | |
final bool isPlaying; | |
@override | |
State<AlbumArt> createState() => _AlbumArtState(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:bloc_example/music_player/widgets/media_button.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
import '../bloc/music_player_bloc.dart'; | |
class MediaControls extends StatelessWidget { | |
MediaControls({required this.isplaying, Key? key}) : super(key: key); | |
static const double iconSize = 35; | |
final bool isplaying; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
part of 'music_player_bloc.dart'; | |
abstract class MusicPlayerEvent {} | |
class PlayPauseButtonPressed extends MusicPlayerEvent {} | |
class NextTrackButtonPressed extends MusicPlayerEvent {} | |
class PreviousTrackButtonPressed extends MusicPlayerEvent {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
part of 'music_player_bloc.dart'; | |
abstract class MusicPlayerState { | |
bool isPlaying; | |
MusicPlayerState(this.isPlaying); | |
} | |
class InitialState extends MusicPlayerState { | |
InitialState(super.isPlaying); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter_bloc/flutter_bloc.dart'; | |
part 'music_player_state.dart'; | |
part 'music_player_event.dart'; | |
class MusicPlayerBloc extends Bloc<MusicPlayerEvent, MusicPlayerState> { | |
MusicPlayerBloc({bool isPlaying = false}) : super(InitialState(isPlaying)) { | |
_playMusic = isPlaying; | |
on<PlayPauseButtonPressed>(_handlePlay); | |
on<PreviousTrackButtonPressed>(_handlePreviousTrack); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
import 'bloc/music_player_bloc.dart'; | |
import 'widgets/album_art.dart'; | |
import 'widgets/media_controls.dart'; | |
class MusicPlayerScreen extends StatelessWidget { | |
const MusicPlayerScreen({Key? key}) : super(key: key); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExampleScreen extends StatelessWidget { | |
const ExampleScreen({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return BlocBuilder<ExampleBloc, ExampleState>( | |
builder: (context, state) { | |
if( state is DataLoading) | |
{ return const CircularProgressIndicator(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
import 'music_player/music_player.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export 'bloc/music_player_bloc.dart'; | |
export 'music_player_screen.dart'; |
OlderNewer