os_mime_type 0.0.2 os_mime_type: ^0.0.2 copied to clipboard
The Flutter package os_mime_type enables the conversion of mime types to file extensions and vice versa, facilitating seamless interaction with file types in application development.
import 'package:flutter/material.dart';
import 'package:os_mime_type/os_mime_type.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'OS Mime Type Demo',
home: Scaffold(
appBar: AppBar(
title: const Text('OS Mime Type Demo'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Mime Type from Extension: ${mimeFromExtension(extension: ".png")}',
),
Text(
'Mime Type from File Name: ${mimeFromFileName(fileName: "image.jpg")}',
),
Text(
'Extension from Mime: ${extensionFromMime(mime: "application/json")}',
),
],
),
),
),
);
}
}