maRci002
0b9225afdf
Shared element transition for predictive back (#154718)
This PR adds a shared element transition for predictive back navigation,
based on the specification found here:
https://developer.android.com/design/ui/mobile/guides/patterns/predictive-back#shared-element-transition.
A new transition builder added:
`PredictiveBackPageSharedElementTransitionsBuilder`, which constructs
the shared element transition version.
<details><summary>Code sample</summary>
```dart
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
brightness: Brightness.light,
pageTransitionsTheme: const PageTransitionsTheme(
builders: {
TargetPlatform.android: PredictiveBackPageSharedElementTransitionsBuilder(),
},
),
),
home: const FirstScreen(),
);
}
}
class FirstScreen extends StatelessWidget {
const FirstScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('First Screen'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (_) => const SecondScreen()),
);
},
child: const Text('Go to Second Screen'),
),
),
);
}
}
class SecondScreen extends StatelessWidget {
const SecondScreen({super.key});
@override
Widget build(BuildContext context) {
return Theme(
data: ThemeData(brightness: Brightness.dark),
child: Scaffold(
appBar: AppBar(
title: const Text('Second Screen'),
),
body: const Center(
child: Text('Hello, Predictive back!'),
),
),
);
}
}
```
</details>
[predictive_back_shared_element.webm](https://github.com/user-attachments/assets/1194cf09-c64f-4b1f-aa3f-10feb0ef12bd)
Partial fix for #153577
---------
Co-authored-by: Justin McCandless <jmccandless@google.com>
2025-05-19 22:06:58 +00:00
..
2025-03-14 17:50:20 +00:00
2025-01-22 21:52:11 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-05-07 16:52:38 +00:00
2025-04-15 23:52:25 +00:00
2025-05-07 16:52:38 +00:00
2024-12-19 20:06:21 +00:00
2025-05-13 23:52:05 +00:00
2024-12-19 20:06:21 +00:00
2025-05-05 01:28:40 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-01-24 21:33:27 +00:00
2025-03-14 17:50:20 +00:00
2025-05-14 17:38:18 +00:00
2025-05-14 17:38:18 +00:00
2025-04-02 21:28:56 +00:00
2024-12-19 20:06:21 +00:00
2025-05-02 19:30:20 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-04-30 23:46:11 +00:00
2024-12-19 20:06:21 +00:00
2025-04-02 21:28:56 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-04-28 09:22:40 +00:00
2025-04-16 19:10:38 +00:00
2025-05-14 02:07:34 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2025-05-16 22:39:54 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-01-14 05:13:41 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-04-02 22:00:19 +00:00
2024-12-19 20:06:21 +00:00
2025-05-13 23:48:10 +00:00
2025-04-11 19:38:16 +00:00
2025-04-29 15:03:09 +00:00
2025-02-06 18:40:25 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-05-02 20:52:14 +00:00
2025-05-02 20:52:14 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-05-12 23:37:28 +00:00
2025-03-14 17:50:20 +00:00
2025-05-12 21:30:47 +00:00
2025-05-02 19:41:10 +00:00
2025-05-07 23:43:06 +00:00
2024-12-19 20:06:21 +00:00
2025-05-12 08:48:22 +00:00
2025-04-30 23:46:11 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-04-02 21:28:56 +00:00
2025-01-22 21:52:11 +00:00
2025-04-30 23:46:11 +00:00
2025-02-13 08:33:12 +00:00
2025-01-24 21:33:27 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-01-24 21:33:27 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2025-04-30 23:46:11 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-01-24 21:33:27 +00:00
2025-03-14 17:50:20 +00:00
2025-01-24 21:33:27 +00:00
2024-12-19 20:06:21 +00:00
2025-01-22 21:52:11 +00:00
2025-04-02 22:00:19 +00:00
2025-05-02 23:34:04 +00:00
2025-05-09 17:23:34 +00:00
2025-04-09 04:47:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-05-05 23:57:33 +00:00
2024-12-19 20:06:21 +00:00
2025-01-24 21:33:27 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-04-02 21:28:56 +00:00
2025-03-14 17:50:20 +00:00
2025-04-02 21:28:56 +00:00
2025-03-13 08:02:36 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-04-30 23:46:11 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-05-06 23:36:52 +00:00
2025-03-17 17:00:05 +00:00
2024-12-19 20:06:21 +00:00
2025-04-03 00:33:58 +00:00
2025-03-14 17:50:20 +00:00
2025-05-19 22:06:58 +00:00
2025-04-17 03:56:17 +00:00
2025-02-20 07:48:23 +00:00
2025-05-14 02:07:34 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2025-05-19 17:10:12 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-04-02 21:28:56 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-05-02 23:32:32 +00:00
2025-03-14 17:50:20 +00:00
2025-05-01 18:15:49 +00:00
2025-03-14 17:50:20 +00:00
2025-04-15 23:52:25 +00:00
2025-03-14 17:50:20 +00:00
2025-02-28 02:30:37 +00:00
2025-04-29 23:44:25 +00:00
2025-05-19 17:10:12 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-05-06 05:25:32 +00:00
2025-04-30 18:43:49 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-01-15 11:23:41 +00:00
2025-04-30 23:46:11 +00:00
2025-03-14 17:50:20 +00:00
2025-01-14 05:13:41 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-05-16 22:39:54 +00:00
2025-04-10 07:11:24 +00:00
2025-05-02 23:32:32 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-02-21 18:40:05 +00:00
2025-05-14 17:38:18 +00:00
2025-03-14 17:50:20 +00:00
2025-05-16 17:29:12 +00:00
2025-05-02 01:57:19 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2025-04-15 23:52:25 +00:00
2025-04-15 23:52:25 +00:00
2025-04-30 18:44:36 +00:00
2025-03-17 17:00:05 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00