Skip to content

Instantly share code, notes, and snippets.

@ThinkDigitalSoftware
Created July 6, 2018 18:15
Show Gist options
  • Save ThinkDigitalSoftware/05fc3ef931dc297f8cd2bdcbff6e6155 to your computer and use it in GitHub Desktop.
Save ThinkDigitalSoftware/05fc3ef931dc297f8cd2bdcbff6e6155 to your computer and use it in GitHub Desktop.
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