pparth602

library_page.dart

Mar 14th, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.62 KB | None | 0 0
  1. import 'package:audiobook_player/presentation/widgets/music_tile.dart';
  2. import 'package:file_picker/file_picker.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:just_audio/just_audio.dart';
  5.  
  6. class LibraryPage extends StatefulWidget {
  7.   final bool isPlay;
  8.   final List<PlatformFile> paths;
  9.   final AudioPlayer player01;
  10.   // final List<String> listOfFileName;
  11.  
  12.   LibraryPage({Key key, this.paths, this.isPlay, this.player01})
  13.       : super(key: key);
  14.   @override
  15.   _LibraryPageState createState() => _LibraryPageState();
  16. }
  17.  
  18. class _LibraryPageState extends State<LibraryPage> {
  19.   bool isPlay = true;
  20.  
  21.   @override
  22.   Widget build(BuildContext context) {
  23.     return Scaffold(
  24.         appBar: AppBar(
  25.           title: Text("Open Audiobook"),
  26.           actions: <Widget>[
  27.             InkWell(
  28.               onTap: () async {},
  29.               child: Padding(
  30.                 padding: const EdgeInsets.all(15.0),
  31.                 child: Icon(Icons.add_circle_outline_rounded),
  32.               ),
  33.             ),
  34.           ],
  35.         ),
  36.         body: ListView.builder(
  37.           itemCount: widget.paths.length,
  38.           itemBuilder: (BuildContext context, int index) {
  39.             return InkWell(
  40.               onTap: () async {
  41.                 var duration =
  42.                     await widget.player01.setFilePath(widget.paths[index].path);
  43.                 widget.player01.play();
  44.                 isPlay = true;
  45.               },
  46.               child: MusicTile(
  47.                   musicName: widget.paths[index].name,
  48.                   authorName: "authorName"),
  49.             );
  50.           },
  51.         ));
  52.   }
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment