【问题标题】:Text disappears after custom page transition自定义页面转换后文本消失
【发布时间】:2020-09-27 16:19:50
【问题描述】:

我遇到了一个奇怪的问题,即当我导航到新路线时,我放在目标页面上的文字没有显示。但其他元素可以。

这是我的过渡实现:

class BouncyPageRoute extends PageRouteBuilder {
  final Widget destination;

  BouncyPageRoute({this.destination})
      : super(
          transitionDuration: Duration(milliseconds: 600),
          transitionsBuilder: (context, animation, secondaryAnimation, child) {
            animation =
                CurvedAnimation(parent: animation, curve: Curves.elasticInOut);
            return ScaleTransition(
              scale: animation,
              child: child,
              alignment: Alignment.center,
            );
          },
          pageBuilder: (context, animation, secondaryAnimation) {
            return destination;
          },
        );
}

目标页面实现:

import 'package:flutter/material.dart';

class SecondScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Center(
          child: Column(
            children: [
              FlutterLogo(),
              Text(" can you see meeee??"),
            ],
          ),
        ),
      ),
    );
  }
}

你可以在 github 上查看项目 git@github.com:folivi/flutter_transition_issue.git 我在 Flutter 1.22 beta 分支上。

我没有做错什么?

感谢您的帮助

【问题讨论】:

  • 适用于 Flutter 版本 stable, 1.20.4
  • 确实!非常感谢!

标签: flutter flutter-animation


【解决方案1】:

当我将过渡持续时间设置为 2000 时,我遇到了同样的问题,但是当我将它设置为 1500 左右时它会起作用。所以尝试调整过渡持续时间。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-12
    • 2014-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多