pull/2701/head
Eric Windmill 1 month ago
parent 8b19871277
commit 78b847cf12

@ -1,10 +1,10 @@
name: flutter_module_using_plugin
name: flutter_module_using_plugin_android_view
description: An example Flutter module that uses a plugin.
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -2,11 +2,11 @@ name: flutter_module_books
description: A Flutter module using the Pigeon package to demonstrate
integrating Flutter in a realistic scenario where the existing platform app
already has business logic and middleware constraints.
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -1,10 +1,10 @@
name: flutter_module
name: flutter_module_fullscreen
description: An example Flutter module.
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -1,10 +1,10 @@
name: multiple_flutters_module
description: A module that is embedded in the multiple_flutters_ios and multiple_flutters_android sample code.
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -1,10 +1,10 @@
name: flutter_module_using_plugin
description: An example Flutter module that uses a plugin.
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -1,10 +1,10 @@
name: flutter_module
description: An example Flutter module.
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -1,13 +1,14 @@
name: analysis_defaults
description: Analysis defaults for flutter/samples
publish_to: none
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
# NOTE: Code is not allowed in this package. Do not add more dependencies.
# The `flutter_lints` dependency is required for `lib/flutter.yaml`.
dependencies:
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0

@ -1,12 +1,11 @@
name: splash_screen_sample
description: A sample Flutter app with animated splash screen on Android 12.
publish_to: "none"
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.35.0-0.1.pre <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -2,15 +2,16 @@ name: animations
description: A new Flutter project.
version: 1.0.0+1
publish_to: none
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
sdk: flutter
flutter_animate: ^4.1.0
go_router: ^15.0.0
go_router: ^16.0.0
window_size: # plugin is not yet part of the flutter framework
git:
url: https://github.com/google/flutter-desktop-embedding.git

@ -2,9 +2,10 @@ name: asset_transformation
description: "A new Flutter project."
publish_to: 'none'
version: 0.1.0
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
@ -14,7 +15,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0
vector_graphics_compiler: ^1.1.11+1
grayscale_transformer:
path: ./grayscale_transformer

@ -1,12 +1,13 @@
name: background_isolate_channels
description: A new Flutter project.
resolution: workspace
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
cupertino_icons: ^1.0.2

@ -2,9 +2,10 @@ name: client
description: A Flutter app which communicates with a Dart backend using shared business logic.
publish_to: "none"
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
cupertino_icons: ^1.0.2
@ -15,7 +16,7 @@ dependencies:
path: ../shared
dev_dependencies:
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0
flutter_test:
sdk: flutter

@ -2,9 +2,10 @@ name: server
description: A server app using the shelf package and Docker.
version: 1.0.0
publish_to: "none"
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
args: ^2.0.0

@ -1,9 +1,10 @@
name: shared
description: Common data models required by our client and server
version: 1.0.0
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
freezed_annotation: ">=2.1.0 <4.0.0"

@ -1,5 +1,7 @@
name: context_menus
description: A new Flutter project.
version: 1.0.0+1
resolution: workspace
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
@ -17,10 +19,10 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# 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
environment:
sdk: '>=3.35.0-0.1.pre <4.0.0'
sdk: '^3.5.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions

@ -2,9 +2,10 @@ name: date_planner
description: "An iOS-style date planner."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 0.1.0
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
@ -15,4 +16,4 @@ dependencies:
uuid:
dev_dependencies:
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0

@ -1,5 +1,8 @@
name: deeplink_store_example
description: A new Flutter project.
version: 1.0.0+1
resolution: workspace
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
@ -16,10 +19,10 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# 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
environment:
sdk: '>=3.35.0-0.1.pre <4.0.0'
sdk: '^3.5.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
@ -35,7 +38,7 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
shrine_images: ^2.0.2
go_router: ^15.0.0
go_router: ^16.0.0
dev_dependencies:
flutter_test:
@ -45,7 +48,7 @@ dev_dependencies:
# 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: ^5.0.0
flutter_lints: ^6.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

