flutter_ui_mode_manager 1.0.0 flutter_ui_mode_manager: ^1.0.0 copied to clipboard
A flutter plugin that helps to deffrentiate which platform a flutter application is running on, Phone, TV, Car, and so on
flutter_ui_mode_manager #
A flutter plugin that helps to deffrentiate which platform a flutter application is running on, Phone, TV, Car, and so on.
Example #
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_ui_mode_manager/flutter_ui_mode_manager.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
UiMode _uiMode;
@override
void initState() {
super.initState();
initDeviceUiMode();
}
Future<void> initDeviceUiMode() async {
UiMode uiMode;
try {
uiMode = await FlutterUiModeManager.getDeviceUiMode;
} on PlatformException {
uiMode = null;
}
if (!mounted) return;
setState(() {
_uiMode = uiMode;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Running on: $_uiMode\n'),
),
),
);
}
}
Getting Started #
This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.