package_info 0.1.0 copy "package_info: ^0.1.0" to clipboard
package_info: ^0.1.0 copied to clipboard

discontinued
outdatedDart 1 only

Plugin for querying information about the application package.

example/lib/main.dart

// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:package_info/package_info.dart' as package_info;

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String _version = 'Unknown';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<Null> initPackageState() async {
    String version;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      version = await package_info.version;
    } on PlatformException {
      version = 'Failed to get version.';
    }

    // 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(() {
      _version = version;
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: const Text('Plugin example app'),
      ),
      body: new Center(child: new Text('App version is: $_version\n')),
    );
  }
}
929
likes
0
pub points
99%
popularity

Publisher

verified publisherflutter.dev

Plugin for querying information about the application package.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on package_info