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

Flutter plugin for getting android device screen height.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:screen_dimension/screen_dimension.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  double _height = 0;

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> _getHeight() async {
    double height;
    try {
      height = await ScreenDimension.getHeight;
    } on PlatformException {
      height = 0;
    }

    if (!mounted) return;

    setState(() {
      _height = height;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Real Device Screen Dimensions'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Screen Height: $_height\n',style: TextStyle(fontSize: 30,fontWeight: FontWeight.w600),),
              SizedBox(
                height: 100.0,
              ),
              RaisedButton(
                child: Text("Get Height",style: TextStyle(fontSize: 18)),
                color: Colors.blue,
                onPressed: () async{
                  await _getHeight();
                },
              )
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

Flutter plugin for getting android device screen height.

Repository (GitHub)
View/report issues

License

BSD-2-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on screen_dimension