Sample code for 30+ languages & platforms
Dart

Delete a Task List

See more Google Tasks Examples

Demonstrates how to delete a Google task list.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  // This example requires the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  // Get the previously obtained access token.
  // See Get Google Tasks Access Token.

  final fac = CkFileAccess();
  final String accessToken;
  try {
    accessToken = fac.readEntireTextFile('qa_data/tokens/googleTasks.txt', 'utf-8');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final http = CkHttp();

  http.authToken = accessToken;

  // Delete the task list with this ID:  MDM4MzQ4NTA3NDQwMDUxMzQ2OTQ6OTk5Njk3NjkxNzg4Nzg2NDow
  http.setUrlVar('taskListId', 'MDM4MzQ4NTA3NDQwMDUxMzQ2OTQ6OTk5Njk3NjkxNzg4Nzg2NDow');

  final resp = CkHttpResponse();
  try {
    http.httpNoBody('DELETE', 'https://www.googleapis.com/tasks/v1/users/@me/lists/{\$taskListId}', resp);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  // Show the response body. (empty for success)
  print(resp.bodyStr);

  // Examine the response status code. (204 = success)
  print('response status code: ${resp.statusCode}');
}