encoding_checker 0.0.2
encoding_checker: ^0.0.2 copied to clipboard
A Plugin to check if a device supports playing h265 encoded videos
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:encoding_checker/encoding_checker.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _supportsH265 = 'Unknown';
final _encodingCheckerPlugin = EncodingChecker();
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
try {
final checkResult =
await _encodingCheckerPlugin.checkH265Support() ?? false;
_supportsH265 = checkResult.toString();
} on PlatformException {
_supportsH265 = 'Failed to get data.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Supports h265: $_supportsH265\n'),
],
),
),
),
);
}
}