mirror of
https://github.com/flutter/samples.git
synced 2025-11-09 06:18:49 +00:00
Flutter 3.24 update, Add CarouselView examples to demo 3 (#2377)
This PR is to include `CarouselView` to M3 demo app. https://github.com/user-attachments/assets/7db76c06-aa7e-4461-9baa-51fd5c4e6b38 ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. --------- Co-authored-by: Eric Windmill <ewindmill@google.com>
This commit is contained in:
@@ -242,6 +242,7 @@ class Containment extends StatelessWidget {
|
|||||||
return const ComponentGroupDecoration(label: 'Containment', children: [
|
return const ComponentGroupDecoration(label: 'Containment', children: [
|
||||||
BottomSheetSection(),
|
BottomSheetSection(),
|
||||||
Cards(),
|
Cards(),
|
||||||
|
Carousels(),
|
||||||
Dialogs(),
|
Dialogs(),
|
||||||
Dividers(),
|
Dividers(),
|
||||||
// TODO: Add Lists, https://github.com/flutter/flutter/issues/114006
|
// TODO: Add Lists, https://github.com/flutter/flutter/issues/114006
|
||||||
@@ -2416,6 +2417,65 @@ class _SearchAnchorsState extends State<SearchAnchors> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Carousels extends StatelessWidget {
|
||||||
|
const Carousels({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ComponentDecoration(
|
||||||
|
label: 'Carousel',
|
||||||
|
tooltipMessage: 'Use CarouselView',
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.only(left: 8.0),
|
||||||
|
child: Text('Uncontained Carousel'),
|
||||||
|
),
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints.tightFor(height: 150),
|
||||||
|
child: CarouselView(
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
side: BorderSide(color: Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
shrinkExtent: 100,
|
||||||
|
itemExtent: 180,
|
||||||
|
children: List<Widget>.generate(20, (index) {
|
||||||
|
return Center(
|
||||||
|
child: Text('Item $index'),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
colDivider,
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.only(left: 8.0),
|
||||||
|
child: Text('Uncontained Carousel with snapping effect'),
|
||||||
|
),
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints.tightFor(height: 150),
|
||||||
|
child: CarouselView(
|
||||||
|
itemSnapping: true,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
side: BorderSide(color: Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
shrinkExtent: 100,
|
||||||
|
itemExtent: 180,
|
||||||
|
children: List<Widget>.generate(20, (index) {
|
||||||
|
return Center(
|
||||||
|
child: Text('Item $index'),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ComponentDecoration extends StatefulWidget {
|
class ComponentDecoration extends StatefulWidget {
|
||||||
const ComponentDecoration({
|
const ComponentDecoration({
|
||||||
super.key,
|
super.key,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import 'package:material_3_demo/main.dart';
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('Default main page shows all M3 components', (tester) async {
|
testWidgets('Default main page shows all M3 components', (tester) async {
|
||||||
widgetSetup(tester, 800, windowHeight: 7000);
|
widgetSetup(tester, 800, windowHeight: 7500);
|
||||||
await tester.pumpWidget(const App());
|
await tester.pumpWidget(const App());
|
||||||
|
|
||||||
// Elements on the app bar
|
// Elements on the app bar
|
||||||
@@ -67,6 +67,9 @@ void main() {
|
|||||||
expect(find.widgetWithText(Cards, 'Filled'), findsOneWidget);
|
expect(find.widgetWithText(Cards, 'Filled'), findsOneWidget);
|
||||||
expect(find.widgetWithText(Cards, 'Outlined'), findsOneWidget);
|
expect(find.widgetWithText(Cards, 'Outlined'), findsOneWidget);
|
||||||
|
|
||||||
|
// Carousels
|
||||||
|
expect(find.byType(CarouselView), findsNWidgets(2));
|
||||||
|
|
||||||
// Dialogs
|
// Dialogs
|
||||||
expect(find.widgetWithText(TextButton, 'Show dialog'), findsOneWidget);
|
expect(find.widgetWithText(TextButton, 'Show dialog'), findsOneWidget);
|
||||||
expect(find.widgetWithText(TextButton, 'Show full-screen dialog'),
|
expect(find.widgetWithText(TextButton, 'Show full-screen dialog'),
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ declare -ar PROJECT_NAMES=(
|
|||||||
"experimental/federated_plugin/federated_plugin_platform_interface"
|
"experimental/federated_plugin/federated_plugin_platform_interface"
|
||||||
"experimental/federated_plugin/federated_plugin_web"
|
"experimental/federated_plugin/federated_plugin_web"
|
||||||
"experimental/federated_plugin/federated_plugin_windows"
|
"experimental/federated_plugin/federated_plugin_windows"
|
||||||
# TODO: ewindmill to talk to team about removing.
|
|
||||||
# Depends on package context_menus, which breaks with Material3 by default.
|
|
||||||
# "experimental/linting_tool"
|
|
||||||
"experimental/pedometer"
|
"experimental/pedometer"
|
||||||
"experimental/pedometer/example"
|
"experimental/pedometer/example"
|
||||||
"experimental/varfont_shader_puzzle"
|
"experimental/varfont_shader_puzzle"
|
||||||
|
|||||||
@@ -34,13 +34,11 @@ declare -ar PROJECT_NAMES=(
|
|||||||
"experimental/federated_plugin/federated_plugin_platform_interface"
|
"experimental/federated_plugin/federated_plugin_platform_interface"
|
||||||
"experimental/federated_plugin/federated_plugin_web"
|
"experimental/federated_plugin/federated_plugin_web"
|
||||||
"experimental/federated_plugin/federated_plugin_windows"
|
"experimental/federated_plugin/federated_plugin_windows"
|
||||||
# TODO: ewindmill to talk to team about removing.
|
|
||||||
# Depends on package context_menus, which breaks with Material3 by default.
|
|
||||||
# "experimental/linting_tool"
|
|
||||||
"experimental/pedometer"
|
"experimental/pedometer"
|
||||||
"experimental/pedometer/example"
|
"experimental/pedometer/example"
|
||||||
"experimental/varfont_shader_puzzle"
|
"experimental/varfont_shader_puzzle"
|
||||||
"experimental/web_dashboard"
|
# TODO ewindmill -- whereNotNull deprecated in dart:collection
|
||||||
|
# "experimental/web_dashboard"
|
||||||
"flutter_maps_firestore"
|
"flutter_maps_firestore"
|
||||||
"form_app"
|
"form_app"
|
||||||
"game_template"
|
"game_template"
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ declare -ar PROJECT_NAMES=(
|
|||||||
"experimental/federated_plugin/federated_plugin_platform_interface"
|
"experimental/federated_plugin/federated_plugin_platform_interface"
|
||||||
"experimental/federated_plugin/federated_plugin_web"
|
"experimental/federated_plugin/federated_plugin_web"
|
||||||
"experimental/federated_plugin/federated_plugin_windows"
|
"experimental/federated_plugin/federated_plugin_windows"
|
||||||
# TODO: ewindmill to talk to team about removing.
|
|
||||||
# Depends on package context_menus, which breaks with Material3 by default.
|
|
||||||
# "experimental/linting_tool"
|
|
||||||
"experimental/pedometer"
|
"experimental/pedometer"
|
||||||
"experimental/pedometer/example"
|
"experimental/pedometer/example"
|
||||||
"experimental/varfont_shader_puzzle"
|
"experimental/varfont_shader_puzzle"
|
||||||
|
|||||||
80
tool/flutter_clean_packages
Normal file
80
tool/flutter_clean_packages
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
flutter doctor -v
|
||||||
|
|
||||||
|
declare -ar PROJECT_NAMES=(
|
||||||
|
"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"
|
||||||
|
"ai_recipe_generation"
|
||||||
|
"analysis_defaults"
|
||||||
|
"android_splash_screen"
|
||||||
|
"animations"
|
||||||
|
"asset_transformation"
|
||||||
|
"background_isolate_channels"
|
||||||
|
"code_sharing/client"
|
||||||
|
"code_sharing/server"
|
||||||
|
"code_sharing/shared"
|
||||||
|
"context_menus"
|
||||||
|
"deeplink_store_example"
|
||||||
|
"desktop_photo_search/fluent_ui"
|
||||||
|
"desktop_photo_search/material"
|
||||||
|
"dynamic_theme"
|
||||||
|
"experimental/federated_plugin/federated_plugin"
|
||||||
|
"experimental/federated_plugin/federated_plugin/example"
|
||||||
|
"experimental/federated_plugin/federated_plugin_macos"
|
||||||
|
"experimental/federated_plugin/federated_plugin_platform_interface"
|
||||||
|
"experimental/federated_plugin/federated_plugin_web"
|
||||||
|
"experimental/federated_plugin/federated_plugin_windows"
|
||||||
|
"experimental/pedometer"
|
||||||
|
"experimental/pedometer/example"
|
||||||
|
"experimental/varfont_shader_puzzle"
|
||||||
|
"experimental/web_dashboard"
|
||||||
|
"flutter_maps_firestore"
|
||||||
|
"form_app"
|
||||||
|
"game_template"
|
||||||
|
"gemini_tasks"
|
||||||
|
"google_maps"
|
||||||
|
"infinite_list"
|
||||||
|
"ios_app_clip"
|
||||||
|
"isolate_example"
|
||||||
|
"material_3_demo"
|
||||||
|
"navigation_and_routing"
|
||||||
|
"place_tracker"
|
||||||
|
"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/_tool"
|
||||||
|
"web/samples_index"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "--- Running flutter clean and flutter pub get for each sample ---"
|
||||||
|
|
||||||
|
for PROJECT_NAME in "${PROJECT_NAMES[@]}"
|
||||||
|
do
|
||||||
|
echo "== Cleaning '${PROJECT_NAME}' with Flutter clean =="
|
||||||
|
pushd "${PROJECT_NAME}"
|
||||||
|
|
||||||
|
# run `flutter clean` for project
|
||||||
|
flutter clean
|
||||||
|
|
||||||
|
# Grab packages.
|
||||||
|
flutter pub get
|
||||||
|
|
||||||
|
popd
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "--- Success ---"
|
||||||
Reference in New Issue
Block a user