From 778eaba278c9cad92b41e6e10af87b39fa631dc4 Mon Sep 17 00:00:00 2001 From: Martijn van Dijk Date: Wed, 31 Jul 2024 17:45:12 +0200 Subject: [PATCH] Update --- analysis_options.yaml | 1 + example/analysis_options.yaml | 29 +--------- example/ios/Flutter/Debug.xcconfig | 1 + example/ios/Flutter/Release.xcconfig | 1 + example/ios/Podfile | 44 +++++++++++++++ example/lib/main.dart | 4 +- example/pubspec.yaml | 83 +++------------------------- example/test/widget_test.dart | 30 ---------- lib/src/app.dart | 10 ++-- lib/src/home.dart | 8 +-- lib/src/info_page.dart | 5 +- pubspec.yaml | 1 + 12 files changed, 70 insertions(+), 147 deletions(-) create mode 100644 analysis_options.yaml create mode 100644 example/ios/Podfile delete mode 100644 example/test/widget_test.dart diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..a3be6b8 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1 @@ +include: package:flutter_lints/flutter.yaml \ No newline at end of file diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index 0d29021..a3be6b8 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -1,28 +1 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. - -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. -include: package:flutter_lints/flutter.yaml - -linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at https://dart.dev/lints. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. - rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options +include: package:flutter_lints/flutter.yaml \ No newline at end of file diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 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/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 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 b/example/ios/Podfile new file mode 100644 index 0000000..d97f17e --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +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 + + 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 + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/example/lib/main.dart b/example/lib/main.dart index 4dfb33c..72aa8ed 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -15,11 +15,11 @@ class CenteredText extends StatelessWidget { return ExamplePage(Icons.text_fields, (context) => const CenteredText()); } - const CenteredText(); + const CenteredText({super.key}); @override Widget build(BuildContext context) { - return Center( + return const Center( child: Text('Very simple example'), ); } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 7f0fa59..ff8eedd 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,90 +1,23 @@ name: example -description: "A new Flutter project." -# The following line prevents the package from being accidentally published to -# pub.dev using `flutter pub publish`. This is preferred for private packages. +description: A new Flutter project. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -# The following defines the version and build number for your application. -# A version number is three numbers separated by dots, like 1.2.43 -# followed by an optional build number separated by a +. -# Both the version and the builder number may be overridden in flutter -# build by specifying --build-name and --build-number, respectively. -# In Android, build-name is used as versionName while build-number used as versionCode. -# Read more about Android versioning at https://developer.android.com/studio/publish/versioning -# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. -# Read more about iOS versioning at -# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -# In Windows, build-name is used as the major, minor, and patch parts -# of the product and file versions while build-number is used as the build suffix. -version: 1.0.0+1 +version: 1.0.0 environment: - sdk: '>=3.4.4 <4.0.0' + sdk: ^3.3.0 + flutter: '>=3.19.0' -# Dependencies specify other packages that your package needs in order to work. -# To automatically upgrade your package dependencies to the latest versions -# consider running `flutter pub upgrade --major-versions`. Alternatively, -# dependencies can be manually updated by changing the version numbers below to -# the latest version available on pub.dev. To see which dependencies have newer -# versions available, run `flutter pub outdated`. dependencies: flutter: sdk: flutter - - - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.6 + baseflow_plugin_template: + path: ../ dev_dependencies: flutter_test: sdk: flutter + flutter_lints: ^4.0.0 - # The "flutter_lints" package below contains a set of recommended lints to - # encourage good coding practices. The lint set provided by the package is - # activated in the `analysis_options.yaml` file located at the root of your - # package. See that file for information about deactivating specific lint - # rules and activating additional ones. - flutter_lints: ^3.0.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. 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 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 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 + uses-material-design: true \ No newline at end of file diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart deleted file mode 100644 index 092d222..0000000 --- a/example/test/widget_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:example/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} diff --git a/lib/src/app.dart b/lib/src/app.dart index d53644d..9e23a0f 100644 --- a/lib/src/app.dart +++ b/lib/src/app.dart @@ -15,13 +15,13 @@ class BaseflowPluginExample extends StatelessWidget { createMaterialColor(const Color.fromRGBO(48, 49, 60, 1)); BaseflowPluginExample({ - Key? key, + super.key, required this.pluginName, required String githubURL, required String pubDevURL, required this.pages, this.appBarActions, - }) : super(key: key) { + }) { pages.add(InfoPage.createPage(pluginName, githubURL, pubDevURL)); } @@ -40,12 +40,12 @@ class BaseflowPluginExample extends StatelessWidget { splashColor: themeMaterialColor.shade50, textTheme: ButtonTextTheme.primary, ), - bottomAppBarTheme: BottomAppBarTheme( - color: const Color.fromRGBO(57, 58, 71, 1), + bottomAppBarTheme: const BottomAppBarTheme( + color: Color.fromRGBO(57, 58, 71, 1), ), hintColor: themeMaterialColor.shade500, primarySwatch: createMaterialColor(const Color.fromRGBO(48, 49, 60, 1)), - textTheme: TextTheme( + textTheme: const TextTheme( bodyLarge: TextStyle( color: Colors.white, fontSize: 16, diff --git a/lib/src/home.dart b/lib/src/home.dart index 46eb12d..00bb3f5 100644 --- a/lib/src/home.dart +++ b/lib/src/home.dart @@ -4,12 +4,12 @@ import 'package:flutter/material.dart'; /// A Flutter example demonstrating how the [pluginName] plugin could be used class AppHome extends StatefulWidget { /// Constructs the [AppHome] class - AppHome({ - Key? key, + const AppHome({ + super.key, required this.title, required this.pages, this.appBarActions, - }) : super(key: key); + }); /// The [title] of the application, which is shown in the application's /// title bar. @@ -18,7 +18,7 @@ class AppHome extends StatefulWidget { final List? appBarActions; @override - _AppHomeState createState() => _AppHomeState(); + State createState() => _AppHomeState(); } class _AppHomeState extends State { diff --git a/lib/src/info_page.dart b/lib/src/info_page.dart index 9d28e02..2451ac3 100644 --- a/lib/src/info_page.dart +++ b/lib/src/info_page.dart @@ -11,7 +11,7 @@ class InfoPage extends StatelessWidget { String githubUrl, String pubDevUrl, ) { - return new ExamplePage( + return ExamplePage( Icons.info_outline, (context) => InfoPage._( pluginName: pluginName, @@ -25,11 +25,10 @@ class InfoPage extends StatelessWidget { final String pubDevUrl; const InfoPage._({ - Key? key, required this.pluginName, required this.githubUrl, required this.pubDevUrl, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/pubspec.yaml b/pubspec.yaml index a347c03..407c83d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + flutter_lints: ^4.0.0 flutter: uses-material-design: true