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

outdated

Redirect your Flutter application to the Native WiFi Settings.

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  bool _wifiSettingsWasOpened = false;

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    bool wifiSettingsWasOpened;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      wifiSettingsWasOpened = await Wifluttings.openNativeWifiSettings;
    } on PlatformException {
      wifiSettingsWasOpened = false;
    }

    // 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(() {
      _wifiSettingsWasOpened = wifiSettingsWasOpened;
    });
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Wifluttings example app'),
        ),
        body: SizedBox.expand(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              new Text('Wifi settings was Opened?: $_wifiSettingsWasOpened\n'),
              RaisedButton(
                child: Text("open wifi settings".toUpperCase(),),
                color: Colors.blue,
                textColor: Colors.white,
                elevation: 4.0,
                onPressed: this.initPlatformState,
              )
            ],
          )
        )
      ),
    );
  }
}
1
likes
0
pub points
10%
popularity

Publisher

unverified uploader

Redirect your Flutter application to the Native WiFi Settings.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on wifluttings