From cb1c31ed15c65e788facb025917c7686a0f456ce Mon Sep 17 00:00:00 2001 From: Stephan Veenstra Date: Mon, 3 Jul 2023 14:36:09 +0200 Subject: [PATCH 1/8] Add TaskStatus.open as status when creating a new task --- example/lib/main.dart | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 8ebd498e..cd932ab4 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -6,9 +6,7 @@ import 'package:flutter/material.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - final database = await $FloorFlutterDatabase - .databaseBuilder('flutter_database.db') - .build(); + final database = await $FloorFlutterDatabase.databaseBuilder('flutter_database.db').build(); final dao = database.taskDao; runApp(FloorApp(dao)); @@ -65,8 +63,7 @@ class TasksWidgetState extends State { PopupMenuButton( itemBuilder: (context) { return List.generate( - TaskStatus.values.length + - 1, //Uses increment to handle All types + TaskStatus.values.length + 1, //Uses increment to handle All types (index) { return PopupMenuItem( value: index, @@ -116,9 +113,7 @@ class TasksListView extends StatelessWidget { Widget build(BuildContext context) { return Expanded( child: StreamBuilder>( - stream: selectedType == null - ? dao.findAllTasksAsStream() - : dao.findAllTasksByStatusAsStream(selectedType!), + stream: selectedType == null ? dao.findAllTasksAsStream() : dao.findAllTasksByStatusAsStream(selectedType!), builder: (_, snapshot) { if (!snapshot.hasData) return Container(); @@ -190,10 +185,8 @@ class TaskListCell extends StatelessWidget { break; case DismissDirection.startToEnd: final tasksLength = TaskStatus.values.length; - final nextIndex = - (tasksLength + task.statusIndex + 1) % tasksLength; - final taskCopy = - task.copyWith(status: TaskStatus.values[nextIndex]); + final nextIndex = (tasksLength + task.statusIndex + 1) % tasksLength; + final taskCopy = task.copyWith(status: TaskStatus.values[nextIndex]); await dao.updateTask(taskCopy); statusMessage = 'Updated task status by: ${taskCopy.statusTitle}'; break; @@ -264,7 +257,11 @@ class TasksTextField extends StatelessWidget { if (message.trim().isEmpty) { _textEditingController.clear(); } else { - final task = Task.optional(message: message, type: TaskType.task); + final task = Task.optional( + message: message, + type: TaskType.task, + status: TaskStatus.open, + ); await dao.insertTask(task); _textEditingController.clear(); } From 37719f2413a474c070de3a6ceafe389ab83f8351 Mon Sep 17 00:00:00 2001 From: Stephan Veenstra Date: Mon, 3 Jul 2023 15:20:29 +0200 Subject: [PATCH 2/8] Use line length 80 --- example/lib/main.dart | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index cd932ab4..5d689966 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -6,7 +6,9 @@ import 'package:flutter/material.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - final database = await $FloorFlutterDatabase.databaseBuilder('flutter_database.db').build(); + final database = await $FloorFlutterDatabase + .databaseBuilder('flutter_database.db') + .build(); final dao = database.taskDao; runApp(FloorApp(dao)); @@ -63,7 +65,8 @@ class TasksWidgetState extends State { PopupMenuButton( itemBuilder: (context) { return List.generate( - TaskStatus.values.length + 1, //Uses increment to handle All types + TaskStatus.values.length + + 1, //Uses increment to handle All types (index) { return PopupMenuItem( value: index, @@ -113,7 +116,9 @@ class TasksListView extends StatelessWidget { Widget build(BuildContext context) { return Expanded( child: StreamBuilder>( - stream: selectedType == null ? dao.findAllTasksAsStream() : dao.findAllTasksByStatusAsStream(selectedType!), + stream: selectedType == null + ? dao.findAllTasksAsStream() + : dao.findAllTasksByStatusAsStream(selectedType!), builder: (_, snapshot) { if (!snapshot.hasData) return Container(); @@ -185,8 +190,10 @@ class TaskListCell extends StatelessWidget { break; case DismissDirection.startToEnd: final tasksLength = TaskStatus.values.length; - final nextIndex = (tasksLength + task.statusIndex + 1) % tasksLength; - final taskCopy = task.copyWith(status: TaskStatus.values[nextIndex]); + final nextIndex = + (tasksLength + task.statusIndex + 1) % tasksLength; + final taskCopy = + task.copyWith(status: TaskStatus.values[nextIndex]); await dao.updateTask(taskCopy); statusMessage = 'Updated task status by: ${taskCopy.statusTitle}'; break; From 1588b9776b93a0054d7781add397dec42b201d65 Mon Sep 17 00:00:00 2001 From: Stephan Veenstra Date: Tue, 18 Jul 2023 16:55:54 +0200 Subject: [PATCH 3/8] Support uncategorized in example --- example/analysis_options.yaml | 1 + example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Podfile | 63 +++++-------------- example/ios/Podfile.lock | 31 +++++++++ example/ios/Runner.xcodeproj/project.pbxproj | 46 ++++++-------- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- example/ios/Runner/Info.plist | 4 ++ example/lib/database.g.dart | 17 +++++ example/lib/main.dart | 62 +++++++++++++----- example/lib/task.dart | 2 +- example/lib/task_dao.dart | 3 + example/pubspec.lock | 34 +++++++--- example/pubspec.yaml | 1 + 13 files changed, 165 insertions(+), 103 deletions(-) create mode 100644 example/analysis_options.yaml create mode 100644 example/ios/Podfile.lock diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 00000000..a3be6b82 --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml \ No newline at end of file diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9367d483..9625e105 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 11.0 diff --git a/example/ios/Podfile b/example/ios/Podfile index d077b08b..d207307f 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' @@ -10,60 +10,29 @@ project 'Runner', { 'Release' => :release, } -def parse_KV_file(file, separator='=') - file_abs_path = File.expand_path(file) - if !File.exists? file_abs_path - return []; +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" end - pods_ary = [] - skip_line_start_symbols = ["#", "/"] - File.foreach(file_abs_path) { |line| - next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } - plugin = line.split(pattern=separator) - if plugin.length == 2 - podname = plugin[0].strip() - path = plugin[1].strip() - podpath = File.expand_path("#{path}", file_abs_path) - pods_ary.push({:name => podname, :path => podpath}); - else - puts "Invalid plugin specification: #{line}" - end - } - return pods_ary + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" end -target 'Runner' do - # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock - # referring to absolute paths on developers' machines. - system('rm -rf .symlinks') - system('mkdir -p .symlinks/plugins') +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - # Flutter Pods - generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig') - if generated_xcode_build_settings.empty? - puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." - end - generated_xcode_build_settings.map { |p| - if p[:name] == 'FLUTTER_FRAMEWORK_DIR' - symlink = File.join('.symlinks', 'flutter') - File.symlink(File.dirname(p[:path]), symlink) - pod 'Flutter', :path => File.join(symlink, File.basename(p[:path])) - end - } +flutter_ios_podfile_setup - # Plugin Pods - plugin_pods = parse_KV_file('../.flutter-plugins') - plugin_pods.map { |p| - symlink = File.join('.symlinks', 'plugins', p[:name]) - File.symlink(p[:path], symlink) - pod p[:name], :path => File.join(symlink, 'ios') - } +target 'Runner' do + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) end post_install do |installer| installer.pods_project.targets.each do |target| - target.build_configurations.each do |config| - config.build_settings['ENABLE_BITCODE'] = 'NO' - end + flutter_additional_ios_build_settings(target) end end diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock new file mode 100644 index 00000000..f88a1b1d --- /dev/null +++ b/example/ios/Podfile.lock @@ -0,0 +1,31 @@ +PODS: + - Flutter (1.0.0) + - FMDB (2.7.5): + - FMDB/standard (= 2.7.5) + - FMDB/standard (2.7.5) + - sqflite (0.0.2): + - Flutter + - FMDB (>= 2.7.5) + +DEPENDENCIES: + - Flutter (from `Flutter`) + - sqflite (from `.symlinks/plugins/sqflite/ios`) + +SPEC REPOS: + trunk: + - FMDB + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + sqflite: + :path: ".symlinks/plugins/sqflite/ios" + +SPEC CHECKSUMS: + Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a + sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 + +PODFILE CHECKSUM: 663715e941f9adb426e33bf9376914006f9ea95b + +COCOAPODS: 1.12.1 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index d4fc6969..b201c7d2 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -150,7 +150,6 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - E62E850C06B92A582AAB7B05 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -167,7 +166,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0910; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -211,6 +210,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -243,6 +243,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -255,24 +256,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - E62E850C06B92A582AAB7B05 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -347,7 +330,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -368,7 +351,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -424,7 +410,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -471,7 +457,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -491,7 +477,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -514,7 +503,10 @@ "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 786d6aad..f1560181 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + diff --git a/example/lib/database.g.dart b/example/lib/database.g.dart index c593a4c1..676d3a44 100644 --- a/example/lib/database.g.dart +++ b/example/lib/database.g.dart @@ -225,6 +225,23 @@ class _$TaskDao extends TaskDao { isView: false); } + @override + Stream> findAllTasksWithoutStatusAsStream() { + return _queryAdapter.queryListStream( + 'SELECT * FROM task WHERE status IS NULL', + mapper: (Map row) => Task( + row['id'] as int?, + row['isRead'] == null ? null : (row['isRead'] as int) != 0, + row['message'] as String, + _dateTimeConverter.decode(row['timestamp'] as int), + row['status'] == null + ? null + : TaskStatus.values[row['status'] as int], + _taskTypeConverter.decode(row['type'] as String?)), + queryableName: 'task', + isView: false); + } + @override Future updateTypeById( TaskType type, diff --git a/example/lib/main.dart b/example/lib/main.dart index 5d689966..d910bf08 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -17,7 +17,7 @@ Future main() async { class FloorApp extends StatelessWidget { final TaskDao dao; - const FloorApp(this.dao); + const FloorApp(this.dao, {super.key}); @override Widget build(BuildContext context) { @@ -47,7 +47,7 @@ class TasksWidget extends StatefulWidget { } class TasksWidgetState extends State { - TaskStatus? _selectedType; + TaskStatusFilter _selectedFilter = TaskStatusFilter.all; @override Widget build(BuildContext context) { @@ -65,13 +65,12 @@ class TasksWidgetState extends State { PopupMenuButton( itemBuilder: (context) { return List.generate( - TaskStatus.values.length + - 1, //Uses increment to handle All types + TaskStatusFilter.values.length, (index) { return PopupMenuItem( value: index, child: Text( - index == 0 ? 'All' : _getMenuType(index).title, + index == 0 ? 'All' : _getMenuType(index).label, ), ); }, @@ -79,7 +78,7 @@ class TasksWidgetState extends State { }, onSelected: (index) { setState(() { - _selectedType = index == 0 ? null : _getMenuType(index); + _selectedFilter = _getMenuType(index); }); }, ) @@ -90,7 +89,7 @@ class TasksWidgetState extends State { children: [ TasksListView( dao: widget.dao, - selectedType: _selectedType, + selectedStatus: _selectedFilter, ), TasksTextField(dao: widget.dao), ], @@ -99,26 +98,29 @@ class TasksWidgetState extends State { ); } - TaskStatus _getMenuType(int index) => TaskStatus.values[index - 1]; + TaskStatusFilter _getMenuType(int index) => TaskStatusFilter.values[index]; } class TasksListView extends StatelessWidget { final TaskDao dao; - final TaskStatus? selectedType; + final TaskStatusFilter selectedStatus; const TasksListView({ Key? key, required this.dao, - required this.selectedType, + required this.selectedStatus, }) : super(key: key); @override Widget build(BuildContext context) { return Expanded( child: StreamBuilder>( - stream: selectedType == null + stream: selectedStatus == TaskStatusFilter.all ? dao.findAllTasksAsStream() - : dao.findAllTasksByStatusAsStream(selectedType!), + : selectedStatus == TaskStatusFilter.uncategorized + ? dao.findAllTasksWithoutStatusAsStream() + : dao.findAllTasksByStatusAsStream( + _getTaskStatusFromFilter(selectedStatus)), builder: (_, snapshot) { if (!snapshot.hasData) return Container(); @@ -137,6 +139,19 @@ class TasksListView extends StatelessWidget { ), ); } + + TaskStatus _getTaskStatusFromFilter(TaskStatusFilter filter) { + switch (filter) { + case TaskStatusFilter.open: + return TaskStatus.open; + case TaskStatusFilter.inProgress: + return TaskStatus.inProgress; + case TaskStatusFilter.done: + return TaskStatus.done; + default: + return throw 'Invalid filter'; + } + } } class TaskListCell extends StatelessWidget { @@ -157,22 +172,22 @@ class TaskListCell extends StatelessWidget { padding: const EdgeInsets.only(left: 16), color: Colors.green, child: const Align( + alignment: Alignment.centerLeft, child: Text( 'Change status', style: TextStyle(color: Colors.white), ), - alignment: Alignment.centerLeft, ), ), secondaryBackground: Container( padding: const EdgeInsets.only(right: 16), color: Colors.red, child: const Align( + alignment: Alignment.centerRight, child: Text( 'Delete', style: TextStyle(color: Colors.white), ), - alignment: Alignment.centerRight, ), ), direction: DismissDirection.horizontal, @@ -190,8 +205,9 @@ class TaskListCell extends StatelessWidget { break; case DismissDirection.startToEnd: final tasksLength = TaskStatus.values.length; - final nextIndex = - (tasksLength + task.statusIndex + 1) % tasksLength; + final nextIndex = task.statusIndex == null + ? 0 + : (tasksLength + task.statusIndex! + 1) % tasksLength; final taskCopy = task.copyWith(status: TaskStatus.values[nextIndex]); await dao.updateTask(taskCopy); @@ -267,10 +283,22 @@ class TasksTextField extends StatelessWidget { final task = Task.optional( message: message, type: TaskType.task, - status: TaskStatus.open, + status: null, ); await dao.insertTask(task); _textEditingController.clear(); } } } + +enum TaskStatusFilter { + all('All'), + uncategorized('Uncategorized'), + open('Open'), + inProgress('In Progress'), + done('Done'); + + final String label; + + const TaskStatusFilter(this.label); +} diff --git a/example/lib/task.dart b/example/lib/task.dart index 3a7240e9..5887d66c 100644 --- a/example/lib/task.dart +++ b/example/lib/task.dart @@ -109,5 +109,5 @@ class Task { extension TaskExtension on Task { String get statusTitle => status?.title ?? 'Empty'; - int get statusIndex => status?.index ?? 0; + int? get statusIndex => status?.index; } diff --git a/example/lib/task_dao.dart b/example/lib/task_dao.dart index cfdf8fe5..8e01233e 100644 --- a/example/lib/task_dao.dart +++ b/example/lib/task_dao.dart @@ -18,6 +18,9 @@ abstract class TaskDao { @Query('SELECT * FROM task WHERE status = :status') Stream> findAllTasksByStatusAsStream(TaskStatus status); + @Query('SELECT * FROM task WHERE status IS NULL') + Stream> findAllTasksWithoutStatusAsStream(); + @Query('UPDATE OR ABORT Task SET type = :type WHERE id = :id') Future updateTypeById(TaskType type, int id); diff --git a/example/pubspec.lock b/example/pubspec.lock index e0d64796..80d022ee 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -235,6 +235,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" + url: "https://pub.dev" + source: hosted + version: "2.0.2" flutter_test: dependency: "direct dev" description: flutter @@ -292,10 +300,10 @@ packages: dependency: transitive description: name: js - sha256: "323b7c70073cccf6b9b8d8b334be418a3293cfb612a560dc2737160a37bf61bd" + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" url: "https://pub.dev" source: hosted - version: "0.6.6" + version: "0.6.5" json_annotation: dependency: transitive description: @@ -304,6 +312,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.8.0" + lints: + dependency: transitive + description: + name: lints + sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + url: "https://pub.dev" + source: hosted + version: "2.0.1" lists: dependency: transitive description: @@ -324,10 +340,10 @@ packages: dependency: transitive description: name: matcher - sha256: c94db23593b89766cda57aab9ac311e3616cf87c6fa4e9749df032f66f30dcb8 + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" url: "https://pub.dev" source: hosted - version: "0.12.14" + version: "0.12.13" material_color_utilities: dependency: transitive description: @@ -364,10 +380,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.8.2" pool: dependency: transitive description: @@ -529,10 +545,10 @@ packages: dependency: transitive description: name: test_api - sha256: "6182294da5abf431177fccc1ee02401f6df30f766bc6130a0852c6b6d7ee6b2d" + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 url: "https://pub.dev" source: hosted - version: "0.4.18" + version: "0.4.16" timing: dependency: transitive description: @@ -590,5 +606,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.19.0 <4.0.0" + dart: ">=2.19.0 <3.0.0" flutter: ">=3.3.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index aadfdf8f..12f46bcc 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -22,3 +22,4 @@ dev_dependencies: path: ../floor_generator/ flutter_test: sdk: flutter + flutter_lints: ^2.0.2 From 33064ef63368c2345a6fb6f53e157f7b703ba138 Mon Sep 17 00:00:00 2001 From: Stephan Veenstra Date: Wed, 19 Jul 2023 10:06:14 +0200 Subject: [PATCH 4/8] Update workflow action to use Pinch forks --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74b05224..6c57a0ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: run: dart run test_cov - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: pinchbv/codecov-action-ga@main with: token: ${{ secrets.CODECOV_TOKEN }} flags: floor_generator @@ -76,7 +76,7 @@ jobs: uses: actions/checkout@v2 - name: Install Flutter - uses: subosito/flutter-action@v2 + uses: pinchbv/flutter-action-ga@main with: channel: stable architecture: x64 @@ -104,7 +104,7 @@ jobs: working-directory: floor - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: pinchbv/codecov-action-ga@main with: token: ${{ secrets.CODECOV_TOKEN }} flags: floor @@ -119,7 +119,7 @@ jobs: uses: actions/checkout@v2 - name: Install Flutter - uses: subosito/flutter-action@v2 + uses: pinchbv/flutter-action-ga@main with: channel: stable From 4a70d641cba46d7994cc337496ee06957d1fc2f6 Mon Sep 17 00:00:00 2001 From: Stephan Veenstra Date: Wed, 19 Jul 2023 10:52:14 +0200 Subject: [PATCH 5/8] Add ignore_for_file: library_private_types_in_public_api --- example/lib/database.g.dart | 47 ++++++-------------- example/lib/main.dart | 16 +++---- example/pubspec.lock | 10 ++--- example/pubspec.yaml | 1 + floor/pubspec.lock | 32 +++++++------ floor_annotation/pubspec.lock | 2 +- floor_generator/lib/writer/floor_writer.dart | 3 +- floor_generator/pubspec.lock | 9 ++-- 8 files changed, 47 insertions(+), 73 deletions(-) diff --git a/example/lib/database.g.dart b/example/lib/database.g.dart index 676d3a44..f129903e 100644 --- a/example/lib/database.g.dart +++ b/example/lib/database.g.dart @@ -7,17 +7,16 @@ part of 'database.dart'; // ************************************************************************** // ignore: avoid_classes_with_only_static_members +// ignore_for_file: library_private_types_in_public_api class $FloorFlutterDatabase { /// Creates a database builder for a persistent database. /// Once a database is built, you should keep a reference to it and re-use it. - static _$FlutterDatabaseBuilder databaseBuilder(String name) => - _$FlutterDatabaseBuilder(name); + static _$FlutterDatabaseBuilder databaseBuilder(String name) => _$FlutterDatabaseBuilder(name); /// Creates a database builder for an in memory database. /// Information stored in an in memory database disappears when the process is killed. /// Once a database is built, you should keep a reference to it and re-use it. - static _$FlutterDatabaseBuilder inMemoryDatabaseBuilder() => - _$FlutterDatabaseBuilder(null); + static _$FlutterDatabaseBuilder inMemoryDatabaseBuilder() => _$FlutterDatabaseBuilder(null); } class _$FlutterDatabaseBuilder { @@ -43,9 +42,7 @@ class _$FlutterDatabaseBuilder { /// Creates the database and initializes it. Future build() async { - final path = name != null - ? await sqfliteDatabaseFactory.getDatabasePath(name!) - : ':memory:'; + final path = name != null ? await sqfliteDatabaseFactory.getDatabasePath(name!) : ':memory:'; final database = _$FlutterDatabase(); database.database = await database.open( path, @@ -78,8 +75,7 @@ class _$FlutterDatabase extends FlutterDatabase { await callback?.onOpen?.call(database); }, onUpgrade: (database, startVersion, endVersion) async { - await MigrationAdapter.runMigrations( - database, startVersion, endVersion, migrations); + await MigrationAdapter.runMigrations(database, startVersion, endVersion, migrations); await callback?.onUpgrade?.call(database, startVersion, endVersion); }, @@ -163,9 +159,7 @@ class _$TaskDao extends TaskDao { row['isRead'] == null ? null : (row['isRead'] as int) != 0, row['message'] as String, _dateTimeConverter.decode(row['timestamp'] as int), - row['status'] == null - ? null - : TaskStatus.values[row['status'] as int], + row['status'] == null ? null : TaskStatus.values[row['status'] as int], _taskTypeConverter.decode(row['type'] as String?)), arguments: [id]); } @@ -178,9 +172,7 @@ class _$TaskDao extends TaskDao { row['isRead'] == null ? null : (row['isRead'] as int) != 0, row['message'] as String, _dateTimeConverter.decode(row['timestamp'] as int), - row['status'] == null - ? null - : TaskStatus.values[row['status'] as int], + row['status'] == null ? null : TaskStatus.values[row['status'] as int], _taskTypeConverter.decode(row['type'] as String?))); } @@ -192,9 +184,7 @@ class _$TaskDao extends TaskDao { row['isRead'] == null ? null : (row['isRead'] as int) != 0, row['message'] as String, _dateTimeConverter.decode(row['timestamp'] as int), - row['status'] == null - ? null - : TaskStatus.values[row['status'] as int], + row['status'] == null ? null : TaskStatus.values[row['status'] as int], _taskTypeConverter.decode(row['type'] as String?)), queryableName: 'task', isView: false); @@ -203,9 +193,7 @@ class _$TaskDao extends TaskDao { @override Stream findUniqueMessagesCountAsStream() { return _queryAdapter.queryStream('SELECT DISTINCT COUNT(message) FROM task', - mapper: (Map row) => row.values.first as int, - queryableName: 'task', - isView: false); + mapper: (Map row) => row.values.first as int, queryableName: 'task', isView: false); } @override @@ -216,9 +204,7 @@ class _$TaskDao extends TaskDao { row['isRead'] == null ? null : (row['isRead'] as int) != 0, row['message'] as String, _dateTimeConverter.decode(row['timestamp'] as int), - row['status'] == null - ? null - : TaskStatus.values[row['status'] as int], + row['status'] == null ? null : TaskStatus.values[row['status'] as int], _taskTypeConverter.decode(row['type'] as String?)), arguments: [status.index], queryableName: 'task', @@ -227,16 +213,13 @@ class _$TaskDao extends TaskDao { @override Stream> findAllTasksWithoutStatusAsStream() { - return _queryAdapter.queryListStream( - 'SELECT * FROM task WHERE status IS NULL', + return _queryAdapter.queryListStream('SELECT * FROM task WHERE status IS NULL', mapper: (Map row) => Task( row['id'] as int?, row['isRead'] == null ? null : (row['isRead'] as int) != 0, row['message'] as String, _dateTimeConverter.decode(row['timestamp'] as int), - row['status'] == null - ? null - : TaskStatus.values[row['status'] as int], + row['status'] == null ? null : TaskStatus.values[row['status'] as int], _taskTypeConverter.decode(row['type'] as String?)), queryableName: 'task', isView: false); @@ -247,10 +230,8 @@ class _$TaskDao extends TaskDao { TaskType type, int id, ) async { - return _queryAdapter.query( - 'UPDATE OR ABORT Task SET type = ?1 WHERE id = ?2', - mapper: (Map row) => row.values.first as int, - arguments: [type.index, id]); + return _queryAdapter.query('UPDATE OR ABORT Task SET type = ?1 WHERE id = ?2', + mapper: (Map row) => row.values.first as int, arguments: [type.index, id]); } @override diff --git a/example/lib/main.dart b/example/lib/main.dart index d910bf08..db0c283f 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -6,9 +6,7 @@ import 'package:flutter/material.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - final database = await $FloorFlutterDatabase - .databaseBuilder('flutter_database.db') - .build(); + final database = await $FloorFlutterDatabase.databaseBuilder('flutter_database.db').build(); final dao = database.taskDao; runApp(FloorApp(dao)); @@ -119,8 +117,7 @@ class TasksListView extends StatelessWidget { ? dao.findAllTasksAsStream() : selectedStatus == TaskStatusFilter.uncategorized ? dao.findAllTasksWithoutStatusAsStream() - : dao.findAllTasksByStatusAsStream( - _getTaskStatusFromFilter(selectedStatus)), + : dao.findAllTasksByStatusAsStream(_getTaskStatusFromFilter(selectedStatus)), builder: (_, snapshot) { if (!snapshot.hasData) return Container(); @@ -197,6 +194,7 @@ class TaskListCell extends StatelessWidget { trailing: Text(task.timestamp.toIso8601String()), ), confirmDismiss: (direction) async { + final scaffoldMessengerState = ScaffoldMessenger.of(context); String? statusMessage; switch (direction) { case DismissDirection.endToStart: @@ -205,11 +203,8 @@ class TaskListCell extends StatelessWidget { break; case DismissDirection.startToEnd: final tasksLength = TaskStatus.values.length; - final nextIndex = task.statusIndex == null - ? 0 - : (tasksLength + task.statusIndex! + 1) % tasksLength; - final taskCopy = - task.copyWith(status: TaskStatus.values[nextIndex]); + final nextIndex = task.statusIndex == null ? 0 : (tasksLength + task.statusIndex! + 1) % tasksLength; + final taskCopy = task.copyWith(status: TaskStatus.values[nextIndex]); await dao.updateTask(taskCopy); statusMessage = 'Updated task status by: ${taskCopy.statusTitle}'; break; @@ -218,7 +213,6 @@ class TaskListCell extends StatelessWidget { } if (statusMessage != null) { - final scaffoldMessengerState = ScaffoldMessenger.of(context); scaffoldMessengerState.hideCurrentSnackBar(); scaffoldMessengerState.showSnackBar( SnackBar(content: Text(statusMessage)), diff --git a/example/pubspec.lock b/example/pubspec.lock index 80d022ee..0c168edb 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -446,21 +446,21 @@ packages: source: hosted version: "1.9.1" sqflite: - dependency: transitive + dependency: "direct main" description: name: sqflite - sha256: "500d6fec583d2c021f2d25a056d96654f910662c64f836cd2063167b8f1fa758" + sha256: b4d6710e1200e96845747e37338ea8a819a12b51689a3bcf31eff0003b37a0b9 url: "https://pub.dev" source: hosted - version: "2.2.6" + version: "2.2.8+4" sqflite_common: dependency: transitive description: name: sqflite_common - sha256: "963dad8c4aa2f814ce7d2d5b1da2f36f31bd1a439d8f27e3dc189bb9d26bc684" + sha256: "8f7603f3f8f126740bc55c4ca2d1027aab4b74a1267a3e31ce51fe40e3b65b8f" url: "https://pub.dev" source: hosted - version: "2.4.3" + version: "2.4.5+1" sqflite_common_ffi: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 12f46bcc..acc5480d 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -12,6 +12,7 @@ environment: dependencies: floor: path: ../floor/ + sqflite: ^2.2.8+4 flutter: sdk: flutter diff --git a/floor/pubspec.lock b/floor/pubspec.lock index 85d4fe9c..0fc92434 100644 --- a/floor/pubspec.lock +++ b/floor/pubspec.lock @@ -212,18 +212,16 @@ packages: floor_annotation: dependency: "direct main" description: - name: floor_annotation - sha256: fa3fa4f198cdd1d922a69ceb06e54663fe59256bf1cb3c036eff206b445a6960 - url: "https://pub.dev" - source: hosted + path: "../floor_annotation" + relative: true + source: path version: "1.4.2" floor_generator: dependency: "direct dev" description: - name: floor_generator - sha256: "40aaf1b619adc03367ce4b7c79161e3198d43b572b5ec9cc99a4a89de27b08d2" - url: "https://pub.dev" - source: hosted + path: "../floor_generator" + relative: true + source: path version: "1.4.2" flutter: dependency: "direct main" @@ -287,10 +285,10 @@ packages: dependency: transitive description: name: js - sha256: "323b7c70073cccf6b9b8d8b334be418a3293cfb612a560dc2737160a37bf61bd" + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" url: "https://pub.dev" source: hosted - version: "0.6.6" + version: "0.6.5" json_annotation: dependency: transitive description: @@ -319,10 +317,10 @@ packages: dependency: "direct dev" description: name: matcher - sha256: c94db23593b89766cda57aab9ac311e3616cf87c6fa4e9749df032f66f30dcb8 + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" url: "https://pub.dev" source: hosted - version: "0.12.14" + version: "0.12.13" material_color_utilities: dependency: transitive description: @@ -367,10 +365,10 @@ packages: dependency: "direct main" description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.8.2" pool: dependency: transitive description: @@ -532,10 +530,10 @@ packages: dependency: transitive description: name: test_api - sha256: "6182294da5abf431177fccc1ee02401f6df30f766bc6130a0852c6b6d7ee6b2d" + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 url: "https://pub.dev" source: hosted - version: "0.4.18" + version: "0.4.16" timing: dependency: transitive description: @@ -593,5 +591,5 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.19.0 <4.0.0" + dart: ">=2.19.0 <3.0.0" flutter: ">=3.3.0" diff --git a/floor_annotation/pubspec.lock b/floor_annotation/pubspec.lock index 91d69e7d..b5c9c7d4 100644 --- a/floor_annotation/pubspec.lock +++ b/floor_annotation/pubspec.lock @@ -10,4 +10,4 @@ packages: source: hosted version: "1.9.1" sdks: - dart: ">=2.12.0 <4.0.0" + dart: ">=2.12.0 <3.0.0" diff --git a/floor_generator/lib/writer/floor_writer.dart b/floor_generator/lib/writer/floor_writer.dart index 697ae678..3efe9511 100644 --- a/floor_generator/lib/writer/floor_writer.dart +++ b/floor_generator/lib/writer/floor_writer.dart @@ -39,6 +39,7 @@ class FloorWriter extends Writer { return Class((builder) => builder ..name = '\$Floor$_databaseName' ..methods.addAll([databaseBuilderMethod, inMemoryDatabaseBuilderMethod]) - ..docs.add('// ignore: avoid_classes_with_only_static_members')); + ..docs.add('// ignore: avoid_classes_with_only_static_members') + ..docs.add('// ignore_for_file: library_private_types_in_public_api')); } } diff --git a/floor_generator/pubspec.lock b/floor_generator/pubspec.lock index 3916ef11..ac5a2bc8 100644 --- a/floor_generator/pubspec.lock +++ b/floor_generator/pubspec.lock @@ -180,10 +180,9 @@ packages: floor_annotation: dependency: "direct main" description: - name: floor_annotation - sha256: fa3fa4f198cdd1d922a69ceb06e54663fe59256bf1cb3c036eff206b445a6960 - url: "https://pub.dev" - source: hosted + path: "../floor_annotation" + relative: true + source: path version: "1.4.2" frontend_server_client: dependency: transitive @@ -555,4 +554,4 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.19.0 <=3.3.8" + dart: ">=2.19.0 <3.0.0" From ca44e8a319edd03d6975bcd117658e6a617b3ad2 Mon Sep 17 00:00:00 2001 From: Stephan Veenstra Date: Wed, 19 Jul 2023 10:59:57 +0200 Subject: [PATCH 6/8] Add test for library_private_types_in_public_api --- floor_generator/test/writer/floor_writer_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/floor_generator/test/writer/floor_writer_test.dart b/floor_generator/test/writer/floor_writer_test.dart index 39fd5d69..033997ca 100644 --- a/floor_generator/test/writer/floor_writer_test.dart +++ b/floor_generator/test/writer/floor_writer_test.dart @@ -14,6 +14,7 @@ void main() { expect(actual, equalsDart(r''' // ignore: avoid_classes_with_only_static_members + // ignore_for_file: library_private_types_in_public_api class $FloorFooBar { /// Creates a database builder for a persistent database. /// Once a database is built, you should keep a reference to it and re-use it. From b8a30815c744333a50549efa3afd01f3a4cfbdba Mon Sep 17 00:00:00 2001 From: Stephan Veenstra Date: Wed, 19 Jul 2023 11:07:56 +0200 Subject: [PATCH 7/8] Reorder ignore rules on generated class --- floor_generator/lib/writer/floor_writer.dart | 4 ++-- floor_generator/test/writer/floor_writer_test.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/floor_generator/lib/writer/floor_writer.dart b/floor_generator/lib/writer/floor_writer.dart index 3efe9511..bf6ef591 100644 --- a/floor_generator/lib/writer/floor_writer.dart +++ b/floor_generator/lib/writer/floor_writer.dart @@ -39,7 +39,7 @@ class FloorWriter extends Writer { return Class((builder) => builder ..name = '\$Floor$_databaseName' ..methods.addAll([databaseBuilderMethod, inMemoryDatabaseBuilderMethod]) - ..docs.add('// ignore: avoid_classes_with_only_static_members') - ..docs.add('// ignore_for_file: library_private_types_in_public_api')); + ..docs.add('// ignore_for_file: library_private_types_in_public_api') + ..docs.add('// ignore: avoid_classes_with_only_static_members')); } } diff --git a/floor_generator/test/writer/floor_writer_test.dart b/floor_generator/test/writer/floor_writer_test.dart index 033997ca..1a0b2c50 100644 --- a/floor_generator/test/writer/floor_writer_test.dart +++ b/floor_generator/test/writer/floor_writer_test.dart @@ -13,8 +13,8 @@ void main() { final actual = FloorWriter(databaseName).write(); expect(actual, equalsDart(r''' - // ignore: avoid_classes_with_only_static_members // ignore_for_file: library_private_types_in_public_api + // ignore: avoid_classes_with_only_static_members class $FloorFooBar { /// Creates a database builder for a persistent database. /// Once a database is built, you should keep a reference to it and re-use it. From 808f14d7438e2081168d092c7266d6faaf3684b5 Mon Sep 17 00:00:00 2001 From: hendrikvanderkaaden Date: Fri, 15 Mar 2024 14:34:59 +0100 Subject: [PATCH 8/8] Resolve merge conflicts with develop --- example/pubspec.lock | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index ad812b07..2950e134 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -235,6 +235,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + url: "https://pub.dev" + source: hosted + version: "2.0.3" flutter_test: dependency: "direct dev" description: flutter @@ -328,6 +336,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.1" + lints: + dependency: transitive + description: + name: lints + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.dev" + source: hosted + version: "2.1.1" lists: dependency: transitive description: @@ -454,7 +470,7 @@ packages: source: hosted version: "1.10.0" sqflite: - dependency: transitive + dependency: "direct main" description: name: sqflite sha256: a9016f495c927cb90557c909ff26a6d92d9bd54fc42ba92e19d4e79d61e798c6 @@ -529,10 +545,10 @@ packages: dependency: transitive description: name: strings - sha256: "1f3db7347b8dfd9844ee7fb34883cffbe6cc723a63cb9f4a0aa19e619304b030" + sha256: b33f40c4dd3e597bf6d9e7f4f4dc282dad0f19b07d9f320cb5c2183859cbccf5 url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "3.1.1" synchronized: dependency: transitive description: