Skip to content

Commit 2fc80aa

Browse files
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>
1 parent 5ea3636 commit 2fc80aa

File tree

6 files changed

+146
-11
lines changed

6 files changed

+146
-11
lines changed

material_3_demo/lib/component_screen.dart

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ class Containment extends StatelessWidget {
242242
return const ComponentGroupDecoration(label: 'Containment', children: [
243243
BottomSheetSection(),
244244
Cards(),
245+
Carousels(),
245246
Dialogs(),
246247
Dividers(),
247248
// TODO: Add Lists, https://github.com/flutter/flutter/issues/114006
@@ -2416,6 +2417,65 @@ class _SearchAnchorsState extends State<SearchAnchors> {
24162417
}
24172418
}
24182419

2420+
class Carousels extends StatelessWidget {
2421+
const Carousels({super.key});
2422+
2423+
@override
2424+
Widget build(BuildContext context) {
2425+
return ComponentDecoration(
2426+
label: 'Carousel',
2427+
tooltipMessage: 'Use CarouselView',
2428+
child: Column(
2429+
crossAxisAlignment: CrossAxisAlignment.start,
2430+
children: [
2431+
const Padding(
2432+
padding: EdgeInsets.only(left: 8.0),
2433+
child: Text('Uncontained Carousel'),
2434+
),
2435+
ConstrainedBox(
2436+
constraints: const BoxConstraints.tightFor(height: 150),
2437+
child: CarouselView(
2438+
shape: RoundedRectangleBorder(
2439+
borderRadius: BorderRadius.circular(10),
2440+
side: BorderSide(color: Theme.of(context).colorScheme.outline),
2441+
),
2442+
shrinkExtent: 100,
2443+
itemExtent: 180,
2444+
children: List<Widget>.generate(20, (index) {
2445+
return Center(
2446+
child: Text('Item $index'),
2447+
);
2448+
}),
2449+
),
2450+
),
2451+
colDivider,
2452+
const Padding(
2453+
padding: EdgeInsets.only(left: 8.0),
2454+
child: Text('Uncontained Carousel with snapping effect'),
2455+
),
2456+
ConstrainedBox(
2457+
constraints: const BoxConstraints.tightFor(height: 150),
2458+
child: CarouselView(
2459+
itemSnapping: true,
2460+
shape: RoundedRectangleBorder(
2461+
borderRadius: BorderRadius.circular(10),
2462+
side: BorderSide(color: Theme.of(context).colorScheme.outline),
2463+
),
2464+
shrinkExtent: 100,
2465+
itemExtent: 180,
2466+
children: List<Widget>.generate(20, (index) {
2467+
return Center(
2468+
child: Text('Item $index'),
2469+
);
2470+
}),
2471+
),
2472+
),
2473+
],
2474+
),
2475+
);
2476+
}
2477+
}
2478+
24192479
class ComponentDecoration extends StatefulWidget {
24202480
const ComponentDecoration({
24212481
super.key,

material_3_demo/test/component_screen_test.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:material_3_demo/main.dart';
1010

1111
void main() {
1212
testWidgets('Default main page shows all M3 components', (tester) async {
13-
widgetSetup(tester, 800, windowHeight: 7000);
13+
widgetSetup(tester, 800, windowHeight: 7500);
1414
await tester.pumpWidget(const App());
1515

1616
// Elements on the app bar
@@ -67,6 +67,9 @@ void main() {
6767
expect(find.widgetWithText(Cards, 'Filled'), findsOneWidget);
6868
expect(find.widgetWithText(Cards, 'Outlined'), findsOneWidget);
6969

70+
// Carousels
71+
expect(find.byType(CarouselView), findsNWidgets(2));
72+
7073
// Dialogs
7174
expect(find.widgetWithText(TextButton, 'Show dialog'), findsOneWidget);
7275
expect(find.widgetWithText(TextButton, 'Show full-screen dialog'),

tool/flutter_ci_script_beta.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ declare -ar PROJECT_NAMES=(
3434
"experimental/federated_plugin/federated_plugin_platform_interface"
3535
"experimental/federated_plugin/federated_plugin_web"
3636
"experimental/federated_plugin/federated_plugin_windows"
37-
# TODO: ewindmill to talk to team about removing.
38-
# Depends on package context_menus, which breaks with Material3 by default.
39-
# "experimental/linting_tool"
4037
"experimental/pedometer"
4138
"experimental/pedometer/example"
4239
"experimental/varfont_shader_puzzle"

tool/flutter_ci_script_master.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ declare -ar PROJECT_NAMES=(
3434
"experimental/federated_plugin/federated_plugin_platform_interface"
3535
"experimental/federated_plugin/federated_plugin_web"
3636
"experimental/federated_plugin/federated_plugin_windows"
37-
# TODO: ewindmill to talk to team about removing.
38-
# Depends on package context_menus, which breaks with Material3 by default.
39-
# "experimental/linting_tool"
4037
"experimental/pedometer"
4138
"experimental/pedometer/example"
4239
"experimental/varfont_shader_puzzle"
43-
"experimental/web_dashboard"
40+
# TODO ewindmill -- whereNotNull deprecated in dart:collection
41+
# "experimental/web_dashboard"
4442
"flutter_maps_firestore"
4543
"form_app"
4644
"game_template"

tool/flutter_ci_script_stable.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ declare -ar PROJECT_NAMES=(
3434
"experimental/federated_plugin/federated_plugin_platform_interface"
3535
"experimental/federated_plugin/federated_plugin_web"
3636
"experimental/federated_plugin/federated_plugin_windows"
37-
# TODO: ewindmill to talk to team about removing.
38-
# Depends on package context_menus, which breaks with Material3 by default.
39-
# "experimental/linting_tool"
4037
"experimental/pedometer"
4138
"experimental/pedometer/example"
4239
"experimental/varfont_shader_puzzle"

tool/flutter_clean_packages

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
flutter doctor -v
6+
7+
declare -ar PROJECT_NAMES=(
8+
"add_to_app/android_view/flutter_module_using_plugin"
9+
"add_to_app/books/flutter_module_books"
10+
"add_to_app/fullscreen/flutter_module"
11+
"add_to_app/multiple_flutters/multiple_flutters_module"
12+
"add_to_app/plugin/flutter_module_using_plugin"
13+
"add_to_app/prebuilt_module/flutter_module"
14+
"ai_recipe_generation"
15+
"analysis_defaults"
16+
"android_splash_screen"
17+
"animations"
18+
"asset_transformation"
19+
"background_isolate_channels"
20+
"code_sharing/client"
21+
"code_sharing/server"
22+
"code_sharing/shared"
23+
"context_menus"
24+
"deeplink_store_example"
25+
"desktop_photo_search/fluent_ui"
26+
"desktop_photo_search/material"
27+
"dynamic_theme"
28+
"experimental/federated_plugin/federated_plugin"
29+
"experimental/federated_plugin/federated_plugin/example"
30+
"experimental/federated_plugin/federated_plugin_macos"
31+
"experimental/federated_plugin/federated_plugin_platform_interface"
32+
"experimental/federated_plugin/federated_plugin_web"
33+
"experimental/federated_plugin/federated_plugin_windows"
34+
"experimental/pedometer"
35+
"experimental/pedometer/example"
36+
"experimental/varfont_shader_puzzle"
37+
"experimental/web_dashboard"
38+
"flutter_maps_firestore"
39+
"form_app"
40+
"game_template"
41+
"gemini_tasks"
42+
"google_maps"
43+
"infinite_list"
44+
"ios_app_clip"
45+
"isolate_example"
46+
"material_3_demo"
47+
"navigation_and_routing"
48+
"place_tracker"
49+
"platform_channels"
50+
"platform_design"
51+
"platform_view_swift"
52+
"provider_counter"
53+
"provider_shopper"
54+
"simple_shader"
55+
"simplistic_calculator"
56+
"simplistic_editor"
57+
"testing_app"
58+
"veggieseasons"
59+
"web_embedding/element_embedding_demo"
60+
"web/_tool"
61+
"web/samples_index"
62+
)
63+
64+
echo "--- Running flutter clean and flutter pub get for each sample ---"
65+
66+
for PROJECT_NAME in "${PROJECT_NAMES[@]}"
67+
do
68+
echo "== Cleaning '${PROJECT_NAME}' with Flutter clean =="
69+
pushd "${PROJECT_NAME}"
70+
71+
# run `flutter clean` for project
72+
flutter clean
73+
74+
# Grab packages.
75+
flutter pub get
76+
77+
popd
78+
done
79+
80+
echo "--- Success ---"

0 commit comments

Comments
 (0)