如何关闭Flutter页面过渡动画

时间:2020-08-04 10:51:00

标签: flutter flutter-animation

我有Flutter MaterialApp。

当我在页面之间导航时,会向左滑动动画。
我不希望页面更改之间有任何过渡动画。

void main() {
  runApp(MaterialApp(
    //home: MainScreen(),
    initialRoute: '/',
    routes: {
      '/': (context) => MenuPage(),
      '/page2': (context) => Page2(),
    }
  ));
}

如何关闭页面过渡动画?

1 个答案:

答案 0 :(得分:1)

使用以下代码在不使用动画的情况下进行导航。


<body onload="init()">
    <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->

    <table class="block_xp-report-table">
        <tbody>
            <tr class="" id="block_xp_report_r0">
                <td class="cell c0" id="block_xp_report_r0_c0">
                    1
                </td>
                <td class="cell c1" id="block_xp_report_r0_c1">
                    <a href="http://test.com.np/user/view.php?id=2157&amp;course=103"
                        id="yui_3_17_2_1_1596532113936_188"
                        data-attribute="-- need to get the href value from here not the name">John</a>
                </td>
                <td class="cell c2" id="block_xp_report_r0_c2" data-attribute="---need to get this text ">6</td>
                <td class="cell c3" id="block_xp_report_r0_c3">
                    <div class="block_xp-xp">
                        <div class="pts" data-attribute="---need to get this text ">6,414</div>
                    </div>
                </td>
            </tr>
            <tr class="" id="block_xp_report_r1">
                <td class="cell c0" id="block_xp_report_r1_c0">
                    <a href="http://test.com.np/user/view.php?id=2158&amp;course=103">Image 1</a>
                </td>
                <td class="cell c1" id="block_xp_report_r1_c1">
                    <a href="http://test.com.np/user/view.php?id=2158&amp;course=103"
                        id="yui_3_17_2_1_1596532113936_188">John</a>
                </td>
                <td class="cell c2" id="block_xp_report_r1_c2">6</td>
                <td class="cell c3" id="block_xp_report_r1_c3">
                    <div class="block_xp-xp">
                        <div class="pts">6,414</div>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>


    <script>

        function init() {

            const rowIndexes = {

                href: 1,
                text: 2,
                points: 3
            }

            const responses = Array.from(document.querySelectorAll('.block_xp-report-table tbody tr'))
                .map(res => {



                    const getFor = (elemName) => {
                        return res.querySelectorAll("td")[rowIndexes[elemName]]
                    }


                    return { href: getFor('href').querySelector("a").getAttribute("href"), text: getFor('text').innerText, points: getFor('points').innerText }
                })

            console.log(responses)

          
        }

    </script>
</body>