diff --git a/.gitignore b/.gitignore index cdecf14..c6f51c1 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ build/ .android/ .ios/ .flutter-plugins +example/.flutter-plugins-dependencies +example/ios/Podfile +example/ios/Flutter/flutter_export_environment.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8531085 --- /dev/null +++ b/Makefile @@ -0,0 +1,53 @@ + # Copyright (C) 2019, David PHAM-VAN + # + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + +DART_SRC=$(shell find . -name '*.dart') + +all: format + +format: format-dart + +format-dart: $(DART_SRC) + dartfmt -w --fix $^ + +clean: + git clean -fdx -e .vscode + +test: + pub run test + +publish: format analyze clean + pub publish -f + +.dartfix: + pub global activate dartfix + touch $@ + +.pana: + pub global activate pana + touch $@ + +fix: .dartfix $(DART_SRC) + pub global run dartfix --overwrite . + +analyze: $(DART_SRC) + dartanalyzer --fatal-infos --fatal-warnings --fatal-hints --fatal-lints -v . + +pana: .pana + pub global run pana --no-warning --source path . + +.PHONY: format format-dart clean publish test fix analyze + +lib/src/pubspec.dart: pubspec.yaml + flutter pub run pubspec_extract -s $^ -d $@ diff --git a/README.md b/README.md index 2d9b094..c185762 100644 --- a/README.md +++ b/README.md @@ -2,23 +2,22 @@ A debug drawer menu for better development. This is an initial release with very few functionalities. -This project is heavily inspired on a similar project for Android (https://github.com/palaima/DebugDrawer) - -Screenshot +This project is heavily inspired on a similar project for Android () +Screenshot ## Getting Started Include the last version of the library in your `pubspec.yaml`: -``` - dependencies: - flutter_debug_drawer: 0.1.1+1 +```yaml +dependencies: + flutter_debug_drawer: ``` Now, you can customize your debug drawer adding it to your main application object: -``` +```dart class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { @@ -27,6 +26,8 @@ class MyApp extends StatelessWidget { builder: DebugDrawerBuilder.build(modules: [ PlatformModule(), MediaQueryModule(), + PackageModule(), + SharedPreferencesModule(), ]), home: MyHomePage(), ); @@ -34,5 +35,4 @@ class MyApp extends StatelessWidget { } ``` -Right now, only PlatformModule and MediaQueryModule are availables. More will come soon. - +Right now, only PlatformModule, MediaQueryModule, PackageModule, and SharedPreferencesModule are available. More will come soon. diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..9aaad93 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,30 @@ +# see https://github.com/dart-lang/pedantic#enabled-lints. +include: package:pedantic/analysis_options.yaml + +linter: + rules: + - always_declare_return_types + - avoid_void_async + - await_only_futures + - file_names + - omit_local_variable_types + - prefer_const_constructors_in_immutables + - prefer_final_fields + - prefer_final_locals + - prefer_foreach + - prefer_generic_function_type_aliases + - prefer_if_null_operators + - prefer_interpolation_to_compose_strings + - prefer_null_aware_operators + - prefer_single_quotes + - prefer_typing_uninitialized_variables + - sort_constructors_first + - sort_unnamed_constructors_first + - unnecessary_brace_in_string_interps + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_overrides + - unnecessary_parenthesis + - unnecessary_this + - use_function_type_syntax_for_parameters + - void_checks diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee..e8efba1 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Flutter.podspec b/example/ios/Flutter/Flutter.podspec new file mode 100644 index 0000000..5ca3041 --- /dev/null +++ b/example/ios/Flutter/Flutter.podspec @@ -0,0 +1,18 @@ +# +# NOTE: This podspec is NOT to be published. It is only used as a local source! +# + +Pod::Spec.new do |s| + s.name = 'Flutter' + s.version = '1.0.0' + s.summary = 'High-performance, high-fidelity mobile apps.' + s.description = <<-DESC +Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS. + DESC + s.homepage = 'https://flutter.io' + s.license = { :type => 'MIT' } + s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } + s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s } + s.ios.deployment_target = '8.0' + s.vendored_frameworks = 'Flutter.framework' +end diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 592ceee..399e934 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock new file mode 100644 index 0000000..8cac1cf --- /dev/null +++ b/example/ios/Podfile.lock @@ -0,0 +1,28 @@ +PODS: + - Flutter (1.0.0) + - package_info (0.0.1): + - Flutter + - shared_preferences (0.0.1): + - Flutter + +DEPENDENCIES: + - Flutter (from `Flutter`) + - package_info (from `.symlinks/plugins/package_info/ios`) + - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + package_info: + :path: ".symlinks/plugins/package_info/ios" + shared_preferences: + :path: ".symlinks/plugins/shared_preferences/ios" + +SPEC CHECKSUMS: + Flutter: 0e3d915762c693b495b44d77113d4970485de6ec + package_info: 78cabb3c322943c55d39676f4a5bfc748c01d055 + shared_preferences: 1feebfa37bb57264736e16865e7ffae7fc99b523 + +PODFILE CHECKSUM: 1b66dae606f75376c5f2135a8290850eeb09ae83 + +COCOAPODS: 1.8.4 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index f05b339..ac4f3fe 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 1F084647ACA90F8824BD6ED2 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 95263E012B6C087BC88BC511 /* Pods_Runner.framework */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -40,17 +41,21 @@ 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; + 4BEAB43E412E67324B8DFD48 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 95263E012B6C087BC88BC511 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; + 976AD1D2177E520A10E0B35B /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 9D1982BAA90B471EFAF113F2 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -60,12 +65,21 @@ files = ( 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, + 1F084647ACA90F8824BD6ED2 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 7530B419E6A07FA692EF1277 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 95263E012B6C087BC88BC511 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -85,6 +99,8 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, + E70455A5166365AADFB58586 /* Pods */, + 7530B419E6A07FA692EF1277 /* Frameworks */, ); sourceTree = ""; }; @@ -119,6 +135,17 @@ name = "Supporting Files"; sourceTree = ""; }; + E70455A5166365AADFB58586 /* Pods */ = { + isa = PBXGroup; + children = ( + 4BEAB43E412E67324B8DFD48 /* Pods-Runner.debug.xcconfig */, + 9D1982BAA90B471EFAF113F2 /* Pods-Runner.release.xcconfig */, + 976AD1D2177E520A10E0B35B /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -126,12 +153,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 5D976A2112F356206E183696 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + DA9250D950D4C34EA3152714 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -205,6 +234,28 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; }; + 5D976A2112F356206E183696 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -219,6 +270,21 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + DA9250D950D4C34EA3152714 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + 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 */ @@ -508,7 +574,6 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ - }; rootObject = 97C146E61CF9000F007C117D /* Project object */; } diff --git a/example/ios/Runner.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a1..21a3cc1 100644 --- a/example/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/example/lib/main.dart b/example/lib/main.dart index dca4982..5ab4170 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -8,16 +8,11 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', - builder: DebugDrawerBuilder.build(modules: [ - PlatformModule(), - MediaQueryModule(), - PackageModule(), - SharedPreferencesModule(), - ]), + builder: DebugDrawerBuilder.buildDefault(), theme: ThemeData( primarySwatch: Colors.blue, ), - home: MyHomePage(),navigatorObservers: , + home: MyHomePage(), ); } } @@ -27,7 +22,7 @@ class MyHomePage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text("UNO"), + title: Text('UNO'), ), body: Center( child: Column( @@ -38,14 +33,14 @@ class MyHomePage extends StatelessWidget { ), Text( 'hola', - style: Theme.of(context).textTheme.display1, + style: Theme.of(context).textTheme.headline4, ), ], ), ), floatingActionButton: FloatingActionButton( - onPressed: () => Navigator.of(context) - .push(PageRouteBuilder(pageBuilder: (context, _, __) => Page2())), + onPressed: () => Navigator.of(context).push(PageRouteBuilder( + pageBuilder: (BuildContext context, _, __) => Page2())), tooltip: 'Increment', child: Icon(Icons.add), ), // This trailing comma makes auto-formatting nicer for build methods. @@ -58,7 +53,7 @@ class Page2 extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text("DOS"), + title: Text('DOS'), ), body: Center( child: Column( @@ -69,7 +64,7 @@ class Page2 extends StatelessWidget { ), Text( 'PEPEc', - style: Theme.of(context).textTheme.display1, + style: Theme.of(context).textTheme.headline4, ), ], ), diff --git a/example/pubspec.lock b/example/pubspec.lock index 59cb709..b62d6c2 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,20 +1,34 @@ # Generated by pub -# See https://www.dartlang.org/tools/pub/glossary#lockfile +# See https://dart.dev/tools/pub/glossary#lockfile packages: + archive: + dependency: transitive + description: + name: archive + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.4.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" charcode: dependency: transitive description: @@ -29,6 +43,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.14.11" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" cupertino_icons: dependency: "direct main" description: @@ -53,20 +81,27 @@ packages: description: flutter source: sdk version: "0.0.0" + image: + dependency: transitive + description: + name: image + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.5" + version: "0.12.6" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.1.8" package_info: dependency: transitive description: @@ -80,21 +115,28 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.2" + version: "1.6.4" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.5.0" + version: "1.8.0+1" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.0" quiver: dependency: transitive description: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.5" shared_preferences: dependency: transitive description: @@ -134,7 +176,7 @@ packages: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" term_glyph: dependency: transitive description: @@ -148,7 +190,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.11" typed_data: dependency: transitive description: @@ -163,6 +205,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.8" + xml: + dependency: transitive + description: + name: xml + url: "https://pub.dartlang.org" + source: hosted + version: "3.5.0" sdks: - dart: ">=2.2.0 <3.0.0" + dart: ">=2.7.0 <3.0.0" flutter: ">=0.1.4 <2.0.0" diff --git a/lib/src/base/base_module.dart b/lib/src/base/base_module.dart index eeaa057..030a128 100644 --- a/lib/src/base/base_module.dart +++ b/lib/src/base/base_module.dart @@ -1,17 +1,16 @@ import 'package:flutter/material.dart'; import '../drawer/debug_drawer.dart'; -import '../drawer/debug_drawer_theme.dart'; class DebugDrawerModule extends StatelessWidget { - DebugDrawerModule({Key key, this.title, this.child}) : super(key: key); + const DebugDrawerModule({Key key, this.title, this.child}) : super(key: key); final Widget child; final String title; @override Widget build(BuildContext context) { - DebugDrawerTheme theme = DebugDrawer.of(context).theme; + final theme = DebugDrawer.of(context).theme; return Padding( padding: theme.sectionMargin, child: Container( diff --git a/lib/src/base/module_widgets.dart b/lib/src/base/module_widgets.dart index 5239310..607795a 100644 --- a/lib/src/base/module_widgets.dart +++ b/lib/src/base/module_widgets.dart @@ -1,17 +1,16 @@ import 'package:flutter/material.dart'; import '../drawer/debug_drawer.dart'; -import '../drawer/debug_drawer_theme.dart'; class DebugDrawerField extends StatelessWidget { + const DebugDrawerField({Key key, this.label, this.value}) : super(key: key); + final String label; final String value; - DebugDrawerField({Key key, this.label, this.value}) : super(key: key); - @override Widget build(BuildContext context) { - DebugDrawerTheme theme = DebugDrawer.of(context).theme; + final theme = DebugDrawer.of(context).theme; return Container( padding: EdgeInsets.symmetric(vertical: 6), alignment: Alignment.topLeft, @@ -22,7 +21,7 @@ class DebugDrawerField extends StatelessWidget { padding: EdgeInsets.only(right: 8), width: 120, child: Text( - "$label:", + '$label:', style: theme.labelStyle, )), Expanded( @@ -38,18 +37,18 @@ class DebugDrawerField extends StatelessWidget { } class DebugDrawerButton extends StatelessWidget { - final VoidCallback onPressed; - final String label; - const DebugDrawerButton({ Key key, this.onPressed, this.label, }) : super(key: key); + final VoidCallback onPressed; + final String label; + @override Widget build(BuildContext context) { - DebugDrawerTheme theme = DebugDrawer.of(context).theme; + final theme = DebugDrawer.of(context).theme; return Container( child: RaisedButton( diff --git a/lib/src/drawer/debug_drawer.dart b/lib/src/drawer/debug_drawer.dart index dd33ac7..49c986a 100644 --- a/lib/src/drawer/debug_drawer.dart +++ b/lib/src/drawer/debug_drawer.dart @@ -1,6 +1,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import '../../flutter_debug_drawer.dart'; import 'debug_drawer_theme.dart'; class DebugDrawerBuilder { @@ -18,24 +19,32 @@ class DebugDrawerBuilder { return null; } } + + static TransitionBuilder buildDefault() { + return build(modules: [ + PlatformModule(), + MediaQueryModule(), + PackageModule(), + SharedPreferencesModule(), + ]); + } } class DebugDrawer extends StatelessWidget { - final Widget child; - - final DebugDrawerTheme theme; - - final List modules; - - DebugDrawer({ + const DebugDrawer({ Key key, this.child, this.modules = const [], this.theme, }) : super(key: key); + final Widget child; + + final DebugDrawerTheme theme; + + final List modules; static DebugDrawer of(BuildContext context) { - return context.ancestorWidgetOfExactType(DebugDrawer); + return context.findAncestorWidgetOfExactType(); } @override @@ -46,7 +55,7 @@ class DebugDrawer extends StatelessWidget { endDrawer: MediaQuery.removePadding( removeTop: true, context: context, - child: new DebugDrawerBody(modules: modules), + child: DebugDrawerBody(modules: modules), ), ); } @@ -62,7 +71,7 @@ class DebugDrawerBody extends StatelessWidget { @override Widget build(BuildContext context) { - DebugDrawerTheme theme = DebugDrawer.of(context).theme; + final theme = DebugDrawer.of(context).theme; return Container( padding: EdgeInsets.only( diff --git a/lib/src/drawer/debug_drawer_theme.dart b/lib/src/drawer/debug_drawer_theme.dart index e573dd0..c3bb8fb 100644 --- a/lib/src/drawer/debug_drawer_theme.dart +++ b/lib/src/drawer/debug_drawer_theme.dart @@ -1,20 +1,6 @@ import 'package:flutter/material.dart'; class DebugDrawerTheme { - final Color backgroundColor; - final Color sectionColor; - final double width; - final EdgeInsetsGeometry sectionPadding; - final EdgeInsetsGeometry sectionMargin; - final TextStyle sectionTitleStyle; - final Color sectionTitleSeparatorColor; - final EdgeInsetsGeometry sectionTitleSeparatorPadding; - final double sectionTitleSeparatorHeight; - final TextStyle labelStyle; - final TextStyle valueStyle; - final Color buttonColor; - final TextStyle buttonStyle; - const DebugDrawerTheme({ this.backgroundColor, this.sectionColor, @@ -43,8 +29,22 @@ class DebugDrawerTheme { assert(buttonColor != null), assert(buttonStyle != null); + final Color backgroundColor; + final Color sectionColor; + final double width; + final EdgeInsetsGeometry sectionPadding; + final EdgeInsetsGeometry sectionMargin; + final TextStyle sectionTitleStyle; + final Color sectionTitleSeparatorColor; + final EdgeInsetsGeometry sectionTitleSeparatorPadding; + final double sectionTitleSeparatorHeight; + final TextStyle labelStyle; + final TextStyle valueStyle; + final Color buttonColor; + final TextStyle buttonStyle; + static TextStyle defaultTextStyle = TextStyle( - fontFamily: "Roboto Condensed", color: Colors.white, fontSize: 14); + fontFamily: 'Roboto Condensed', color: Colors.white, fontSize: 14); static DebugDrawerTheme defaultTheme = DebugDrawerTheme( backgroundColor: Colors.black, diff --git a/lib/src/modules/media_query.dart b/lib/src/modules/media_query.dart index 9e90c6e..1b737e8 100644 --- a/lib/src/modules/media_query.dart +++ b/lib/src/modules/media_query.dart @@ -6,37 +6,37 @@ import '../base/module_widgets.dart'; class MediaQueryModule extends DebugDrawerModule { @override Widget build(BuildContext context) { - MediaQueryData mediaQuery = MediaQuery.of(context); + final mediaQuery = MediaQuery.of(context); return DebugDrawerModule( - title: "MediaQuery", + title: 'MediaQuery', child: Column( children: [ DebugDrawerField( - label: "Size.width", - value: "width: ${mediaQuery.size.width.toStringAsFixed(2)}"), + label: 'Size.width', + value: 'width: ${mediaQuery.size.width.toStringAsFixed(2)}'), DebugDrawerField( - label: "size.height", - value: "height: ${mediaQuery.size.height.toStringAsFixed(2)}", + label: 'size.height', + value: 'height: ${mediaQuery.size.height.toStringAsFixed(2)}', ), DebugDrawerField( - label: "PixelRatio", - value: "${mediaQuery.devicePixelRatio}", + label: 'PixelRatio', + value: '${mediaQuery.devicePixelRatio}', ), DebugDrawerField( - label: "Orientation", - value: "${mediaQuery.orientation.toString()}", + label: 'Orientation', + value: '${mediaQuery.orientation.toString()}', ), DebugDrawerField( - label: "Platform Brightness", - value: "${mediaQuery.platformBrightness}", + label: 'Platform Brightness', + value: '${mediaQuery.platformBrightness}', ), DebugDrawerField( - label: "Text scale factor", - value: "${mediaQuery.textScaleFactor}", + label: 'Text scale factor', + value: '${mediaQuery.textScaleFactor}', ), DebugDrawerField( - label: "PixelRatio", - value: "${mediaQuery.textScaleFactor}", + label: 'PixelRatio', + value: '${mediaQuery.textScaleFactor}', ), ], ), diff --git a/lib/src/modules/package.dart b/lib/src/modules/package.dart index 17c34e9..87ac4b8 100644 --- a/lib/src/modules/package.dart +++ b/lib/src/modules/package.dart @@ -10,32 +10,32 @@ class PackageModule extends StatefulWidget { } class _PackageModuleState extends State { - String appName = ""; - String packageName = ""; - String version = ""; - String buildNumber = ""; + String appName = ''; + String packageName = ''; + String version = ''; + String buildNumber = ''; @override Widget build(BuildContext context) { return DebugDrawerModule( - title: "Package Info", + title: 'Package Info', child: Column( children: [ DebugDrawerField( - label: "App name", - value: "$appName", + label: 'App name', + value: '$appName', ), DebugDrawerField( - label: "Package name", - value: "$packageName", + label: 'Package name', + value: '$packageName', ), DebugDrawerField( - label: "App version", - value: "$version", + label: 'App version', + value: '$version', ), DebugDrawerField( - label: "Build number", - value: "$buildNumber", + label: 'Build number', + value: '$buildNumber', ), ], ), diff --git a/lib/src/modules/platform.dart b/lib/src/modules/platform.dart index 86ceb7f..301a0f6 100644 --- a/lib/src/modules/platform.dart +++ b/lib/src/modules/platform.dart @@ -9,40 +9,40 @@ class PlatformModule extends StatelessWidget { @override Widget build(BuildContext context) { return DebugDrawerModule( - title: "Platform", + title: 'Platform', child: Column( children: [ DebugDrawerField( - label: "OS", - value: "${Platform.operatingSystem}", + label: 'OS', + value: '${Platform.operatingSystem}', ), DebugDrawerField( - label: "OS Version", - value: "${Platform.operatingSystemVersion}", + label: 'OS Version', + value: '${Platform.operatingSystemVersion}', ), DebugDrawerField( - label: "Isolate script", - value: "${Platform.script.toString()}", + label: 'Isolate script', + value: '${Platform.script.toString()}', ), DebugDrawerField( - label: "Path separator", - value: "${Platform.pathSeparator}", + label: 'Path separator', + value: '${Platform.pathSeparator}', ), DebugDrawerField( - label: "Locale name", - value: "${Platform.localeName}", + label: 'Locale name', + value: '${Platform.localeName}', ), DebugDrawerField( - label: "Local hostname", - value: "${Platform.localHostname}", + label: 'Local hostname', + value: '${Platform.localHostname}', ), DebugDrawerField( - label: "Processors", - value: "${Platform.numberOfProcessors}", + label: 'Processors', + value: '${Platform.numberOfProcessors}', ), DebugDrawerField( - label: "Package config", - value: "${Platform.packageConfig}", + label: 'Package config', + value: '${Platform.packageConfig}', ), ], ), diff --git a/lib/src/modules/sharedprefs.dart b/lib/src/modules/sharedprefs.dart index 00e76e9..339769d 100644 --- a/lib/src/modules/sharedprefs.dart +++ b/lib/src/modules/sharedprefs.dart @@ -1,47 +1,40 @@ import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; import '../base/base_module.dart'; import '../base/module_widgets.dart'; class SharedPreferencesModule extends DebugDrawerModule { - @override - Widget build(BuildContext context) { - MediaQueryData mediaQuery = MediaQuery.of(context); - return DebugDrawerModule( - title: "Shared preferences", - child: Column( - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - DebugDrawerButton( - label: "Show shared preferences", - onPressed: () { - Navigator.of(context).push( - PageRouteBuilder( - pageBuilder: (context, _, __) => SharedPrefsPage(), - ), - ); - }, - ) - ], - ), - ); + Future _loadPrefs() async { + final pref = await SharedPreferences.getInstance(); + await pref.reload(); + print('reloaded'); + return pref; } -} -class SharedPrefsPage extends StatefulWidget { - @override - _SharedPrefsPageState createState() => _SharedPrefsPageState(); -} - -class _SharedPrefsPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text("Shared preferences"), + return DebugDrawerModule( + title: 'Shared preferences', + child: FutureBuilder( + future: _loadPrefs(), + builder: + (BuildContext context, AsyncSnapshot snapshot) { + if (!snapshot.hasData) { + return SizedBox(); + } + + return Column( + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + for (final key in snapshot.data.getKeys()) + DebugDrawerField( + label: key, value: snapshot.data.get(key).toString()), + ], + ); + }, ), - body: Container(), ); } } diff --git a/pubspec.lock b/pubspec.lock index 0381bf8..ea0620d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,5 +1,5 @@ # Generated by pub -# See https://www.dartlang.org/tools/pub/glossary#lockfile +# See https://dart.dev/tools/pub/glossary#lockfile packages: async: dependency: transitive @@ -7,35 +7,63 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.8.2" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.3.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" - cupertino_icons: - dependency: "direct main" + version: "1.15.0" + fake_async: + dependency: transitive description: - name: cupertino_icons + name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "5.2.1" flutter: dependency: "direct main" description: flutter @@ -46,55 +74,151 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.16.1" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.5" + version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.7.0" package_info: dependency: "direct main" description: name: package_info url: "https://pub.dartlang.org" source: hosted - version: "0.4.0+3" + version: "0.4.3+2" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.2" - pedantic: + version: "1.8.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.1+2" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + path_provider_windows: dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4+3" + pedantic: + dependency: "direct dev" description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.5.0" - quiver: + version: "1.9.2" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.1" + plugin_platform_interface: dependency: transitive description: - name: quiver + name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "1.0.3" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.13" shared_preferences: dependency: "direct main" description: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.2" + version: "0.5.12+4" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2+4" + shared_preferences_macos: + dependency: transitive + description: + name: shared_preferences_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.1+11" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2+7" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.1+3" sky_engine: dependency: transitive description: flutter @@ -106,56 +230,70 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.4.8" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.1" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.4" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" sdks: - dart: ">=2.2.0 <3.0.0" - flutter: ">=0.1.4 <2.0.0" + dart: ">=2.14.0 <3.0.0" + flutter: ">=1.12.13+hotfix.5" diff --git a/pubspec.yaml b/pubspec.yaml index 30b50e7..7027c8d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,68 +5,18 @@ homepage: https://github.com/sergiandreplace/flutter_debug_drawer version: 0.0.2 environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.7.0 <3.0.0" dependencies: flutter: sdk: flutter - cupertino_icons: ^0.1.2 package_info: ^0.4.0+3 shared_preferences: ^0.5.2 - dev_dependencies: flutter_test: sdk: flutter - -# For information on the generic Dart part of this file, see the -# following page: https://www.dartlang.org/tools/pub/pubspec + pedantic: flutter: - # The following line ensures that the Material Icons font is - # included with your application, so that you can use the icons in - # the material Icons class. uses-material-design: true - - # To add Flutter specific assets to your application, add an assets section, - # like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - - # For details regarding adding assets from package dependencies, see - # https://flutter.dev/assets-and-images/#from-packages - - # To add Flutter specific custom fonts to your application, add a fonts - # section here, in this "flutter" section. Each entry in this list should - # have a "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts from package dependencies, - # see https://flutter.dev/custom-fonts/#from-packages - - - # This section identifies your Flutter project as a module meant for - # embedding in a native host app. These identifiers should _not_ ordinarily - # be changed after generation - they are used to ensure that the tooling can - # maintain consistency when adding or modifying assets and plugins. - # They also do not have any bearing on your native host application's - # identifiers, which may be completely independent or the same as these. - module: - androidPackage: com.blindbugs.flutter_debug_drawer - iosBundleIdentifier: com.blindbugs.flutterDebugDrawer