voltron_screen_info 0.0.1 copy "voltron_screen_info: ^0.0.1" to clipboard
voltron_screen_info: ^0.0.1 copied to clipboard

Screen Info Plugin for Voltron

example/lib/main.dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:voltron_screen_info/base_screen_info.dart';
import 'package:voltron_screen_info/voltron_screen_info.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  BaseScreenInfo _screenInfo = BaseScreenInfo({});

  @override
  void initState() {
    super.initState();
    initScreenInfo();
  }

  Future<void> initScreenInfo() async {
    var voltronScreenInfoPlugin = VoltronScreenInfoPlugin();
    BaseScreenInfo? screenInfo;
    if (Platform.isAndroid) {
      screenInfo = await voltronScreenInfoPlugin.androidInfo;
    } else if (Platform.isIOS) {
      screenInfo = await voltronScreenInfoPlugin.iosInfo;
    }

    if (!mounted) return;
    setState(() {
      if (screenInfo == null) return;
      _screenInfo = screenInfo;
    });
  }

  Widget _infoTile(String title, String subtitle) {
    return ListTile(
      title: Text(title),
      subtitle: Text(subtitle.isEmpty ? 'Not set' : subtitle),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('VoltronScreenInfo example'),
          elevation: 4,
        ),
        body: ListView(
          children: <Widget>[
            _infoTile('ScreenInfo', _screenInfo.toString()),
          ],
        ),
      ),
    );
  }
}
0
likes
130
pub points
5%
popularity

Publisher

unverified uploader

Screen Info Plugin for Voltron

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on voltron_screen_info