device_type 0.0.3 device_type: ^0.0.3 copied to clipboard
A new Flutter plugin used to determine whether the device is a Phone, Phablet, Tablet, or a Larger Device like a Desktop.
import 'package:device_type/device_type.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late String deviceType;
@override
void initState() {
super.initState();
}
String _getDeviceType(BuildContext context) {
return DeviceType.getDeviceType(context);
}
@override
Widget build(BuildContext context) {
deviceType = _getDeviceType(context);
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin Device Type'),
),
body: Center(
child: Text('Running on: $deviceType\n'),
),
),
);
}
}