nessmediametadataretriever 1.1.1
nessmediametadataretriever: ^1.1.1 copied to clipboard
nessmediametadataretriever
example/lib/main.dart
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:nessmediametadataretriever/nessmediametadataretriever.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
NessMetadata? metadata;
String? path;
Widget? albumArt;
Widget? table;
Future<void> onSelected(String path) async {
FocusScope.of(context).unfocus();
// print(File(path).existsSync());
var metadata = await NessMetadataRetriever.fromFile(File(path));
setState(() {
albumArt = metadata.albumArt != null
? Image.memory(
metadata.albumArt!,
height: 200.0,
width: 200.0,
)
: const SizedBox(
height: 200.0,
width: 200.0,
child: Text('No album art.'),
);
table = SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding:const EdgeInsets.all(20.0),
child: albumArt ?? Container(),
),
const SizedBox(
width: 16.0,
),
DataTable(
columns: const [
DataColumn(
label: Text('Property',
style: TextStyle(fontWeight: FontWeight.w600))),
DataColumn(
label: Text('Value',
style: TextStyle(fontWeight: FontWeight.w600))),
],
rows: [
DataRow(
cells: [
const DataCell( Text('Title')),
DataCell( Text('${metadata.title}')),
],
),
DataRow(
cells: [
const DataCell( Text('ArtistNames')),
DataCell(Text('${metadata.artist}')),
],
),
DataRow(
cells: [
const DataCell( Text('Album')),
DataCell(Text('${metadata.album}')),
],
),
DataRow(
cells: [
const DataCell( Text('AlbumArtist')),
DataCell(Text('${metadata.albumArtist}')),
],
),
DataRow(
cells: [
const DataCell( Text('Duration')),
DataCell(Text('${metadata.duration}')),
],
),
],
),
],
),
);
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('nessmediametadataretriever'),
),
body: Scrollbar(
isAlwaysShown: true,
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
children: [
const Divider(
color: Colors.transparent,
height: 16.0,
),
TextField(
cursorWidth: 1.0,
onEditingComplete: () => onSelected(path!),
onChanged: (String value) => path = value,
style:const TextStyle(fontSize: 14.0),
decoration:const InputDecoration(
hintText: 'Enter media path.',
hintStyle: TextStyle(fontSize: 14.0)),
),
const Divider(
color: Colors.transparent,
height: 16.0,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () => onSelected(path!),
child:const Text('Retrieve MediaMetadata'),
),
],
),
const Divider(
color: Colors.transparent,
height: 16.0,
),
const Divider(
color: Colors.transparent,
height: 16.0,
),
table ??
const Text(
'No media opened.',
textAlign: TextAlign.center,
),
],
),
),
),
);
}
}