Skip to content

Instantly share code, notes, and snippets.

@stargazing-dino
Created September 11, 2019 20:27
Show Gist options
  • Save stargazing-dino/fea5fc4e642939011d24e04499df987e to your computer and use it in GitHub Desktop.
Save stargazing-dino/fea5fc4e642939011d24e04499df987e to your computer and use it in GitHub Desktop.
Onboarding Screen
class Screen extends StatelessWidget {
const Screen({
Key key,
this.topFlex = 1,
this.topText = "",
this.topImageUri = "",
this.bottomFlex = 1,
this.bottomText = "",
this.bottomImageUri = "",
}) : super(key: key);
final int topFlex;
final String topText;
final String topImageUri;
final int bottomFlex;
final String bottomText;
final String bottomImageUri;
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
child: Container(
color: topImageUri == ""
? Theme.of(context).scaffoldBackgroundColor
: null,
padding: topImageUri == ""
? const EdgeInsets.all(16)
: const EdgeInsets.fromLTRB(16, 0, 16, 0),
alignment: topImageUri == "" ? Alignment.center : null,
child: topImageUri != ""
? Image.asset(
topImageUri,
fit: BoxFit.cover,
alignment: Alignment.bottomCenter,
)
: Text(
topText,
style: Theme.of(context).textTheme.display2,
textAlign: TextAlign.center,
),
),
flex: topFlex,
),
Expanded(
child: Container(
color: bottomImageUri == ""
? Theme.of(context).scaffoldBackgroundColor
: null,
alignment: bottomImageUri == "" ? Alignment.center : null,
padding: bottomImageUri == ""
? const EdgeInsets.all(30)
: const EdgeInsets.fromLTRB(40, 30, 40, 0),
child: bottomImageUri != ""
? Image.asset(
bottomImageUri,
fit: BoxFit.cover,
alignment: Alignment.topCenter,
)
: Text(
bottomText,
style: Theme.of(context).textTheme.display2,
textAlign: TextAlign.center,
),
),
flex: bottomFlex,
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment