Skip to content

Instantly share code, notes, and snippets.

@Turskyi
Last active July 24, 2021 10:24
Show Gist options
  • Save Turskyi/0e6e5514c38948a51821f759dd5998c9 to your computer and use it in GitHub Desktop.
Save Turskyi/0e6e5514c38948a51821f759dd5998c9 to your computer and use it in GitHub Desktop.
Background Flutter widget with linear gradient
class BackgroundWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return Align(
alignment: AlignmentDirectional.topCenter,
child: Container(
width: constraints.maxWidth,
height: constraints.maxHeight,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xFF045E9A),
AppConfigs.of(context).colors.vividCyan,
],
begin: const FractionalOffset(0.0, 0.0),
end: const FractionalOffset(1.0, 1.0),
),
),
child: SvgPicture.asset(
"${Constants.ASSETS_IMAGES}pic_background.svg",
fit: BoxFit.cover,
),
),
);
},
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment