Skip to content

Instantly share code, notes, and snippets.

View dokumanx's full-sized avatar
🏠
Working from home

Nahit Fidancı dokumanx

🏠
Working from home
View GitHub Profile
{
"configurations": [
{
"name": "Flutter",
"request": "launch",
"type": "dart",
"toolArgs": [
"--dart-define",
"ANNIVERSARY=I_HAVE_NO_IDEA"
]
"configurations":[
{
"name":"Flutter",
"request":"launch",
"type":"dart",
"toolArgs":[
"--dart-define",
"MY_VAR=MY_VALUE",
"--dart-define",
"MY_OTHER_VAR=MY_OTHER_VALUE"
"configurations": [
{
"name": "Flutter",
"request": "launch",
"type": "dart",
"toolArgs": [
"--dart-define",
"MY_VAR=MY_VALUE",
"--dart-define",
"MY_OTHER_VAR=MY_OTHER_VALUE"
final movieProvider = FutureProvider.autoDispose<TMDBMovieBasic>((ref) async {
// get the repository
final moviesRepo = ref.watch(fetchMoviesRepositoryProvider);
// an object from package:dio that allows cancelling http requests
final cancelToken = CancelToken();
// if the request is successful, keep the response
// get the [KeepAliveLink]
final link = ref.keepAlive();
import 'package:bloc_test/bloc_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:music_player_bloc/features/play_music/bloc/music_player_bloc.dart';
import 'package:music_player_bloc/features/play_music/core/track_timer.dart';
import 'package:music_player_bloc/features/play_music/repository/playlist_repository.dart';
import 'constants.dart';
@GenerateNiceMocks([
blocTest(
'Skip to the previous track',
build: () => musicPlayerBloc,
setUp: () {
when(trackTimer.passedTime(trackDuration: anyNamed('trackDuration')))
.thenAnswer((_) => Duration.zero);
},
seed: () => state.copyWith(
status: PlayerStatus.playing,
currentTime: const Duration(seconds: 10),
blocTest(
'Skip to the next track while there is no remaining track',
build: () => musicPlayerBloc,
setUp: () {
when(trackTimer.passedTime(trackDuration: anyNamed('trackDuration')))
.thenAnswer((_) => const Duration(seconds: 0));
},
seed: () => state.copyWith(
status: PlayerStatus.playing,
currentTrackIndex: blues90s.tracks.length - 1,
blocTest(
'Skip to the next track while there is no remaining track',
build: () => musicPlayerBloc,
setUp: () {
when(trackTimer.passedTime(trackDuration: anyNamed('trackDuration')))
.thenAnswer((_) => const Duration(seconds: 0));
},
seed: () => state.copyWith(
status: PlayerStatus.playing,
currentTrackIndex: blues90s.tracks.length - 1,
blocTest(
'Skip next track',
build: () => musicPlayerBloc,
setUp: () {
when(trackTimer.passedTime(trackDuration: anyNamed('trackDuration')))
.thenAnswer((_) => const Duration(seconds: 0));
},
seed: () => state.copyWith(
status: PlayerStatus.playing,
),
blocTest<MusicPlayerBloc, MusicPlayerState>(
'Play the first track',
build: () => musicPlayerBloc,
setUp: () {
when(trackTimer.passedTime(trackDuration: anyNamed('trackDuration')))
.thenAnswer((_) => const Duration(seconds: 0));
},
act: (bloc) => bloc.add(const MusicPlayerEvent.play()),
skip: 1,
expect: () => <MusicPlayerState>[