@ -2,9 +2,10 @@ name: desktop_photo_search
description: Search for Photos, using the Unsplash API.
publish_to: 'none'
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
built_collection: ^5.1.1

@ -1,10 +1,11 @@
name: desktop_photo_search
name: desktop_photo_search_material
description: Search for Photos, using the Unsplash API.
publish_to: 'none'
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
built_collection: ^5.1.1
@ -20,7 +21,6 @@ dependencies:
git:
url: https://github.com/google/flutter-desktop-embedding.git
path: plugins/menubar
ref: 6c66ad23ee79749f30a8eece542cf54eaf157ed8
provider: ^6.0.5
transparent_image: ^2.0.1
url_launcher: ^6.1.12
@ -29,7 +29,6 @@ dependencies:
git:
url: https://github.com/google/flutter-desktop-embedding.git
path: plugins/window_size
ref: 6c66ad23ee79749f30a8eece542cf54eaf157ed8
dev_dependencies:
analysis_defaults:

@ -2,8 +2,9 @@ name: dynamic_theme
description: "Sample app for the google_generative_ai package"
publish_to: 'none'
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
@ -15,7 +16,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0
flutter:
uses-material-design: true

@ -1,7 +1,6 @@
# Deprecation warning
# Deprecated
The `experimental` directory will be retired with the release of Flutter 3.32,
tentatively scheduled for May 2025. At that time, remaining samples will be deleted.
The `experimental` directory has been deprecated. All samples within have been deleted or moved to [github.com/flutter/demos][]
---

