I would like to create CustomWidget similar to FlutterFlowAudioPlayer, but with the possibility to change AudioPath from variable. So far I just copied the FlutterFlowAudioPlayer code from HomePage code and added import: '/flutter_flow/flutter_flow_audio_player.dart'
, what gives me this error:
Target of URI doesn't exist: '/flutter_flow/flutter_flow_audio_player.dart'. Try creating the file referenced by the URI, or try using a URI for a file that does exist.
Here is what I exactly did:
1) I added new Custom Widget with name AudioPlayerCustom
2) I pasted following code to it:
// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/schema/structs/index.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import '/flutter_flow/flutter_flow_audio_player.dart';
import 'package:assets_audio_player/assets_audio_player.dart';
class NewCustomWidget extends StatefulWidget {
const NewCustomWidget({
Key? key,
this.width,
this.height,
this.audioPath,
}) : super(key: key);
final double? width;
final double? height;
final String? audioPath;
@override
_NewCustomWidgetState createState() => _NewCustomWidgetState();
}
class _NewCustomWidgetState extends State<NewCustomWidget> {
@override
Widget build(BuildContext context) {
return FlutterFlowAudioPlayer(
audio: Audio.network(
FFAppState().buttons[FFAppState().indexOfPressedButton].audio,
metas: Metas(
id: 'sample3.mp3-cda06bb5',
),
),
titleTextStyle: FlutterFlowTheme.of(context).titleLarge,
playbackDurationTextStyle: FlutterFlowTheme.of(context).labelMedium,
fillColor: FlutterFlowTheme.of(context).secondaryBackground,
playbackButtonColor: FlutterFlowTheme.of(context).primary,
activeTrackColor: FlutterFlowTheme.of(context).alternate,
elevation: 0,
playInBackground: PlayInBackground.disabledRestoreOnForeground,
);
}
}
3) To Pubspec dependencies in right panel I added this dependency: assets_audio_player: 3.0.6
and pressed the update button. (I didn't find in which format should I add flutter_flow_audio_player
dependency, but it actually is defined in pubspec.yaml
file so, is there a need to add it again?)
4) Saved and checked for errors, what threw the above mentioned error.
Thank you for response!