Skip to content

Commit

Permalink
Merge branch 'master' into video_player/prevent_screensaver
Browse files Browse the repository at this point in the history
  • Loading branch information
hyue7 authored Sep 7, 2023
2 parents 6b5569c + 8ed18ee commit 165d76c
Show file tree
Hide file tree
Showing 32 changed files with 1,025 additions and 274 deletions.
4 changes: 3 additions & 1 deletion packages/flutter_secure_storage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## NEXT
## 0.1.1

* Update flutter_secure_storage to 9.0.0.
* Update example app.
* Increase the minimum Flutter version to 3.3.

## 0.1.0
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter_secure_storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ This package is not an _endorsed_ implementation of `flutter_secure_storage`. Th

```yaml
dependencies:
flutter_secure_storage: ^6.0.0
flutter_secure_storage_tizen: ^0.1.0
flutter_secure_storage: ^9.0.0
flutter_secure_storage_tizen: ^0.1.1
```
Then you can import `flutter_secure_storage` in your Dart code:
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_secure_storage/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:lint/analysis_options_package.yaml
include: package:lint/package.yaml

linter:
# The lint rules applied to this project can be customized in the
Expand Down
54 changes: 51 additions & 3 deletions packages/flutter_secure_storage/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ItemsWidget extends StatefulWidget {

enum _Actions { deleteAll }

enum _ItemActions { delete, edit, containsKey }
enum _ItemActions { delete, edit, containsKey, read }

class ItemsWidgetState extends State<ItemsWidget> {
final _storage = const FlutterSecureStorage();
Expand Down Expand Up @@ -153,6 +153,13 @@ class ItemsWidgetState extends State<ItemsWidget> {
key: Key('contains_row_$index'),
),
),
PopupMenuItem(
value: _ItemActions.read,
child: Text(
'Read',
key: Key('contains_row_$index'),
),
),
],
),
title: Text(
Expand Down Expand Up @@ -202,17 +209,58 @@ class ItemsWidgetState extends State<ItemsWidget> {
}
break;
case _ItemActions.containsKey:
final result = await _storage.containsKey(key: item.key);
if (!context.mounted) return;
final key = await _displayTextInputDialog(context, item.key);
final result = await _storage.containsKey(key: key);
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Contains Key: $result, key checked: $key'),
backgroundColor: result ? Colors.green : Colors.red,
),
);
break;
case _ItemActions.read:
if (!context.mounted) return;
final key = await _displayTextInputDialog(context, item.key);
final result =
await _storage.read(key: key, aOptions: _getAndroidOptions());
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Contains Key: $result'),
content: Text('value: $result'),
),
);
break;
}
}

Future<String> _displayTextInputDialog(
BuildContext context,
String key,
) async {
final controller = TextEditingController();
controller.text = key;
await showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Check if key exists'),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('OK'),
),
],
content: TextField(
controller: controller,
),
);
},
);
return controller.text;
}

String _randomValue() {
final rand = Random();
final codeUnits = List.generate(20, (index) {
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_secure_storage/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_secure_storage: ^6.0.0
flutter_secure_storage: ^9.0.0
flutter_secure_storage_tizen:
path: ../

Expand Down
4 changes: 2 additions & 2 deletions packages/flutter_secure_storage/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_secure_storage_tizen
description: Tizen implementation of the flutter_secure_storage plugin.
homepage: https://github.com/flutter-tizen/plugins
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/flutter_secure_storage
version: 0.1.0
version: 0.1.1

environment:
sdk: ">=2.18.0 <4.0.0"
Expand All @@ -18,7 +18,7 @@ flutter:
dependencies:
flutter:
sdk: flutter
flutter_secure_storage_platform_interface: ^1.0.0
flutter_secure_storage_platform_interface: ^1.0.1

dev_dependencies:
flutter_test:
Expand Down
4 changes: 3 additions & 1 deletion packages/sqflite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## NEXT
## 0.1.3

* Update sqflite to 2.3.0.
* Increase the minimum Flutter version to 3.3.
* Increase the minimum SDK version to 3.0.0.

## 0.1.2

Expand Down
4 changes: 2 additions & 2 deletions packages/sqflite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ This package is not an _endorsed_ implementation of `sqflite`. Therefore, you ha

```yaml
dependencies:
sqflite: ^2.2.8
sqflite_tizen: ^0.1.2
sqflite: ^2.3.0
sqflite_tizen: ^0.1.3
```
Then you can import `sqflite` in your Dart code:
Expand Down
4 changes: 4 additions & 0 deletions packages/sqflite/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ include: package:flutter_lints/flutter.yaml
# 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
Expand Down
102 changes: 102 additions & 0 deletions packages/sqflite/example/analysis_options.yaml
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

49 changes: 45 additions & 4 deletions packages/sqflite/example/lib/batch_test_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class BatchTestPage extends TestPage {
BatchTestPage({Key? key}) : super('Batch tests', key: key) {
test('BatchQuery', () async {
// await Sqflite.devSetDebugModeOn();
final path = await initDeleteDb('batch.db');
final path = await initDeleteDb('batch_query.db');
final db = await openDatabase(path);

// empty batch
Expand Down Expand Up @@ -42,15 +42,15 @@ class BatchTestPage extends TestPage {
await db.close();
});
test('Batch', () async {
// await Sqflite.devSetDebugModeOn();
// await databaseFactory.devSetDebugModeOn();
final path = await initDeleteDb('batch.db');
final db = await openDatabase(path);

// empty batch
var batch = db.batch();
var results = await batch.commit();
expect(results.length, 0);
expect(results, []);
expect(results, isEmpty);

// one create table
batch = db.batch();
Expand Down Expand Up @@ -112,7 +112,7 @@ class BatchTestPage extends TestPage {
where: 'name = ?', whereArgs: <String>['item']);
batch.delete('Test', where: 'name = ?', whereArgs: ['item']);
results = await batch.commit(noResult: true);
expect(results, []);
expect(results, isEmpty);

await db.close();
});
Expand All @@ -139,6 +139,47 @@ class BatchTestPage extends TestPage {
await db.close();
});

test('Apply in database', () async {
// await Sqflite.devSetDebugModeOn();
final path = await initDeleteDb('apply_in_database.db');
final db = await openDatabase(path);

late List<Object?> results;

final batch1 = db.batch();
batch1.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)');
final batch2 = db.batch();
batch2.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item1']);
results = await batch1.apply();
expect(results, [null]);

results = await batch2.apply();
expect(results, [1]);
await db.close();
});

test('Apply in transaction', () async {
// await Sqflite.devSetDebugModeOn();
final path = await initDeleteDb('apply_in_transaction.db');
final db = await openDatabase(path);

late List<Object?> results;

await db.transaction((txn) async {
final batch1 = txn.batch();
batch1.execute('CREATE TABLE Test (id INTEGER PRIMARY KEY, name TEXT)');
final batch2 = txn.batch();
batch2.rawInsert('INSERT INTO Test (name) VALUES (?)', ['item1']);
results = await batch1.apply();
expect(results, [null]);

results = await batch2.apply();
expect(results, [1]);
});

await db.close();
});

test('Batch continue on error', () async {
// await Sqflite.devSetDebugModeOn();
final path = await initDeleteDb('batch_continue_on_error.db');
Expand Down
27 changes: 2 additions & 25 deletions packages/sqflite/example/lib/database/database.dart
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';
Loading

0 comments on commit 165d76c

Please sign in to comment.