vcs_plugin 0.0.5 copy "vcs_plugin: ^0.0.5" to clipboard
vcs_plugin: ^0.0.5 copied to clipboard

A new Flutter plugin.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:vcs_plugin/vcs_plugin.dart';

FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;

/// IMPORTANT: running the following code on its own won't work as there is setup required for each platform head project.
/// Please download the complete example app from the GitHub repository where all the setup has been done

void main() => runApp(
      MyApp(),
    );

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  VcsPlugin _battery = VcsPlugin();
  Map _batteryState;
  StreamSubscription<Map> _batteryStateSubscription;
  String detail = '';

  @override
  void initState() {
    super.initState();
    initPlatformState();

    _batteryStateSubscription =
        _battery.onBatteryStateChanged.listen((Map state) {
      setState(() {
        print('Sagar ZZZZZZZZZZZZZZZZZZZZZZZZZZZ');
        _batteryState = state;
        print('State : $state');
        print('_batteryState : $_batteryState');
        detail = _batteryState.toString();
      });
    });
  }

  @override
  void dispose() {
    super.dispose();
    print("dispose");
    if (_batteryStateSubscription != null) {
      _batteryStateSubscription.cancel();
    }
  }

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

    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  void callDetails() async {
    await VcsPlugin().setDaySevenDefault;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              Text('Running on: $_platformVersion\n'),
              Text('Scan: $detail'),
              FlatButton(
                  onPressed: () {
                    callDetails();
                  },
                  child: Text("Set Default Method"))
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter plugin.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on vcs_plugin