@ -8,7 +8,6 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_maps_webservice/places.dart';
import 'api_key.dart';
@ -17,7 +16,6 @@ const initialPosition = LatLng(37.7786, -122.4375);
// Hue used by the Google Map Markers to match the theme
const _pinkHue = 350.0;
// Places API client used for Place Photos
final _placesApiClient = GoogleMapsPlaces(apiKey: googleMapsApiKey);
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
@ -73,24 +71,24 @@ class _HomePageState extends State<HomePage> {
builder: (context, snapshot) {
return switch (snapshot) {
AsyncSnapshot(hasError: true) => Center(
child: Text('Error: ${snapshot.error}'),
),
child: Text('Error: ${snapshot.error}'),
),
AsyncSnapshot(hasData: false) => const Center(
child: Text('Loading...'),
),
child: Text('Loading...'),
),
_ => Stack(
children: [
StoreMap(
documents: snapshot.data!.docs,
initialPosition: initialPosition,
mapController: _mapController,
),
StoreCarousel(
mapController: _mapController,
documents: snapshot.data!.docs,
),
],
),
children: [
StoreMap(
documents: snapshot.data!.docs,
initialPosition: initialPosition,
mapController: _mapController,
),
StoreCarousel(
mapController: _mapController,
documents: snapshot.data!.docs,
),
],
),
};
},
),
@ -255,7 +253,8 @@ class StoreMap extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GoogleMap(
initialCameraPosition: CameraPosition(target: initialPosition, zoom: 12),
initialCameraPosition:
CameraPosition(target: initialPosition, zoom: 12),
markers: documents
.map(
(document) => Marker(

@ -1,9 +1,10 @@
name: flutter_maps_firestore
description: A new Flutter project.
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
@ -11,7 +12,6 @@ dependencies:
cloud_firestore: ">=4.6.0 <6.0.0"
firebase_core: ">=2.11.0 <4.0.0"
google_maps_flutter: ^2.2.6
google_maps_webservice: ^0.0.20-nullsafety.5
location: ^7.0.0
dev_dependencies:

@ -2,9 +2,10 @@ name: form_app
description: A sample demonstrating different types of forms and best practices
publish_to: "none"
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
@ -18,7 +19,7 @@ dependencies:
git:
url: https://github.com/google/flutter-desktop-embedding.git
path: plugins/window_size
go_router: ^15.0.0
go_router: ^16.0.0
dev_dependencies:
analysis_defaults:

@ -1,20 +1,21 @@
name: game_template
description: A mobile game built in Flutter.
version: 0.0.1+1
resolution: workspace
# Prevent accidental publishing to pub.dev.
publish_to: 'none'
version: 0.0.1+1
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
sdk: flutter
audioplayers: ^6.0.0
cupertino_icons: ^1.0.2
go_router: ^15.0.0
go_router: ^16.0.0
logging: ^1.1.0
provider: ^6.0.2
shared_preferences: ^2.0.13
@ -29,7 +30,7 @@ dependencies:
in_app_purchase: ^3.0.1 # In-app purchases
dev_dependencies:
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.14.0

@ -2,8 +2,9 @@ name: gemini_tasks
description: "Sample app for the google_generative_ai package"
publish_to: 'none'
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
@ -15,7 +16,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0
flutter:
uses-material-design: true

@ -1,10 +1,11 @@
name: google_maps_in_flutter
description: A new Flutter project.
resolution: workspace
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -2,10 +2,11 @@ name: infinitelist
description: >
A sample implementation of an infinite list.
publish_to: none
resolution: workspace
version: 1.0.0+1
environment:
sdk: '>=3.35.0-0.1.pre <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -1,12 +1,11 @@
name: ios_app_clip
description: An example Flutter project that can build as an App Clip.
publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.35.0-0.1.pre <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -2,9 +2,10 @@ name: isolate_example
description: A Flutter sample to demonstrate isolates
version: 1.0.0+1
publish_to: none
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -1,10 +0,0 @@
## `jsonexample` sample retired
The `jsonexample` sample has reached the end of it's useful life. It was great code
when it has written, but the world has changed. Dart 3 introduced Patterns and
records. There is also various JSON parsing tools like `json_serializable`.
For further information, please see:
- The [Dive into Dart's patterns and records](https://codelabs.developers.google.com/codelabs/dart-patterns-records)
codelab for a deep dive into Dart 3's patterns and records with an application to parsing JSON
- The Flutter.dev documentation on [JSON and serialization](https://docs.flutter.dev/data-and-backend/serialization/json)

@ -2,13 +2,12 @@ name: material_3_demo
description:
A Flutter project showcasing supported Material 3 components, typography, color system and elevation.
Supports different light/dark mode, color seed, and comparison to Material 2.
publish_to: "none"
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -2,16 +2,17 @@ name: bookstore
description: Navigation and routing sample app
publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
adaptive_navigation: ^0.0.3
cupertino_icons: ^1.0.2
flutter:
sdk: flutter
go_router: ^15.0.0
go_router: ^16.0.0
url_launcher: ^6.1.1
window_size:
git:

@ -1,5 +1,8 @@
name: pedometer_example
description: Demonstrates how to use the pedometer plugin.
version: 1.0.0+1
resolution: workspace
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
@ -16,10 +19,10 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# 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
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
@ -41,7 +44,7 @@ dependencies:
ffi: ^2.1.2
intl: ^0.20.0
jni: ^0.13.0
jni: ^0.14.2
fl_chart: ^0.70.0
dev_dependencies:
@ -53,7 +56,7 @@ dev_dependencies:
# 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: ^5.0.0
flutter_lints: ^6.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

@ -2,23 +2,24 @@ name: pedometer
description: A new Flutter FFI plugin project.
version: 0.0.1
publish_to: none
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
sdk: flutter
plugin_platform_interface: ^2.1.8
jni: ^0.13.0
jni: ^0.14.2
ffi: ^2.1.2
dev_dependencies:
ffigen: ^19.1.0
jnigen: ^0.13.1
jnigen: ^0.14.2
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

@ -1,10 +1,10 @@
name: place_tracker
description: A new Flutter project.
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.35.0-0.1.pre <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
@ -13,7 +13,7 @@ dependencies:
google_maps_flutter: ^2.2.0
provider: ^6.0.2
uuid: ^4.0.0
go_router: ">=10.0.0 <16.0.0"
go_router: ^16.0.0
dev_dependencies:
analysis_defaults:

@ -1,16 +1,16 @@
name: platform_channels
description: A new Flutter project.
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.35.0-0.1.pre <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.3
go_router: ">=10.1.0 <16.0.0"
go_router: ^16.0.0
dev_dependencies:
analysis_defaults:

@ -1,9 +1,10 @@
name: platform_design
description: A project showcasing a Flutter app following different platform IA conventions.
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.35.0-0.1.pre <4.0.0'
sdk: '^3.5.0'
dependencies:
english_words: ^4.0.0

@ -1,10 +1,10 @@
name: platform_view_swift
description: A new Flutter project.
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.35.0-0.1.pre <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -3,9 +3,10 @@ description: >
The starter Flutter application, but using Provider to manage state.
publish_to: none
version: 1.0.0
resolution: workspace
environment:
sdk: '>=3.35.0-0.1.pre <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -1,16 +1,16 @@
name: provider_shopper
description: A shopping app sample that uses Provider for state management.
publish_to: none
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
sdk: flutter
go_router: ^15.0.0
go_router: ^16.0.0
provider: ^6.0.2
window_size:
git:

@ -0,0 +1,51 @@
name: samples
description: A collection of samples for Dart and Flutter.
environment:
sdk: '^3.5.0'
workspace:
- add_to_app/android_view/flutter_module_using_plugin
- add_to_app/books/flutter_module_books
- add_to_app/fullscreen/flutter_module
- add_to_app/multiple_flutters/multiple_flutters_module
- add_to_app/plugin/flutter_module_using_plugin
- add_to_app/prebuilt_module/flutter_module
- analysis_defaults
- android_splash_screen
- animations
- asset_transformation
- background_isolate_channels
- code_sharing/client
- code_sharing/server
- code_sharing/shared
- context_menus
- date_planner
- deeplink_store_example
- desktop_photo_search/fluent_ui
- desktop_photo_search/material
- dynamic_theme
- form_app
- flutter_maps_firestore
- game_template
- gemini_tasks
- google_maps
- infinite_list
- ios_app_clip
- isolate_example
- material_3_demo
- navigation_and_routing
- pedometer
- pedometer/example
- platform_channels
- platform_design
- platform_view_swift
- provider_counter
- provider_shopper
- simple_shader
- simplistic_calculator
- simplistic_editor
- testing_app
- veggieseasons
- web_embedding/element_embedding_demo
- web_embedding/ng-flutter/flutter

@ -2,9 +2,10 @@ name: simple_shader
description: Using a shader, simply.
publish_to: 'none'
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:

@ -2,9 +2,10 @@ name: simplistic_calculator
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
auto_size_text: ^3.0.0
@ -18,7 +19,7 @@ dependencies:
math_expressions: ^2.3.0
window_size:
git:
url: https://github.com/google/flutter-desktop-embedding
url: https://github.com/google/flutter-desktop-embedding.git
path: plugins/window_size
dev_dependencies:

@ -1,5 +1,7 @@
name: simplistic_editor
description: A new Flutter project.
version: 1.0.0+1
resolution: workspace
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
@ -15,10 +17,10 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: '>=3.35.0-0.1.pre <4.0.0'
sdk: '^3.5.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions

@ -1,17 +1,17 @@
name: testing_app
description: A sample that shows testing in Flutter.
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.3
provider: ^6.0.2
go_router: ">=10.0.0 <16.0.0"
go_router: ^16.0.0
dev_dependencies:
analysis_defaults:

@ -0,0 +1,12 @@
name: release_cleaner
description: A tool to automate release cleanup for the samples monorepo.
environment:
sdk: '>=3.0.0 <4.0.0'
dependencies:
args: ^2.4.2
io: ^1.0.4
path: ^1.9.0
pub_semver: ^2.1.4
yaml: ^3.1.2
yaml_edit: ^2.1.1

@ -0,0 +1,274 @@
import 'dart:io';
import 'package:args/args.dart';
import 'package:io/ansi.dart';
import 'package:path/path.dart' as p;
import 'package:pub_semver/pub_semver.dart';
import 'package:yaml/yaml.dart';
import 'package:yaml_edit/yaml_edit.dart';
const String logDir = 'logs';
late File _logFile;
void main(List<String> arguments) async {
final parser = ArgParser()
..addFlag('dry-run',
negatable: false,
help:
'Prints the commands that would be executed, but does not run them.');
final argResults = parser.parse(arguments);
final isDryRun = argResults['dry-run'] as bool;
setupLogging();
log(
styleBold
.wrap('Flutter Monorepo Update Script Started: ${DateTime.now()}')!,
stdout);
log(blue.wrap('Log file: ${_logFile.path}')!, stdout);
if (isDryRun) {
log(yellow.wrap('--- DRY RUN MODE ---')!, stdout);
}
if (!await isFlutterInstalled()) {
log(red.wrap('Flutter is not installed or not in PATH')!, stderr);
exit(1);
}
log(styleBold.wrap('\n=========================================')!, stdout);
log(styleBold.wrap('Upgrading Flutter SDK')!, stdout);
log(styleBold.wrap('=========================================')!, stdout);
if (!await runCommand('flutter', ['upgrade'], isDryRun: isDryRun)) {
log(red.wrap('Failed to upgrade Flutter SDK')!, stderr);
exit(1);
}
final flutterVersion = await getFlutterVersion();
if (flutterVersion == null) {
log(red.wrap('Failed to get Flutter version.'), stderr);
exit(1);
}
log(blue.wrap('Flutter upgraded to version: $flutterVersion'), stdout);
final packages = await getWorkspacePackages();
if (packages.isEmpty) {
log(yellow.wrap('No packages found in the root pubspec.yaml workspace.'),
stdout);
exit(0);
}
log(
blue.wrap(
'Found ${packages.length} Flutter project(s): ${packages.join(', ')}'),
stdout);
final failedProjects = <String>[];
for (final packagePath in packages) {
final success = await processProject(packagePath, flutterVersion, isDryRun);
if (!success) {
failedProjects.add(packagePath);
}
}
printSummary(packages.length, failedProjects);
log(
styleBold.wrap(
'\nFlutter Monorepo Update Script Completed: ${DateTime.now()}'),
stdout);
if (failedProjects.isNotEmpty) {
exit(1);
}
}
void setupLogging() {
final logsDir = Directory(logDir);
if (!logsDir.existsSync()) {
logsDir.createSync(recursive: true);
}
final timestamp = DateTime.now().toIso8601String().replaceAll(':', '-');
_logFile = File(p.join(logDir, 'flutter_update_$timestamp.log'));
}
void log(String? message, IOSink sink) {
if (message == null) return;
sink.writeln(message);
_logFile.writeAsStringSync(
'${overrideAnsiOutput(false, () => message)}\n',
mode: FileMode.append,
);
}
Future<bool> isFlutterInstalled() async {
try {
final result = await Process.run('flutter', ['--version']);
return result.exitCode == 0;
} catch (e) {
return false;
}
}
Future<String?> getFlutterVersion() async {
try {
final result = await Process.run('flutter', ['--version', '--machine']);
if (result.exitCode == 0) {
final json = loadYaml(result.stdout as String) as YamlMap;
return json['frameworkVersion'] as String?;
}
} catch (e) {
log(red.wrap('Error getting Flutter version: $e'), stderr);
}
return null;
}
Future<List<String>> getWorkspacePackages() async {
final rootPubspec = File('pubspec.yaml');
if (!rootPubspec.existsSync()) {
log(red.wrap('Root pubspec.yaml not found!'), stderr);
return [];
}
try {
final content = await rootPubspec.readAsString();
final yaml = loadYaml(content) as YamlMap;
final workspace = yaml['workspace'] as YamlList?;
if (workspace != null) {
return workspace.nodes.map((node) => node.value as String).toList();
}
} catch (e) {
log(red.wrap('Error reading workspace packages: $e'), stderr);
}
return [];
}
Future<bool> processProject(
String projectPath, String flutterVersion, bool isDryRun) async {
final projectName = p.basename(projectPath);
final projectDir = Directory(projectPath);
if (!projectDir.existsSync()) {
log(red.wrap('Project directory not found: $projectPath'), stderr);
return false;
}
log(styleBold.wrap('\n========================================='), stdout);
log(styleBold.wrap('Processing project: $projectName'), stdout);
log(styleBold.wrap('========================================='), stdout);
log(blue.wrap('Updating SDK constraints to use Flutter $flutterVersion'),
stdout);
if (!isDryRun) {
if (!await updateSdkConstraints(projectPath, flutterVersion)) {
log(red.wrap('Failed to update SDK constraints for $projectName'),
stderr);
return false;
}
}
final commands = [
Command('Updating dependencies...', 'flutter', ['pub', 'upgrade']),
Command('Running pub get...', 'flutter', ['pub', 'get']),
Command('Running dart analyze...', 'dart', ['analyze']),
Command('Running dart format...', 'dart', ['format', '.']),
Command('Running tests...', 'flutter', ['test']),
];
for (final command in commands) {
log(blue.wrap(command.description), stdout);
if (!await runCommand(command.executable, command.arguments,
workingDirectory: projectPath, isDryRun: isDryRun)) {
log(red.wrap('${command.description} failed for $projectName'), stderr);
// For analyze, format, and test, we might not want to hard fail the whole script.
// The original script continued on format errors but failed on test errors.
if (command.executable == 'flutter' &&
command.arguments.first == 'test') {
return false;
}
}
}
log(green.wrap('Successfully processed $projectName'), stdout);
return true;
}
Future<bool> updateSdkConstraints(
String projectDir, String versionString) async {
final pubspecFile = File(p.join(projectDir, 'pubspec.yaml'));
if (!pubspecFile.existsSync()) {
log(red.wrap('pubspec.yaml not found in $projectDir'), stderr);
return false;
}
try {
final version = Version.parse(versionString);
final nextMajor = version.major + 1;
final newConstraint = "'>=${version} <$nextMajor.0.0'";
final content = await pubspecFile.readAsString();
final editor = YamlEditor(content);
editor.update(['environment', 'sdk'], newConstraint);
await pubspecFile.writeAsString(editor.toString());
log(
blue.wrap(
'Updated Dart SDK constraint in $projectDir to: $newConstraint'),
stdout);
return true;
} catch (e) {
log(red.wrap('Failed to update SDK constraint in $projectDir: $e'), stderr);
return false;
}
}
Future<bool> runCommand(String executable, List<String> arguments,
{String? workingDirectory, bool isDryRun = false}) async {
final commandString = '$executable ${arguments.join(' ')}';
if (isDryRun) {
log(
yellow.wrap(
' [DRY RUN] Would execute: `$commandString` in `${workingDirectory ?? '.'}`'),
stdout);
return true;
}
final process = await Process.start(executable, arguments,
workingDirectory: workingDirectory, runInShell: true);
final stdoutFuture =
process.stdout.transform(SystemEncoding().decoder).forEach((line) {
log(line, stdout);
});
final stderrFuture =
process.stderr.transform(SystemEncoding().decoder).forEach((line) {
log(red.wrap(line), stderr);
});
await Future.wait([stdoutFuture, stderrFuture]);
return await process.exitCode == 0;
}
void printSummary(int total, List<String> failed) {
log(styleBold.wrap('\n========================================='), stdout);
log(styleBold.wrap('Update Summary'), stdout);
log(styleBold.wrap('========================================='), stdout);
log(blue.wrap('Total projects processed: $total'), stdout);
log(green.wrap('Successful: ${total - failed.length}'), stdout);
if (failed.isNotEmpty) {
log(red.wrap('Failed: ${failed.length}'), stderr);
log(red.wrap('Failed projects: ${failed.join(', ')}'), stderr);
}
}
class Command {
final String description;
final String executable;
final List<String> arguments;
Command(this.description, this.executable, this.arguments);
}

@ -2,8 +2,6 @@
set -e
DIR="${BASH_SOURCE%/*}"
# Configuration
LOGS_DIR="logs"
LOG_FILE="$LOGS_DIR/flutter_update_$(date +%Y-%m-%d_%H-%M-%S).log"

@ -21,7 +21,12 @@ class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final index = _getSelectedIndex(GoRouter.of(context).location);
final String location = GoRouter.of(context)
.routerDelegate
.currentConfiguration
.uri
.toString();
final index = _getSelectedIndex(location);
return RestorationScope(
restorationId: restorationId,
child: CupertinoPageScaffold(

@ -67,6 +67,11 @@ class VeggieHeadline extends StatelessWidget {
@override
Widget build(BuildContext context) {
final themeData = CupertinoTheme.of(context);
final String location = GoRouter.of(context)
.routerDelegate
.currentConfiguration
.uri
.toString();
return GestureDetector(
onTap: () {
@ -74,7 +79,7 @@ class VeggieHeadline extends StatelessWidget {
// so navigate to the absolute route, which can be either
// `/favorites/details/${veggie.id}` or `/search/details/${veggie.id}`
// see https://github.com/flutter/flutter/issues/108177
context.go('${GoRouter.of(context).location}/details/${veggie.id}');
context.go('$location/details/${veggie.id}');
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
@ -93,7 +98,8 @@ class VeggieHeadline extends StatelessWidget {
children: [
Row(
children: [
Text(veggie.name, style: Styles.headlineName(themeData)),
Text(veggie.name,
style: Styles.headlineName(themeData)),
..._buildSeasonDots(veggie.seasons),
],
),

@ -1,11 +1,11 @@
name: veggieseasons
description: An iOS app that shows the fruits and veggies currently in season.
publish_to: none
version: 1.2.0
resolution: workspace
environment:
sdk: '>= <1.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
@ -17,11 +17,11 @@ dependencies:
shared_preferences: ^2.0.14
window_size:
git:
url: https://github.com/google/flutter-desktop-embedding
url: https://github.com/google/flutter-desktop-embedding.git
path: plugins/window_size
# TODO: https://github.com/flutter/samples/issues/1838
# go_router ^7.1.0 is breaking the state restoration tests
go_router: 7.0.2
go_router: ^16.0.0
dev_dependencies:
analysis_defaults:

@ -2,9 +2,10 @@ name: element_embedding_demo
description: A small app to be embedded into a HTML element (see web/index.html)
publish_to: 'none'
version: 1.0.0+1
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
@ -13,7 +14,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0
flutter:
uses-material-design: true

@ -2,9 +2,10 @@ name: ng_companion
description: A flutter app with a counter that can be manipulated from JS.
publish_to: none
version: 1.0.0
resolution: workspace
environment:
sdk: '>=3.9.0-0 <4.0.0'
sdk: '^3.5.0'
dependencies:
flutter:
@ -14,7 +15,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0
flutter:
uses-material-design: true

@ -1 +1,6 @@
Read https://dart.dev/tools/pub/workspaces
You are a Dart developer that maintains packages. Your current task is to incrementally update monorepos to use pub workspaces.
- Read https://dart.dev/tools/pub/workspaces
- Create a gloabl pubspec.yaml and populate it
- Determine 5 packages in this repository that could easily be migrated to workspaces.
- Migrate those 5 packages.
Loading…
Cancel
Save