vutil 0.0.10 copy "vutil: ^0.0.10" to clipboard
vutil: ^0.0.10 copied to clipboard

A new flutter plugin project.

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String _key = 'test';
  String _value = 'test';
  String _defaultValue = 'defaultValue';

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

  // 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 VUtil.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform 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(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(children: [
            Text('Running on: $_platformVersion\n'),
            TextField(
              controller: TextEditingController(text: _key),
              onChanged: (val) {
                setState(() {
                  _key = val;
                });
              },
            ),
            TextField(
              controller: TextEditingController(text: _value),
              onChanged: (val) {
                setState(() {
                  _value = val;
                });
              },
            ),
            TextField(
              controller: TextEditingController(text: _defaultValue),
              onChanged: (val) {
                setState(() {
                  _defaultValue = val;
                });
              },
            ),
            FlatButton(
              onPressed: () {
                print(VUtil.setDataToSettings(_key, _value));
              },
              child: Text('set'),
            ),
            FlatButton(
              onPressed: () {
                print(VUtil.getDataToSettings(_key, _defaultValue));
              },
              child: Text('get'),
            ),
            TextField(obscureText: true,)
          ]),
        ),
      ),
    );
  }
}
1
likes
100
pub points
0%
popularity

Publisher

unverified uploader

A new flutter plugin project.

Homepage

Documentation

API reference

License

GPL-3.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on vutil