Created
January 19, 2021 12:43
-
-
Save willcalderbank/af9ae630eccaea24597e5f902de3f613 to your computer and use it in GitHub Desktop.
This file contains 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'; | |
final Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue), | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: MyWidget(), | |
), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
final Color borderColor = Colors.white; | |
final Color foregroundColor = Color.fromRGBO(25,25,25,25); | |
final Color backgroundColor = Color.fromRGBO(55,55,55,25); | |
final Color overlayColor = Color.fromRGBO(100,100,100,25); | |
@override | |
Widget build(BuildContext context) { | |
return OutlinedButton( | |
child: Text('hello'), | |
onPressed: () => null, | |
style: ButtonStyle( | |
minimumSize: MaterialStateProperty.all<Size>(Size(500, 100)), | |
side: MaterialStateProperty.all<BorderSide>(BorderSide(color: borderColor, width: 1.0 ),), | |
foregroundColor: MaterialStateProperty.all<Color>(foregroundColor), | |
backgroundColor: MaterialStateProperty.resolveWith<Color>( | |
(Set<MaterialState> states) { | |
if (states.contains(MaterialState.hovered)) { | |
return backgroundColor; | |
} | |
return null; // Use the component's default. | |
}, | |
), | |
overlayColor:MaterialStateProperty.resolveWith<Color>( | |
(Set<MaterialState> states) { | |
if (states.contains(MaterialState.pressed)) { | |
return overlayColor; | |
} | |
return null; // Use the component's default. | |
}, | |
), | |
shape: MaterialStateProperty.all<RoundedRectangleBorder>( | |
RoundedRectangleBorder(borderRadius: BorderRadius.zero), | |
), | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment