Created
May 19, 2020 18:32
-
-
Save ha-yi/5279d8ef9dff368e15474994bd163872 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'; | |
class SplitColorIcon extends StatelessWidget { | |
final double size; | |
final Color leftColor; | |
final Color rightColor; | |
final IconData iconData; | |
const SplitColorIcon({ | |
Key key, | |
@required this.iconData, | |
this.size = 60, | |
@required this.leftColor, | |
@required this.rightColor, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
width: size, | |
height: size, | |
child: Stack( | |
children: [ | |
Positioned( | |
left: 0, | |
top: 0, | |
bottom: 0, | |
child: ClipRect( | |
child: Container( | |
width: size / 2, | |
child: OverflowBox( | |
maxWidth: size, | |
maxHeight: size, | |
alignment: Alignment.topLeft, | |
child: Icon( | |
iconData, | |
size: size, | |
color: leftColor, | |
), | |
), | |
), | |
), | |
), | |
Positioned( | |
right: 0, | |
top: 0, | |
bottom: 0, | |
child: ClipRect( | |
child: Container( | |
width: size / 2, | |
child: OverflowBox( | |
alignment: Alignment.topRight, | |
maxWidth: size, | |
maxHeight: size, | |
child: Icon( | |
iconData, | |
size: size, | |
color: rightColor, | |
), | |
), | |
), | |
), | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: