mirrored_repositories/awesome-flutter/examples/plugins/packages/connectivity/connectivity_platform_interface/lib
// Copyright 2013 The Flutter 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 'package:connectivity_platform_interface/connectivity_platform_interface.dart';

/// Convert a String to a ConnectivityResult value.
ConnectivityResult parseConnectivityResult(String state) {
  switch (state) {
    case 'wifi':
      return ConnectivityResult.wifi;
    case 'mobile':
      return ConnectivityResult.mobile;
    case 'none':
    default:
      return ConnectivityResult.none;
  }
}

/// Convert a String to a LocationAuthorizationStatus value.
LocationAuthorizationStatus parseLocationAuthorizationStatus(String result) {
  switch (result) {
    case 'notDetermined':
      return LocationAuthorizationStatus.notDetermined;
    case 'restricted':
      return LocationAuthorizationStatus.restricted;
    case 'denied':
      return LocationAuthorizationStatus.denied;
    case 'authorizedAlways':
      return LocationAuthorizationStatus.authorizedAlways;
    case 'authorizedWhenInUse':
      return LocationAuthorizationStatus.authorizedWhenInUse;
    default:
      return LocationAuthorizationStatus.unknown;
  }
}
