Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,20 @@ name: Publish to pub.dev
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*' # tag-pattern on pub.dev: 'v{{version}}'
- 'v[0-9]+.[0-9]+.[0-9]+' # tag pattern on pub.dev: 'v{{version}'

# Publish using the reusable workflow from dart-lang.
# Publish using custom workflow
jobs:
publish:
permissions:
id-token: write # Required for authentication using OIDC
name: 'Publish to pub.dev'
environment: 'pub.dev'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: 2.19
- name: Install dependencies
run: dart pub get
working-directory: .
- name: Publish - dry run
- name: Test Publish (Dry Run)
run: dart pub publish --dry-run
working-directory: .
# Publishing...
- name: Publish to pub.dev
run: dart pub publish -f
working-directory: .
- name: Publish
run: dart pub publish --force
17 changes: 7 additions & 10 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
include: analysis_options.yaml

analyzer:
exclude: [ build/**, lib/**.freezed.dart, lib/**.g.dart ]
exclude:
- build/**
- lib/**.freezed.dart
- lib/**.g.dart

strong-mode:
implicit-casts: false

errors:
missing_required_param: error
parameter_assignments: error
Expand All @@ -23,8 +26,6 @@ linter:
avoid_relative_lib_imports: true
avoid_renaming_method_parameters: true
avoid_return_types_on_setters: true
avoid_returning_null: true
avoid_returning_null_for_future: true
avoid_returning_null_for_void: true
avoid_returning_this: true
avoid_shadowing_type_parameters: true
Expand All @@ -44,12 +45,9 @@ linter:
file_names: true
hash_and_equals: true
implementation_imports: true
invariant_booleans: true
iterable_contains_unrelated_type: true
join_return_with_assignment: true
library_names: true
library_prefixes: true
list_remove_unrelated_type: true
literal_only_boolean_expressions: true
no_adjacent_strings_in_list: true
no_duplicate_case_values: true
Expand All @@ -65,7 +63,6 @@ linter:
prefer_conditional_assignment: true
# prefer_const_constructors: true
prefer_contains: true
prefer_equal_for_default_values: true
prefer_final_fields: true
prefer_final_locals: true
prefer_generic_function_type_aliases: true
Expand Down Expand Up @@ -96,4 +93,4 @@ linter:
use_function_type_syntax_for_parameters: true
use_rethrow_when_possible: true
valid_regexps: true
void_checks: true
void_checks: true
5 changes: 4 additions & 1 deletion lib/client.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: lines_longer_than_80_chars

import 'dart:async';
import 'dart:convert';

Expand Down Expand Up @@ -57,7 +59,7 @@ class HttpClient extends http.BaseClient {
return fromJson<T, K>(bodyJson);
} else {
if (bodyJson!.containsKey('entries')) {
var previewResponse = stack!.livePreview?.entries;
final previewResponse = stack!.livePreview?.entries;
if (previewResponse != null) {
return fromJson<T, K>(mergeLivePreview(bodyJson, Map.fromEntries(previewResponse)));
}
Expand All @@ -69,6 +71,7 @@ class HttpClient extends http.BaseClient {
}
}

// ignore: always_declare_return_types
mergeLivePreview(Map? bodyJson, Map previewResponse) {}

/// Generic objects as well as List of generic objects
Expand Down
10 changes: 5 additions & 5 deletions lib/src/base_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BaseQuery {
/// ```
///
void addParams(Map parameters) {
if (parameters != null && parameters.isNotEmpty) {
if (parameters.isNotEmpty) {
parameters.forEach((key, value) {
queryParameter[key] = value;
});
Expand All @@ -40,7 +40,7 @@ class BaseQuery {
/// ```
///
void addQuery(Map parameters) {
if (parameters != null && parameters.isNotEmpty) {
if (parameters.isNotEmpty) {
parameters.forEach((key, value) {
parameter[key] = value;
});
Expand Down Expand Up @@ -113,7 +113,7 @@ class BaseQuery {
/// ```
///
void param(String key, String value) {
if (key != null && value != null && key.isNotEmpty && value.isNotEmpty) {
if (key.isNotEmpty && value.isNotEmpty) {
queryParameter[key] = value.toString();
}
}
Expand All @@ -131,7 +131,7 @@ class BaseQuery {
/// ```
///
void query(String key, String value) {
if (key != null && value != null && key.isNotEmpty && value.isNotEmpty) {
if (key.isNotEmpty && value.isNotEmpty) {
parameter[key] = value.toString();
}
}
Expand All @@ -156,7 +156,7 @@ class BaseQuery {
}

void where(String fieldUid, QueryOperation queryOperation) {
if (fieldUid != null && fieldUid.isNotEmpty) {
if (fieldUid.isNotEmpty) {
switch(queryOperation.operationType) {
case QueryOperationType.Equals:
parameter[fieldUid] = queryOperation.value;
Expand Down
17 changes: 8 additions & 9 deletions lib/src/entry_queryable.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: lines_longer_than_80_chars

import 'package:contentstack/constant.dart';
import 'package:contentstack/src/enums/include.dart';
import 'package:contentstack/src/enums/include_type.dart';
Expand All @@ -20,7 +22,7 @@ class EntryQueryable {
/// entry.addParam(key, value);
/// ```
void addParam(String key, String value) {
if (key != null && value != null && key.isNotEmpty && value.isNotEmpty) {
if (key.isNotEmpty && value.isNotEmpty) {
parameter[key] = value.toString();
}
}
Expand All @@ -40,7 +42,7 @@ class EntryQueryable {
/// ```
///
void except(List<String> fieldUid) {
if (fieldUid != null && fieldUid.isNotEmpty) {
if (fieldUid.isNotEmpty) {
final List referenceArray = [];
for (final item in fieldUid) {
referenceArray.add(item);
Expand Down Expand Up @@ -175,8 +177,7 @@ class EntryQueryable {
referenceArray.add(referenceFieldUid);
}

if (includeReferenceField.fieldUidList != null &&
includeReferenceField.fieldUidList.isNotEmpty) {
if (includeReferenceField.fieldUidList.isNotEmpty) {
for (final item in includeReferenceField.fieldUidList) {
referenceArray.add(item);
}
Expand All @@ -185,8 +186,7 @@ class EntryQueryable {
break;
case IncludeType.Only:
final Map<String, dynamic> referenceOnlyParam = <String, dynamic>{};
if (includeReferenceField.fieldUidList != null &&
includeReferenceField.fieldUidList.isNotEmpty) {
if (includeReferenceField.fieldUidList.isNotEmpty) {
for (final item in includeReferenceField.fieldUidList) {
referenceArray.add(item);
}
Expand All @@ -197,8 +197,7 @@ class EntryQueryable {
break;
case IncludeType.Except:
final Map<String, dynamic> referenceOnlyParam = <String, dynamic>{};
if (includeReferenceField.fieldUidList != null &&
includeReferenceField.fieldUidList.isNotEmpty) {
if (includeReferenceField.fieldUidList.isNotEmpty) {
for (final item in includeReferenceField.fieldUidList) {
referenceArray.add(item);
}
Expand Down Expand Up @@ -262,7 +261,7 @@ class EntryQueryable {
/// ```
///
void only(List<String> fieldUid) {
if (fieldUid != null && fieldUid.isNotEmpty) {
if (fieldUid.isNotEmpty) {
final List referenceArray = [];
for (final item in fieldUid) {
referenceArray.add(item);
Expand Down
1 change: 1 addition & 0 deletions lib/src/enums/include.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:contentstack/src/enums/include_type.dart';

// ignore: lines_longer_than_80_chars
// set the name to IncludeClass, as the name Include was conflicting with reference.dart enum in entry_queryable.dart
// it also has an element named Include
class IncludeClass {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/enums/operator.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:contentstack/src/query.dart';
import 'package:contentstack/src/enums/operator_type.dart';
import 'package:contentstack/src/query.dart';

class QueryOperator {
final QueryOperatorType operatorType;
Expand Down
89 changes: 40 additions & 49 deletions lib/src/image_transform.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

// ignore_for_file: lines_longer_than_80_chars, cascade_invocations

import 'dart:async';
import 'dart:convert';

Expand Down Expand Up @@ -282,13 +285,9 @@ class ImageTransformation {
/// cropRatio as prams else it takes crop params and comas
/// separated width & height
final cropLRBL = [];
if (width != null) {
cropLRBL.add(width);
}
if (height != null) {
cropLRBL.add(width);
cropLRBL.add(height);
}
if (region != null) {
if (region != null) {
cropLRBL.add(region);
}
if (offset != null) {
Expand Down Expand Up @@ -359,25 +358,19 @@ class ImageTransformation {
///

void fit(double width, double height, Fit fit) {
if (width != null) {
query.append('width', width.toString());
}
if (height != null) {
query.append('width', width.toString());
query.append('height', height.toString());
}
if (fit != null) {
//enum Fit { bounds, crop }

switch(fit) {
case Fit.Bounds:
query.append('fit', 'bounds');
break;
case Fit.Crop:
query.append('fit', 'crop');
break;
}
switch(fit) {
case Fit.Bounds:
query.append('fit', 'bounds');
break;
case Fit.Crop:
query.append('fit', 'crop');
break;
}
}
}

/// The frame parameter fetches the first frame from an animated GIF
/// (Graphics Interchange Format) file that comprises
Expand Down Expand Up @@ -429,35 +422,33 @@ class ImageTransformation {
// degrees90TowardsRight = '6';
// horizontallyAndRotate90DegreesRight = '7';
// rotate90DegreesLeft = '8';
if (orient != null) {
switch(orient) {
case Orientation.ToDefault:
query.append('orient', 1);
break;
case Orientation.Horizontally:
query.append('orient', 2);
break;
case Orientation.HorizontallyAndVertically:
query.append('orient', 3);
break;
case Orientation.Vertically:
query.append('orient', 4);
break;
case Orientation.HorizontallyAndRotate90DegreeLeft:
query.append('orient', 5);
break;
case Orientation.Degrees90TowardsRight:
query.append('orient', 6);
break;
case Orientation.HorizontallyAndRotate90DegreesRight:
query.append('orient', 7);
break;
case Orientation.Rotate90DegreesLeft:
query.append('orient', 8);
break;
}
switch(orient) {
case Orientation.ToDefault:
query.append('orient', 1);
break;
case Orientation.Horizontally:
query.append('orient', 2);
break;
case Orientation.HorizontallyAndVertically:
query.append('orient', 3);
break;
case Orientation.Vertically:
query.append('orient', 4);
break;
case Orientation.HorizontallyAndRotate90DegreeLeft:
query.append('orient', 5);
break;
case Orientation.Degrees90TowardsRight:
query.append('orient', 6);
break;
case Orientation.HorizontallyAndRotate90DegreesRight:
query.append('orient', 7);
break;
case Orientation.Rotate90DegreesLeft:
query.append('orient', 8);
break;
}
}
}

/// The overlay parameter allows you to put one image on top of another.
/// You need to specify the relative URL of the image as
Expand Down
2 changes: 1 addition & 1 deletion lib/src/query_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class URLQueryParams {

String toUrl(String urls) {
String updatedUrl;
if (urls != null && urls.isNotEmpty && urls.endsWith('/')) {
if (urls.isNotEmpty && urls.endsWith('/')) {
updatedUrl = urls.substring(0, urls.length - 1);
} else {
updatedUrl = urls;
Expand Down
Loading