当前位置:网站首页>Flutter realizes the gradual enlargement of hero pictures and the equal proportion method of pictures. Pictures are smoothly enlarged

Flutter realizes the gradual enlargement of hero pictures and the equal proportion method of pictures. Pictures are smoothly enlarged

2022-07-18 17:10:00 A Cong is not bald

Picture list page

floatingActionButton: FloatingActionButton(
        child: Icon(Icons.pool),
        onPressed: () {
          // iOS -> Modal The way 
//          Navigator.of(context).push(MaterialPageRoute(
//            builder: (ctx) {
//              return HYModalPage();
//            },
//            fullscreenDialog: true
//          ));
          Navigator.of(context).push(PageRouteBuilder(
            transitionDuration: Duration(seconds: 3),
            pageBuilder: (ctx, animation1, animation2) {
              return FadeTransition(
                opacity: animation1,
                child: HYModalPage(),
              );
            }
          ));
//          Navigator.of(context).pushNamed(routeName)
        },
      )

Picture details page

import 'package:flutter/material.dart';

class HYImageDetailPage extends StatelessWidget {
  final String _imageURL;

  HYImageDetailPage(this._imageURL);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.black,
      body: Center(
        child: GestureDetector(
            onTap: () {
              Navigator.of(context).pop();
            },
            child: Hero(tag: _imageURL, child: Image.network(_imageURL))
        ),
      ),
    );
  }
}

原网站

版权声明
本文为[A Cong is not bald]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/199/202207161118305491.html