mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
add static method to create material hero controller (#61662)
This commit is contained in:
parent
14dcbb2d84
commit
09dfca6f5d
@ -536,6 +536,17 @@ class MaterialApp extends StatefulWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
_MaterialAppState createState() => _MaterialAppState();
|
_MaterialAppState createState() => _MaterialAppState();
|
||||||
|
|
||||||
|
/// The [HeroController] used for Material page transitions.
|
||||||
|
///
|
||||||
|
/// Used by the [MaterialApp].
|
||||||
|
static HeroController createMaterialHeroController() {
|
||||||
|
return HeroController(
|
||||||
|
createRectTween: (Rect begin, Rect end) {
|
||||||
|
return MaterialRectArcTween(begin: begin, end: end);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MaterialScrollBehavior extends ScrollBehavior {
|
class _MaterialScrollBehavior extends ScrollBehavior {
|
||||||
@ -572,7 +583,7 @@ class _MaterialAppState extends State<MaterialApp> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_heroController = HeroController(createRectTween: _createRectTween);
|
_heroController = MaterialApp.createMaterialHeroController();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -583,14 +594,10 @@ class _MaterialAppState extends State<MaterialApp> {
|
|||||||
// old Navigator won't be disposed (and thus won't unregister with its
|
// old Navigator won't be disposed (and thus won't unregister with its
|
||||||
// observers) until after the new one has been created (because the
|
// observers) until after the new one has been created (because the
|
||||||
// Navigator has a GlobalKey).
|
// Navigator has a GlobalKey).
|
||||||
_heroController = HeroController(createRectTween: _createRectTween);
|
_heroController = MaterialApp.createMaterialHeroController();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RectTween _createRectTween(Rect begin, Rect end) {
|
|
||||||
return MaterialRectArcTween(begin: begin, end: end);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Combine the Localizations for Material with the ones contributed
|
// Combine the Localizations for Material with the ones contributed
|
||||||
// by the localizationsDelegates parameter, if any. Only the first delegate
|
// by the localizationsDelegates parameter, if any. Only the first delegate
|
||||||
// of a particular LocalizationsDelegate.type is loaded so the
|
// of a particular LocalizationsDelegate.type is loaded so the
|
||||||
|
@ -834,6 +834,15 @@ void main() {
|
|||||||
expect(find.text('regular page one'), findsNothing);
|
expect(find.text('regular page one'), findsNothing);
|
||||||
expect(find.text('regular page two'), findsNothing);
|
expect(find.text('regular page two'), findsNothing);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('MaterialApp does create HeroController with the MaterialRectArcTween', (WidgetTester tester) async {
|
||||||
|
final HeroController controller = MaterialApp.createMaterialHeroController();
|
||||||
|
final Tween<Rect> tween = controller.createRectTween(
|
||||||
|
const Rect.fromLTRB(0.0, 0.0, 10.0, 10.0),
|
||||||
|
const Rect.fromLTRB(0.0, 0.0, 20.0, 20.0)
|
||||||
|
);
|
||||||
|
expect(tween, isA<MaterialRectArcTween>());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockAccessibilityFeature implements AccessibilityFeatures {
|
class MockAccessibilityFeature implements AccessibilityFeatures {
|
||||||
|
Loading…
Reference in New Issue
Block a user