From c4275d6f421c2cb3325d1e0c91ce03bafe88d34e Mon Sep 17 00:00:00 2001 From: Mangirdas Kazlauskas Date: Sat, 2 Nov 2024 13:20:40 +0200 Subject: [PATCH 1/2] feat: update project --- assets/markdown/decorator.md | 1 + .../design_pattern_categories_repository.dart | 7 ++--- ...esign_pattern_categories_repository.g.dart | 12 ++++++-- .../repositories/markdown_repository.dart | 3 +- .../repositories/markdown_repository.g.dart | 8 +++-- .../commands/change_color_command.dart | 2 +- .../randomise_properties_command.dart | 2 +- .../prototype/shapes/circle.dart | 2 +- .../prototype/shapes/rectangle.dart | 2 +- lib/main.dart | 4 +-- lib/navigation/router.dart | 7 +++-- lib/navigation/router.g.dart | 6 ++-- lib/themes.dart | 2 +- .../decorator/custom_pizza_selection.dart | 4 +-- .../decorator/decorator_example.dart | 1 + lib/widgets/image_view.dart | 2 +- pubspec.yaml | 29 ++++++++++--------- 17 files changed, 56 insertions(+), 38 deletions(-) diff --git a/assets/markdown/decorator.md b/assets/markdown/decorator.md index 6de2959..b946cb1 100644 --- a/assets/markdown/decorator.md +++ b/assets/markdown/decorator.md @@ -298,6 +298,7 @@ class _DecoratorExampleState extends State { horizontal: LayoutConstants.paddingL, ), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ diff --git a/lib/data/repositories/design_pattern_categories_repository.dart b/lib/data/repositories/design_pattern_categories_repository.dart index f3a308d..17f0499 100644 --- a/lib/data/repositories/design_pattern_categories_repository.dart +++ b/lib/data/repositories/design_pattern_categories_repository.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'package:flutter/services.dart' show rootBundle; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import '../../constants/constants.dart'; @@ -16,16 +17,14 @@ DesignPatternCategoriesRepository designPatternCategoriesRepository(_) { } @riverpod -Future> designPatternCategories( - DesignPatternCategoriesRef ref, -) { +Future> designPatternCategories(Ref ref) { final repository = ref.watch(designPatternCategoriesRepositoryProvider); return repository.get(); } @riverpod -Future designPattern(DesignPatternRef ref, String id) async { +Future designPattern(Ref ref, String id) async { final categories = await ref.watch(designPatternCategoriesProvider.future); return categories diff --git a/lib/data/repositories/design_pattern_categories_repository.g.dart b/lib/data/repositories/design_pattern_categories_repository.g.dart index dc25d5c..8bbdf4a 100644 --- a/lib/data/repositories/design_pattern_categories_repository.g.dart +++ b/lib/data/repositories/design_pattern_categories_repository.g.dart @@ -22,10 +22,12 @@ final designPatternCategoriesRepositoryProvider = allTransitiveDependencies: null, ); +@Deprecated('Will be removed in 3.0. Use Ref instead') +// ignore: unused_element typedef DesignPatternCategoriesRepositoryRef = AutoDisposeProviderRef; String _$designPatternCategoriesHash() => - r'7e5ef69bc420e15f5241981f102ee7afd974ab6e'; + r'64eb21aa9b8a453d7935dc056ac5b831acd68963'; /// See also [designPatternCategories]. @ProviderFor(designPatternCategories) @@ -40,9 +42,11 @@ final designPatternCategoriesProvider = allTransitiveDependencies: null, ); +@Deprecated('Will be removed in 3.0. Use Ref instead') +// ignore: unused_element typedef DesignPatternCategoriesRef = AutoDisposeFutureProviderRef>; -String _$designPatternHash() => r'80372c1c21e1e99f398455df68519f3943028830'; +String _$designPatternHash() => r'6850de04d434e12ead1948cca345849187431451'; /// Copied from Dart SDK class _SystemHash { @@ -178,6 +182,8 @@ class DesignPatternProvider extends AutoDisposeFutureProvider { } } +@Deprecated('Will be removed in 3.0. Use Ref instead') +// ignore: unused_element mixin DesignPatternRef on AutoDisposeFutureProviderRef { /// The parameter `id` of this provider. String get id; @@ -192,4 +198,4 @@ class _DesignPatternProviderElement String get id => (origin as DesignPatternProvider).id; } // ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/data/repositories/markdown_repository.dart b/lib/data/repositories/markdown_repository.dart index 05d58c6..9714f3d 100644 --- a/lib/data/repositories/markdown_repository.dart +++ b/lib/data/repositories/markdown_repository.dart @@ -1,4 +1,5 @@ import 'package:flutter/services.dart' show rootBundle; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import '../../constants/constants.dart'; @@ -9,7 +10,7 @@ part 'markdown_repository.g.dart'; MarkdownRepository markdownRepository(_) => const MarkdownRepository(); @riverpod -Future markdown(MarkdownRef ref, String id) { +Future markdown(Ref ref, String id) { return ref.watch(markdownRepositoryProvider).get(id); } diff --git a/lib/data/repositories/markdown_repository.g.dart b/lib/data/repositories/markdown_repository.g.dart index 025c236..c99dd01 100644 --- a/lib/data/repositories/markdown_repository.g.dart +++ b/lib/data/repositories/markdown_repository.g.dart @@ -22,8 +22,10 @@ final markdownRepositoryProvider = allTransitiveDependencies: null, ); +@Deprecated('Will be removed in 3.0. Use Ref instead') +// ignore: unused_element typedef MarkdownRepositoryRef = AutoDisposeProviderRef; -String _$markdownHash() => r'805f6990bbb5c342a781a60e6f758dcdf7b09ac1'; +String _$markdownHash() => r'2796d0b1e0771c1c7d491f96d27d3e2681d75100'; /// Copied from Dart SDK class _SystemHash { @@ -158,6 +160,8 @@ class MarkdownProvider extends AutoDisposeFutureProvider { } } +@Deprecated('Will be removed in 3.0. Use Ref instead') +// ignore: unused_element mixin MarkdownRef on AutoDisposeFutureProviderRef { /// The parameter `id` of this provider. String get id; @@ -171,4 +175,4 @@ class _MarkdownProviderElement extends AutoDisposeFutureProviderElement String get id => (origin as MarkdownProvider).id; } // ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/design_patterns/command/commands/change_color_command.dart b/lib/design_patterns/command/commands/change_color_command.dart index e60ebe5..0f7fc8e 100644 --- a/lib/design_patterns/command/commands/change_color_command.dart +++ b/lib/design_patterns/command/commands/change_color_command.dart @@ -1,4 +1,4 @@ -import 'package:faker/faker.dart'; +import 'package:faker/faker.dart' hide Color; import 'package:flutter/material.dart'; import '../command.dart'; diff --git a/lib/design_patterns/memento/command_design_pattern/commands/randomise_properties_command.dart b/lib/design_patterns/memento/command_design_pattern/commands/randomise_properties_command.dart index 89a2273..6ffa4f7 100644 --- a/lib/design_patterns/memento/command_design_pattern/commands/randomise_properties_command.dart +++ b/lib/design_patterns/memento/command_design_pattern/commands/randomise_properties_command.dart @@ -1,4 +1,4 @@ -import 'package:faker/faker.dart'; +import 'package:faker/faker.dart' hide Color; import 'package:flutter/material.dart'; import '../../memento/imemento.dart'; diff --git a/lib/design_patterns/prototype/shapes/circle.dart b/lib/design_patterns/prototype/shapes/circle.dart index 708db8d..1a1508a 100644 --- a/lib/design_patterns/prototype/shapes/circle.dart +++ b/lib/design_patterns/prototype/shapes/circle.dart @@ -1,4 +1,4 @@ -import 'package:faker/faker.dart'; +import 'package:faker/faker.dart' hide Color; import 'package:flutter/material.dart'; import '../shape.dart'; diff --git a/lib/design_patterns/prototype/shapes/rectangle.dart b/lib/design_patterns/prototype/shapes/rectangle.dart index c0990f4..74db93e 100644 --- a/lib/design_patterns/prototype/shapes/rectangle.dart +++ b/lib/design_patterns/prototype/shapes/rectangle.dart @@ -1,4 +1,4 @@ -import 'package:faker/faker.dart'; +import 'package:faker/faker.dart' hide Color; import 'package:flutter/material.dart'; import '../shape.dart'; diff --git a/lib/main.dart b/lib/main.dart index ada8d28..af0c4fe 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,7 @@ import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:url_strategy/url_strategy.dart'; +import 'package:flutter_web_plugins/url_strategy.dart'; import 'app.dart'; @@ -10,7 +10,7 @@ Future main() async { await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); - setPathUrlStrategy(); + usePathUrlStrategy(); runApp(const ProviderScope(child: App())); } diff --git a/lib/navigation/router.dart b/lib/navigation/router.dart index 862e324..df80156 100644 --- a/lib/navigation/router.dart +++ b/lib/navigation/router.dart @@ -10,8 +10,11 @@ part 'router.g.dart'; @riverpod GoRouter router(_) => GoRouter( routes: $appRoutes, - redirect: (context, state) => - state.location.isEmpty ? const MainMenuRoute().location : null, + redirect: (context, state) { + final uri = state.uri.toString(); + + return uri.isEmpty ? const MainMenuRoute().location : null; + }, ); @TypedGoRoute( diff --git a/lib/navigation/router.g.dart b/lib/navigation/router.g.dart index fc06fb4..06d496f 100644 --- a/lib/navigation/router.g.dart +++ b/lib/navigation/router.g.dart @@ -62,7 +62,7 @@ extension $DesignPatternDetailsRouteExtension on DesignPatternDetailsRoute { // RiverpodGenerator // ************************************************************************** -String _$routerHash() => r'ad2e290396c92a7229e87dc91b315b4471fe6b4c'; +String _$routerHash() => r'7aea5ccfc73a19a14afda1df517396c9a3ca6182'; /// See also [router]. @ProviderFor(router) @@ -75,6 +75,8 @@ final routerProvider = AutoDisposeProvider.internal( allTransitiveDependencies: null, ); +@Deprecated('Will be removed in 3.0. Use Ref instead') +// ignore: unused_element typedef RouterRef = AutoDisposeProviderRef; // ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member +// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/themes.dart b/lib/themes.dart index 99791d7..6246001 100644 --- a/lib/themes.dart +++ b/lib/themes.dart @@ -4,7 +4,7 @@ const lightBackgroundColor = Color(0xFFECECEC); final lightTheme = ThemeData.from( colorScheme: const ColorScheme.light( - background: lightBackgroundColor, + surface: lightBackgroundColor, primary: Colors.grey, ), ).copyWith( diff --git a/lib/widgets/design_patterns/decorator/custom_pizza_selection.dart b/lib/widgets/design_patterns/decorator/custom_pizza_selection.dart index aa8429f..7928be7 100644 --- a/lib/widgets/design_patterns/decorator/custom_pizza_selection.dart +++ b/lib/widgets/design_patterns/decorator/custom_pizza_selection.dart @@ -51,8 +51,8 @@ class _ChoiceChip extends StatelessWidget { final color = selected ? Colors.white : Colors.black; return ChoiceChip( - color: MaterialStateProperty.resolveWith((states) { - if (states.contains(MaterialState.selected)) { + color: WidgetStateProperty.resolveWith((states) { + if (states.contains(WidgetState.selected)) { return Colors.black; } diff --git a/lib/widgets/design_patterns/decorator/decorator_example.dart b/lib/widgets/design_patterns/decorator/decorator_example.dart index 426290e..5025129 100644 --- a/lib/widgets/design_patterns/decorator/decorator_example.dart +++ b/lib/widgets/design_patterns/decorator/decorator_example.dart @@ -56,6 +56,7 @@ class _DecoratorExampleState extends State { horizontal: LayoutConstants.paddingL, ), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ diff --git a/lib/widgets/image_view.dart b/lib/widgets/image_view.dart index 096d162..541a97e 100644 --- a/lib/widgets/image_view.dart +++ b/lib/widgets/image_view.dart @@ -114,7 +114,7 @@ class _ImageViewState extends State return Scaffold( appBar: AppBar( elevation: 0, - backgroundColor: Theme.of(context).colorScheme.background, + backgroundColor: Theme.of(context).colorScheme.surface, leading: const CloseButton(color: Colors.black), ), body: GestureDetector( diff --git a/pubspec.yaml b/pubspec.yaml index 9dbfda9..35682f3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -9,27 +9,28 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - cupertino_icons: ^1.0.5 - faker: ^2.1.0 + cupertino_icons: ^1.0.8 + faker: ^2.2.0 flutter: sdk: flutter - flutter_markdown: ^0.6.14 - flutter_riverpod: ^2.3.6 - font_awesome_flutter: ^10.4.0 - go_router: ^7.0.1 + flutter_markdown: ^0.7.4+1 + flutter_riverpod: ^2.6.1 + flutter_web_plugins: + sdk: flutter + font_awesome_flutter: ^10.7.0 + go_router: ^14.3.0 highlight: ^0.7.0 - riverpod_annotation: ^2.1.1 - url_launcher: ^6.1.11 - url_strategy: ^0.2.0 - xml: ^6.3.0 + riverpod_annotation: ^2.6.1 + url_launcher: ^6.3.1 + xml: ^6.5.0 dev_dependencies: - build_runner: ^2.4.4 + build_runner: ^2.4.13 flutter_test: sdk: flutter - go_router_builder: ^2.0.1 - lint: ^2.1.2 - riverpod_generator: ^2.2.3 + go_router_builder: ^2.7.1 + lint: ^2.3.0 + riverpod_generator: ^2.6.2 flutter: uses-material-design: true From bc351d530e93ebfcb7f39428624a56157c19ac80 Mon Sep 17 00:00:00 2001 From: Mangirdas Kazlauskas Date: Sat, 2 Nov 2024 13:28:15 +0200 Subject: [PATCH 2/2] feat: update web project --- .metadata | 24 ++++++++++++++++++++++-- web/index.html | 24 ++---------------------- web/manifest.json | 12 ++++++++++++ 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.metadata b/.metadata index aeb01ee..b603e3b 100644 --- a/.metadata +++ b/.metadata @@ -4,7 +4,27 @@ # This file should be version controlled and should not be manually edited. version: - revision: 2d2a1ffec95cc70a3218872a2cd3f8de4933c42f - channel: stable + revision: "603104015dd692ea3403755b55d07813d5cf8965" + channel: "stable" project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 603104015dd692ea3403755b55d07813d5cf8965 + base_revision: 603104015dd692ea3403755b55d07813d5cf8965 + - platform: web + create_revision: 603104015dd692ea3403755b55d07813d5cf8965 + base_revision: 603104015dd692ea3403755b55d07813d5cf8965 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/web/index.html b/web/index.html index 4d44ab8..7110aba 100644 --- a/web/index.html +++ b/web/index.html @@ -1,17 +1,7 @@ - - + @@ -40,16 +30,6 @@

Welcome to Flutter Design Patterns! 👋

- - - + diff --git a/web/manifest.json b/web/manifest.json index 9316028..70365ec 100644 --- a/web/manifest.json +++ b/web/manifest.json @@ -18,6 +18,18 @@ "src": "icons/Icon-512.png", "sizes": "512x512", "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" } ] }