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

dexcom for Flutter allows you to use Dexcom Share to get your Dexcom CGM data, or anybody else's, to run your application. Includes time, reading, and trend.

example/example.md

Get Dexcom data (also sets up session)

Future<Map<String, dynamic>?> getDexcomData(username, password) async {
    Map settings = await getAllSettings();
    var dexcom = Dexcom(username], settings[password]);
    List<dynamic>? response;

    if (username == "" || password == "") {
        Navigator.pushReplacement(
            context,
            MaterialPageRoute(builder: (context) => LoginPage()), // You can define LoginPage somewhere else in your code
        );
        return {};
    }
  
    try {
        response = await dexcom.getGlucoseReadings(maxCount: 2);
        print("Read data with dexcom: $dexcom");
    } catch (e) {
        showAlertDialogue(context, "Login error:", "An error occurred while logging in: $e: Did you enter the correct username and password? If not, go to Settings > Log In With Dexcom."); // You can define showAlertDialogue somewhere else in your code
    }

    if (response != null) {
        print(response);

        String wtString = response[0]['ST'];
        RegExp regExp = RegExp(r'Date\((\d+)\)');
        Match? match = regExp.firstMatch(wtString);
        
        if (match != null) {
            int milliseconds = int.parse(match.group(1)!);
            int seconds = milliseconds ~/ 1000;
            print('Time in seconds: $seconds');
            readingTime = seconds;
        } else {
            print('Invalid date format');
        }
        
        Map<String, dynamic> data = {
            "bg": response[0]["Value"],
            "trend": getTrend(response[0]["Trend"]),
            "previousreading": response[1]["Value"],
            "readingtime": readingTime // in seconds, you can edit the function above to get milliseconds
        };

        print(data);
        return data;
    } else {
        return {"error": "response is null"};
    }
}

Verify login (creates Dexcom session and gets data to verify that the user is fully logged in)

Future<void> verifyLogin(username, password) async {
    var dexcom = Dexcom(username, password);
  
    try {
        await dexcom.verifyLogin(username, password);
        print("Verified login with dexcom: $dexcom");
        Navigator.pop(context);
    } catch (e) {
        showAlertDialogue(context, "Login error:", "An error occurred while logging in: $e (did you enter the correct username and password?)"); // You can define showAlertDialogue somewhere else in your code
    }
}
0
likes
0
points
310
downloads

Publisher

unverified uploader

Weekly Downloads

dexcom for Flutter allows you to use Dexcom Share to get your Dexcom CGM data, or anybody else's, to run your application. Includes time, reading, and trend.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_test, http, intl, uuid

More

Packages that depend on dexcom