Created
July 6, 2018 18:15
-
-
Save ThinkDigitalSoftware/05fc3ef931dc297f8cd2bdcbff6e6155 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter_spinkit/flutter_spinkit.dart'; | |
main(List<String> arguments) { | |
runApp(new MaterialApp( | |
title: "Test", | |
home: CongregationImage( | |
isLoading: true, | |
screenHeight: 100.0, | |
orientation: Orientation.portrait, | |
screenWidth: 200.0, | |
imgSrc: | |
"https://onaliternote.files.wordpress.com/2016/11/wp-1480230666843.jpg?crop", | |
))); | |
} | |
class CongregationImage extends StatelessWidget { | |
const CongregationImage( | |
{Key key, | |
@required this.screenWidth, | |
@required this.screenHeight, | |
@required this.imgSrc, | |
@required this.orientation, | |
this.isLoading}) | |
: super(key: key); | |
final String imgSrc; | |
final double screenWidth; | |
final double screenHeight; | |
final Orientation orientation; | |
final isLoading; | |
@override | |
Widget build(BuildContext context) { | |
double finalWidth = (orientation == Orientation.portrait) | |
? (screenWidth / 2) // if it's portrait | |
: (screenHeight / 4); | |
debugPrint("FinalWidth: $finalWidth"); | |
return Stack(alignment: Alignment.center, children: [ | |
Card( | |
elevation: 4.0, | |
shape: CircleBorder(), | |
child: Image.network( | |
imgSrc, | |
fit: BoxFit.fill, | |
width: finalWidth, // if it's landscape | |
), | |
), | |
isLoading //TODO: fix alignment for the following widget. | |
? Center(child: SpinKitFadingCube(color: Colors.white, width: 40.0)) | |
: new Container(), | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment