From 1076d5f379cd3b5d80d3976dd383beb1d676237e Mon Sep 17 00:00:00 2001 From: Ray Li Date: Sat, 12 Feb 2022 16:23:25 -0600 Subject: [PATCH] Replace Deprecated FlatButtons - Replace deprecated FlatButtons with TextButton. - Support cursor hover change. --- lib/components/blog.dart | 50 +++++++++++++++------------------------- lib/components/text.dart | 11 ++++++++- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/lib/components/blog.dart b/lib/components/blog.dart index 1e01134..6134096 100644 --- a/lib/components/blog.dart +++ b/lib/components/blog.dart @@ -342,7 +342,10 @@ class MenuBar extends StatelessWidget { margin: const EdgeInsets.symmetric(vertical: 30), child: Row( children: [ - GestureDetector( + InkWell( + hoverColor: Colors.transparent, + highlightColor: Colors.transparent, + splashColor: Colors.transparent, onTap: () => Navigator.popUntil( context, ModalRoute.withName(Navigator.defaultRouteName)), child: Text("MINIMAL", @@ -357,57 +360,42 @@ class MenuBar extends StatelessWidget { alignment: Alignment.centerRight, child: Wrap( children: [ - FlatButton( + TextButton( onPressed: () => Navigator.popUntil(context, ModalRoute.withName(Navigator.defaultRouteName)), - child: Text( + child: const Text( "HOME", - style: buttonTextStyle, ), - splashColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, + style: menuButtonStyle, ), - FlatButton( + TextButton( onPressed: () {}, - child: Text( + child: const Text( "PORTFOLIO", - style: buttonTextStyle, ), - splashColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, + style: menuButtonStyle, ), - FlatButton( + TextButton( onPressed: () => Navigator.pushNamed(context, Routes.style), - child: Text( + child: const Text( "STYLE", - style: buttonTextStyle, ), - splashColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, + style: menuButtonStyle, ), - FlatButton( + TextButton( onPressed: () {}, - child: Text( + child: const Text( "ABOUT", - style: buttonTextStyle, ), - splashColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, + style: menuButtonStyle, ), - FlatButton( + TextButton( onPressed: () {}, - child: Text( + child: const Text( "CONTACT", - style: buttonTextStyle, ), - splashColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, + style: menuButtonStyle, ), ], ), diff --git a/lib/components/text.dart b/lib/components/text.dart index bff3d90..b875192 100644 --- a/lib/components/text.dart +++ b/lib/components/text.dart @@ -1,7 +1,9 @@ -import 'package:flutter/widgets.dart'; +import 'package:flutter/material.dart'; import 'package:minimal/components/spacing.dart'; import 'package:minimal/components/typography.dart'; +import 'color.dart'; + class TextBody extends StatelessWidget { final String text; @@ -75,3 +77,10 @@ class TextBlockquote extends StatelessWidget { ); } } + +ButtonStyle? menuButtonStyle = TextButton.styleFrom( + backgroundColor: Colors.transparent, + onSurface: null, + primary: textSecondary, + textStyle: buttonTextStyle, + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16));