Skip to content

Commit 30672be

Browse files
committed
Resolve Warnings #1
- Update deprecated `OutlineButton` to `OutlinedButton`. - Resolve other warnings.
1 parent 26c7857 commit 30672be

File tree

4 files changed

+52
-34
lines changed

4 files changed

+52
-34
lines changed

lib/components/blog.dart

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter/widgets.dart';
32
import 'package:google_fonts/google_fonts.dart';
43
import 'package:minimal/components/color.dart';
54
import 'package:minimal/components/spacing.dart';
@@ -70,36 +69,56 @@ class Tag extends StatelessWidget {
7069
}
7170

7271
class ReadMoreButton extends StatelessWidget {
73-
final Function onPressed;
72+
final VoidCallback onPressed;
7473

7574
const ReadMoreButton({Key? key, required this.onPressed}) : super(key: key);
7675

7776
@override
7877
Widget build(BuildContext context) {
79-
bool hover = false;
80-
return StatefulBuilder(
81-
builder: (BuildContext context, StateSetter setState) {
82-
return MouseRegion(
83-
onHover: (event) => setState(() => hover = true),
84-
onExit: (event) => setState(() => hover = false),
85-
child: OutlineButton(
86-
onPressed: onPressed as void Function()?,
87-
highlightedBorderColor: textPrimary,
88-
hoverColor: textPrimary,
89-
borderSide: BorderSide(color: textPrimary, width: 2),
90-
padding: EdgeInsets.symmetric(horizontal: 20),
91-
child: Text(
92-
"READ MORE",
93-
style: GoogleFonts.montserrat(
78+
return OutlinedButton(
79+
onPressed: onPressed,
80+
style: ButtonStyle(
81+
overlayColor: MaterialStateProperty.all<Color>(textPrimary),
82+
side: MaterialStateProperty.resolveWith((states) {
83+
if (states.contains(MaterialState.focused) ||
84+
states.contains(MaterialState.hovered) ||
85+
states.contains(MaterialState.pressed)) {
86+
return const BorderSide(color: textPrimary, width: 2);
87+
}
88+
89+
return const BorderSide(color: textPrimary, width: 2);
90+
}),
91+
foregroundColor: MaterialStateProperty.resolveWith<Color>((states) {
92+
if (states.contains(MaterialState.focused) ||
93+
states.contains(MaterialState.hovered) ||
94+
states.contains(MaterialState.pressed)) {
95+
return Colors.white;
96+
}
97+
98+
return textPrimary;
99+
}),
100+
textStyle: MaterialStateProperty.resolveWith<TextStyle>((states) {
101+
if (states.contains(MaterialState.focused) ||
102+
states.contains(MaterialState.hovered) ||
103+
states.contains(MaterialState.pressed)) {
104+
return GoogleFonts.montserrat(
94105
textStyle: TextStyle(
95-
fontSize: 14,
96-
color: hover ? Colors.white : textPrimary,
97-
letterSpacing: 1),
98-
),
99-
),
100-
),
101-
);
102-
});
106+
fontSize: 14, color: Colors.white, letterSpacing: 1),
107+
);
108+
}
109+
110+
return GoogleFonts.montserrat(
111+
textStyle:
112+
TextStyle(fontSize: 14, color: textPrimary, letterSpacing: 1),
113+
);
114+
}),
115+
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
116+
const EdgeInsets.symmetric(horizontal: 12, vertical: 16)),
117+
),
118+
child: Text(
119+
"READ MORE",
120+
),
121+
);
103122
}
104123
}
105124

@@ -116,8 +135,7 @@ Widget dividerSmall = Container(
116135
),
117136
);
118137

119-
List<Widget> authorSection(
120-
{required String imageUrl, String? name, String? bio}) {
138+
List<Widget> authorSection({String? imageUrl, String? name, String? bio}) {
121139
return [
122140
divider,
123141
Container(

lib/components/color.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:flutter/material.dart';
22

33
// Text
4-
Color textPrimary = Color(0xFF111111);
5-
Color textSecondary = Color(0xFF3A3A3A);
4+
const Color textPrimary = Color(0xFF111111);
5+
const Color textSecondary = Color(0xFF3A3A3A);

lib/pages/page_list.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:flutter/cupertino.dart';
21
import 'package:flutter/material.dart';
32
import 'package:minimal/components/components.dart';
43

lib/ui/ui_image.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import 'package:flutter/widgets.dart';
22

33
class ImageFixedWidth extends StatelessWidget {
4-
ImageFixedWidth(this.image, this.width,
5-
{this.imageRatio = 1.618, this.placeholder = ""});
64
final String image;
75
final double width;
8-
final double imageRatio;
6+
final double? imageRatio;
97
final String placeholder;
108

9+
const ImageFixedWidth(this.image, this.width,
10+
{this.imageRatio = 1.618, this.placeholder = ""});
11+
1112
@override
1213
Widget build(BuildContext context) {
13-
double height = imageRatio == null ? width : imageRatio * width;
14+
final double height = imageRatio == null ? width : imageRatio! * width;
1415

1516
return FadeInImage.assetNetwork(
1617
image: image,

0 commit comments

Comments
 (0)