use_location 0.0.4 copy "use_location: ^0.0.4" to clipboard
use_location: ^0.0.4 copied to clipboard

A new flutter plugin project.

example/lib/main.dart

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

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

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

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Use Location Plugin'),
        ),
        body: Center(
          child: Main(),
        ),
      ),
    );
  }
}

class Main extends StatefulWidget {
  @override
  _MainState createState() => _MainState();
}

class _MainState extends State<Main> {
  UseLocationStatus status;

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Text("status: '$status'"),
        SizedBox(height: 20),
        RaisedButton(
          child: Text('useLocation()'),
          onPressed: () async {
            setState(() {
              status = null;
            });
            var value = await UseLocation.useLocation(context);
            setState(() {
              status = value;
            });
          },
        ),
      ],
    );
  }
}

class YesNoDialog extends StatelessWidget {
  final String message;

  const YesNoDialog({Key key, @required this.message}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      content: Text(message, textAlign: TextAlign.center),
      actions: <Widget>[
        SimpleDialogOption(
          child: Text(
            "NOPE",
            style: TextStyle(color: Colors.red),
          ),
          onPressed: () {
            Navigator.of(context).pop(false);
          },
        ),
        SimpleDialogOption(
          child: Text(
            "OKAY",
            style: TextStyle(color: Colors.blue),
          ),
          onPressed: () {
            Navigator.of(context).pop(true);
          },
        )
      ],
    );
  }
}

Future<bool> showYesNoDialog(BuildContext context, String message) async {
  var choice = await showDialog(
    context: context,
    builder: (context) {
      return YesNoDialog(message: message);
    },
  );

  return choice ?? false;
}
1
likes
15
pub points
43%
popularity

Publisher

unverified uploader

A new flutter plugin project.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, plugin_scaffold

More

Packages that depend on use_location