From 34efd164e35d0e3075c6617388a09b1e17b0b126 Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 2 Jan 2025 17:26:49 +0530 Subject: [PATCH] update: use base class on dart/flutter for ping. --- templates/dart/lib/src/client_base.dart.twig | 10 +++++++++- templates/dart/lib/src/client_browser.dart.twig | 8 -------- templates/dart/lib/src/client_io.dart.twig | 8 -------- templates/flutter/lib/src/client_base.dart.twig | 10 +++++++++- templates/flutter/lib/src/client_browser.dart.twig | 8 -------- templates/flutter/lib/src/client_io.dart.twig | 8 -------- 6 files changed, 18 insertions(+), 34 deletions(-) diff --git a/templates/dart/lib/src/client_base.dart.twig b/templates/dart/lib/src/client_base.dart.twig index f3137281d..31a1794ea 100644 --- a/templates/dart/lib/src/client_base.dart.twig +++ b/templates/dart/lib/src/client_base.dart.twig @@ -21,7 +21,15 @@ abstract class ClientBase implements Client { ClientBase addHeader(String key, String value); @override - Future ping(); + Future ping() async { + final String apiPath = '/ping'; + final response = await call( + HttpMethod.get, + path: apiPath, + responseType: ResponseType.plain, + ); + return response.data; + } @override Future call( diff --git a/templates/dart/lib/src/client_browser.dart.twig b/templates/dart/lib/src/client_browser.dart.twig index 41d9860c9..6a0f046fd 100644 --- a/templates/dart/lib/src/client_browser.dart.twig +++ b/templates/dart/lib/src/client_browser.dart.twig @@ -77,14 +77,6 @@ class ClientBrowser extends ClientBase with ClientMixin { return this; } - @override - Future ping() async { - final String apiPath = '/ping'; - final response = await call(HttpMethod.get, path: apiPath, responseType: ResponseType.plain); - - return response.data; - } - @override Future webAuth(Uri url) async { final request = http.Request('GET', url); diff --git a/templates/dart/lib/src/client_io.dart.twig b/templates/dart/lib/src/client_io.dart.twig index 09a3ca6a3..8a51e5979 100644 --- a/templates/dart/lib/src/client_io.dart.twig +++ b/templates/dart/lib/src/client_io.dart.twig @@ -89,14 +89,6 @@ class ClientIO extends ClientBase with ClientMixin { return this; } - @override - Future ping() async { - final String apiPath = '/ping'; - final response = await call(HttpMethod.get, path: apiPath, responseType: ResponseType.plain); - - return response.data; - } - @override Future chunkedUpload({ required String path, diff --git a/templates/flutter/lib/src/client_base.dart.twig b/templates/flutter/lib/src/client_base.dart.twig index 3493c5e66..fd199b359 100644 --- a/templates/flutter/lib/src/client_base.dart.twig +++ b/templates/flutter/lib/src/client_base.dart.twig @@ -24,7 +24,15 @@ abstract class ClientBase implements Client { ClientBase addHeader(String key, String value); @override - Future ping(); + Future ping() async { + final String apiPath = '/ping'; + final response = await call( + HttpMethod.get, + path: apiPath, + responseType: ResponseType.plain, + ); + return response.data; + } @override Future call( diff --git a/templates/flutter/lib/src/client_browser.dart.twig b/templates/flutter/lib/src/client_browser.dart.twig index 22b0d6bc6..e3bffef21 100644 --- a/templates/flutter/lib/src/client_browser.dart.twig +++ b/templates/flutter/lib/src/client_browser.dart.twig @@ -98,14 +98,6 @@ class ClientBrowser extends ClientBase with ClientMixin { return this; } - @override - Future ping() async { - final String apiPath = '/ping'; - final response = await call(HttpMethod.get, path: apiPath, responseType: ResponseType.plain); - - return response.data; - } - Future init() async { final cookieFallback = web.window.localStorage['cookieFallback']; if (cookieFallback != null) { diff --git a/templates/flutter/lib/src/client_io.dart.twig b/templates/flutter/lib/src/client_io.dart.twig index f93ab9ac1..371dd51ee 100644 --- a/templates/flutter/lib/src/client_io.dart.twig +++ b/templates/flutter/lib/src/client_io.dart.twig @@ -130,14 +130,6 @@ class ClientIO extends ClientBase with ClientMixin { return this; } - @override - Future ping() async { - final String apiPath = '/ping'; - final response = await call(HttpMethod.get, path: apiPath, responseType: ResponseType.plain); - - return response.data; - } - Future init() async { if(_initProgress) return; _initProgress = true;