-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sqflite] Update sqflite to 2.3.0 (#614)
- Loading branch information
Showing
26 changed files
with
965 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
# Until there are meta linter rules, each desired lint must be explicitly enabled. | ||
# See: https://github.com/dart-lang/linter/issues/288 | ||
# | ||
# For a list of lints, see: http://dart-lang.github.io/linter/lints/ | ||
# See the configuration guide for more | ||
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer | ||
# | ||
# NOTE: Please keep this file in sync with | ||
# https://github.com/flutter/flutter/blob/master/analysis_options.yaml | ||
|
||
analyzer: | ||
language: | ||
strict-casts: true | ||
strict-inference: true | ||
|
||
errors: | ||
# treat missing required parameters as a warning (not a hint) | ||
missing_required_param: warning | ||
# treat missing returns as a warning (not a hint) | ||
missing_return: warning | ||
# allow having TODOs in the code | ||
todo: ignore | ||
# Ignore errors like | ||
# 'super_goes_last' is a deprecated lint rule and should not be used • included_file_warning | ||
included_file_warning: ignore | ||
|
||
linter: | ||
rules: | ||
- always_declare_return_types | ||
- avoid_dynamic_calls | ||
- avoid_empty_else | ||
- avoid_relative_lib_imports | ||
- avoid_shadowing_type_parameters | ||
- avoid_slow_async_io | ||
- avoid_types_as_parameter_names | ||
- await_only_futures | ||
- camel_case_extensions | ||
- camel_case_types | ||
- cancel_subscriptions | ||
- curly_braces_in_flow_control_structures | ||
- directives_ordering | ||
- empty_catches | ||
- hash_and_equals | ||
- collection_methods_unrelated_type | ||
- no_adjacent_strings_in_list | ||
- no_duplicate_case_values | ||
- non_constant_identifier_names | ||
- omit_local_variable_types | ||
- package_api_docs | ||
- package_prefixed_library_names | ||
- prefer_generic_function_type_aliases | ||
- prefer_is_empty | ||
- prefer_is_not_empty | ||
- prefer_iterable_whereType | ||
- prefer_single_quotes | ||
- prefer_typing_uninitialized_variables | ||
- sort_child_properties_last | ||
- test_types_in_equals | ||
- throw_in_finally | ||
- unawaited_futures | ||
- unnecessary_null_aware_assignments | ||
- unnecessary_statements | ||
- unrelated_type_equality_checks | ||
- unsafe_html | ||
- valid_regexps | ||
|
||
- constant_identifier_names | ||
- control_flow_in_finally | ||
- empty_statements | ||
- implementation_imports | ||
- overridden_fields | ||
- package_names | ||
- prefer_const_constructors | ||
- prefer_initializing_formals | ||
- prefer_void_to_null | ||
# | ||
- always_require_non_null_named_parameters | ||
- annotate_overrides | ||
- avoid_init_to_null | ||
- avoid_null_checks_in_equality_operators | ||
- avoid_return_types_on_setters | ||
- empty_constructor_bodies | ||
- library_names | ||
- library_prefixes | ||
- prefer_adjacent_string_concatenation | ||
- prefer_collection_literals | ||
- prefer_contains | ||
- slash_for_doc_comments | ||
- type_init_formals | ||
- unnecessary_const | ||
- unnecessary_new | ||
- unnecessary_null_in_if_null_operators | ||
- use_rethrow_when_possible | ||
# === doc rules === | ||
- public_member_api_docs | ||
# | ||
# - prefer_final_locals | ||
- sort_constructors_first | ||
- sort_unnamed_constructors_first | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,2 @@ | ||
import 'dart:async'; | ||
import 'dart:io'; | ||
|
||
import 'package:path/path.dart'; | ||
import 'package:sqflite/sqflite.dart'; | ||
|
||
/// delete the db, create the folder and returns its path | ||
Future<String> initDeleteDb(String dbName) async { | ||
final databasePath = await getDatabasesPath(); | ||
final path = join(databasePath, dbName); | ||
|
||
// make sure the folder exists | ||
// ignore: avoid_slow_async_io | ||
if (await Directory(dirname(path)).exists()) { | ||
await deleteDatabase(path); | ||
} else { | ||
try { | ||
await Directory(dirname(path)).create(recursive: true); | ||
} catch (e) { | ||
// ignore: avoid_print | ||
print(e); | ||
} | ||
} | ||
return path; | ||
} | ||
export 'database_impl.dart'; | ||
export 'database_io.dart' if (dart.library.html) 'database_web.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import 'dart:typed_data'; | ||
|
||
import 'package:sqflite/sqflite.dart'; | ||
|
||
import 'database.dart'; | ||
|
||
/// Custom platform Handler, need to handle Web or IO differently or from a | ||
/// custom app | ||
abstract class PlatformHandler { | ||
/// delete the db, create the folder and returns its path | ||
Future<String> initDeleteDb(String dbName) async { | ||
if (await databaseExists(dbName)) { | ||
await deleteDatabase(dbName); | ||
} | ||
return dbName; | ||
} | ||
|
||
/// Write the db file directly to the file system | ||
Future<void> writeFileAsBytes(String path, List<int> bytes, | ||
{bool flush = false}); | ||
|
||
/// Read a file as bytes | ||
Future<Uint8List> readFileAsBytes(String path); | ||
|
||
/// Write a file as a string | ||
Future<void> writeFileAsString(String path, String text, | ||
{bool flush = false}); | ||
|
||
/// Read a file as a string | ||
Future<String> readFileAsString(String path); | ||
|
||
/// Check if a path exists. | ||
Future<bool> pathExists(String path); | ||
|
||
/// Recursively create a directory | ||
Future<void> createDirectory(String path); | ||
|
||
/// Recursively delete a directory | ||
Future<void> deleteDirectory(String path); | ||
|
||
/// Check if a directory exists | ||
Future<bool> existsDirectory(String path); | ||
} | ||
|
||
// --- | ||
// Compat, to keep the example page as is | ||
// --- | ||
|
||
/// delete the db, create the folder and returnes its path | ||
Future<String> initDeleteDb(String dbName) => | ||
platformHandler.initDeleteDb(dbName); | ||
|
||
/// Write the db file directly to the file system | ||
Future<void> writeFileAsBytes(String path, List<int> bytes, | ||
{bool flush = false}) => | ||
platformHandler.writeFileAsBytes(path, bytes, flush: flush); | ||
|
||
/// Read a file as bytes | ||
Future<Uint8List> readFileAsBytes(String path) => | ||
platformHandler.readFileAsBytes(path); | ||
|
||
/// Write a file as a string | ||
Future<void> writeFileAsString(String path, String text, | ||
{bool flush = false}) => | ||
platformHandler.writeFileAsString(path, text, flush: flush); | ||
|
||
/// Read a file as a string | ||
Future<String> readFileAsString(String path) => | ||
platformHandler.readFileAsString(path); | ||
|
||
/// Check if a path exists. | ||
Future<bool> pathExists(String path) => platformHandler.pathExists(path); | ||
|
||
/// Recursively create a directory | ||
Future<void> createDirectory(String path) => | ||
platformHandler.createDirectory(path); | ||
|
||
/// Recursively delete a directory | ||
Future<void> deleteDirectory(String path) => | ||
platformHandler.deleteDirectory(path); | ||
|
||
/// Check if a directory exists | ||
Future<bool> existsDirectory(String path) => | ||
platformHandler.existsDirectory(path); | ||
|
||
PlatformHandler? _platformHandler; | ||
|
||
/// Platform handler (can be overriden, needed for the web test app) | ||
PlatformHandler get platformHandler => _platformHandler ??= platformHandlerIo; | ||
set platformHandler(PlatformHandler handler) => _platformHandler = handler; |
Oops, something went wrong.