Skip to content

Commit a4a74ec

Browse files
Lee Paraynorayliverified
authored andcommitted
ConditionalRouteWidget from updated navigation_utils and TextButton deprecation updates.
1 parent f85e696 commit a4a74ec

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

lib/components/text.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ class TextBlockquote extends StatelessWidget {
7979
}
8080

8181
ButtonStyle? menuButtonStyle = TextButton.styleFrom(
82+
foregroundColor: textSecondary,
8283
backgroundColor: Colors.transparent,
83-
onSurface: null,
84-
primary: textSecondary,
84+
disabledForegroundColor: const Color.fromRGBO(
85+
0, 0, 0, 0.38), // Replace null with desired color and opacity
8586
textStyle: buttonTextStyle,
8687
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16));

lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:minimal/pages/pages.dart';
33
import 'package:minimal/routes.dart';
44
import 'package:navigation_utils/navigation_utils.dart';
55
import 'package:responsive_framework/responsive_framework.dart';
6+
import 'package:minimal/utils/conditional_route_widget.dart';
67

78
void main() {
89
runApp(const MyApp());
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import 'package:flutter/material.dart';
2+
3+
class ConditionalRouteWidget extends StatelessWidget {
4+
final List<String>? routes;
5+
final List<String>? routesExcluded;
6+
final TransitionBuilder builder;
7+
final Widget child;
8+
9+
const ConditionalRouteWidget(
10+
{Key? key,
11+
this.routes,
12+
this.routesExcluded,
13+
required this.builder,
14+
required this.child})
15+
: assert(routes == null || routesExcluded == null,
16+
'Cannot include `routes` and `routesExcluded`. Please provide an list of routes to include or exclude, not both.'),
17+
super(key: key);
18+
19+
@override
20+
Widget build(BuildContext context) {
21+
String? currentRoute = ModalRoute.of(context)?.settings.name;
22+
23+
if (routes != null && routes!.contains(currentRoute)) {
24+
return builder(context, child);
25+
} else if (routesExcluded != null &&
26+
routesExcluded!.contains(currentRoute) == false) {
27+
return builder(context, child);
28+
}
29+
30+
return child;
31+
}
32+
}

0 commit comments

Comments
 (0)