fix: Material theme deprecations

This commit is contained in:
DenserMeerkat
2024-06-28 11:56:52 +05:30
parent 806a72de4b
commit 21ab2b449e
30 changed files with 88 additions and 95 deletions

View File

@ -26,7 +26,7 @@ final kIsAndroid = !kIsWeb && Platform.isAndroid;
final kIsMobile = !kIsWeb && (Platform.isIOS || Platform.isAndroid);
final kColorTransparentState =
MaterialStateProperty.all<Color>(Colors.transparent);
WidgetStateProperty.all<Color>(Colors.transparent);
const kColorTransparent = Colors.transparent;
const kColorWhite = Colors.white;
const kColorBlack = Colors.black;

View File

@ -70,8 +70,8 @@ class EditorTitleActions extends StatelessWidget {
message: tooltip,
child: IconButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(const EdgeInsets.all(0) + padding),
shape: MaterialStateProperty.all(const ContinuousRectangleBorder()),
padding: WidgetStateProperty.all(const EdgeInsets.all(0) + padding),
shape: WidgetStateProperty.all(const ContinuousRectangleBorder()),
),
onPressed: onPressed,
icon: Icon(

View File

@ -44,7 +44,7 @@ class EnvCellField extends StatelessWidget {
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: clrScheme.surfaceVariant,
color: clrScheme.surfaceContainerHighest,
),
),
),

View File

@ -19,7 +19,7 @@ class SidebarFilter extends StatelessWidget {
decoration: BoxDecoration(
borderRadius: kBorderRadius8,
border: Border.all(
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
),
),
child: Row(

View File

@ -88,7 +88,7 @@ class Dashboard extends ConsumerWidget {
VerticalDivider(
thickness: 1,
width: 1,
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
),
Expanded(
child: IndexedStack(

View File

@ -177,7 +177,7 @@ class EditEnvironmentSecretsState
children: [
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: kBorderRadius12,
),
margin: kP10,

View File

@ -178,7 +178,7 @@ class EditEnvironmentVariablesState
children: [
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
borderRadius: kBorderRadius12,
),
margin: kP10,

View File

@ -17,59 +17,54 @@ class EditRequestBody extends ConsumerWidget {
final contentType = ref.watch(selectedRequestModelProvider
.select((value) => value?.httpRequestModel?.bodyContentType));
return Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
),
child: Column(
children: [
const SizedBox(
height: kHeaderHeight,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Select Content Type:",
),
DropdownButtonBodyContentType(),
],
),
return Column(
children: [
const SizedBox(
height: kHeaderHeight,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Select Content Type:",
),
DropdownButtonBodyContentType(),
],
),
Expanded(
child: switch (contentType) {
ContentType.formdata =>
const Padding(padding: kPh4, child: FormDataWidget()),
// TODO: Fix JsonTextFieldEditor & plug it here
ContentType.json => Padding(
padding: kPt5o10,
child: TextFieldEditor(
key: Key("$selectedId-json-body"),
fieldKey: "$selectedId-json-body-editor",
initialValue: requestModel?.httpRequestModel?.body,
onChanged: (String value) {
ref
.read(collectionStateNotifierProvider.notifier)
.update(selectedId, body: value);
},
),
),
Expanded(
child: switch (contentType) {
ContentType.formdata =>
const Padding(padding: kPh4, child: FormDataWidget()),
// TODO: Fix JsonTextFieldEditor & plug it here
ContentType.json => Padding(
padding: kPt5o10,
child: TextFieldEditor(
key: Key("$selectedId-json-body"),
fieldKey: "$selectedId-json-body-editor",
initialValue: requestModel?.httpRequestModel?.body,
onChanged: (String value) {
ref
.read(collectionStateNotifierProvider.notifier)
.update(selectedId, body: value);
},
),
_ => Padding(
padding: kPt5o10,
child: TextFieldEditor(
key: Key("$selectedId-body"),
fieldKey: "$selectedId-body-editor",
initialValue: requestModel?.httpRequestModel?.body,
onChanged: (String value) {
ref
.read(collectionStateNotifierProvider.notifier)
.update(selectedId, body: value);
},
),
),
_ => Padding(
padding: kPt5o10,
child: TextFieldEditor(
key: Key("$selectedId-body"),
fieldKey: "$selectedId-body-editor",
initialValue: requestModel?.httpRequestModel?.body,
onChanged: (String value) {
ref
.read(collectionStateNotifierProvider.notifier)
.update(selectedId, body: value);
},
),
},
)
],
),
),
},
)
],
);
}
}

View File

@ -201,10 +201,6 @@ class _FormDataBodyState extends ConsumerState<FormDataWidget> {
return Stack(
children: [
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
borderRadius: kBorderRadius12,
),
margin: kP10,
child: Column(
children: [

View File

@ -179,10 +179,6 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
return Stack(
children: [
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
borderRadius: kBorderRadius12,
),
margin: kP10,
child: Column(
children: [

View File

@ -179,10 +179,6 @@ class EditRequestURLParamsState extends ConsumerState<EditRequestURLParams> {
return Stack(
children: [
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
borderRadius: kBorderRadius12,
),
margin: kP10,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,

View File

@ -12,10 +12,12 @@ class EditorPaneRequestURLCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Card(
color: kColorTransparent,
surfaceTintColor: kColorTransparent,
elevation: 0,
shape: RoundedRectangleBorder(
side: BorderSide(
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
),
borderRadius: kBorderRadius12,
),
@ -32,7 +34,6 @@ class EditorPaneRequestURLCard extends StatelessWidget {
Expanded(
child: URLTextField(),
),
SizedBox.shrink(),
],
)
: const Row(

View File

@ -21,9 +21,9 @@ class PageBase extends ConsumerWidget {
final isDarkMode =
ref.watch(settingsProvider.select((value) => value.isDark));
final scaffold = Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
backgroundColor: Theme.of(context).colorScheme.surface,
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.background,
backgroundColor: Theme.of(context).colorScheme.surface,
primary: true,
title: Text(title),
centerTitle: true,

View File

@ -9,9 +9,11 @@ class RequestDetailsCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Card(
color: kColorTransparent,
surfaceTintColor: kColorTransparent,
shape: RoundedRectangleBorder(
side: BorderSide(
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
),
borderRadius: kBorderRadius12,
),

View File

@ -42,7 +42,8 @@ class SidebarEnvironmentCard extends StatelessWidget {
final colorScheme = Theme.of(context).colorScheme;
final Color color =
isGlobal ? colorScheme.secondaryContainer : colorScheme.surface;
final Color colorVariant = colorScheme.surfaceVariant.withOpacity(0.5);
final Color colorVariant =
colorScheme.surfaceContainerHighest.withOpacity(0.5);
final Color surfaceTint = colorScheme.primary;
bool isSelected = selectedId == id;
bool inEditMode = editRequestId == id;

View File

@ -42,7 +42,7 @@ class SidebarRequestCard extends StatelessWidget {
Widget build(BuildContext context) {
final Color color = Theme.of(context).colorScheme.surface;
final Color colorVariant =
Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.5);
Theme.of(context).colorScheme.surfaceContainerHighest.withOpacity(0.5);
final Color surfaceTint = Theme.of(context).colorScheme.primary;
bool isSelected = selectedId == id;
bool inEditMode = editRequestId == id;

View File

@ -22,16 +22,16 @@ class CheckBox extends StatelessWidget {
borderRadius: BorderRadius.circular(3),
),
side: BorderSide(
color: colorScheme.surfaceVariant,
color: colorScheme.surfaceContainerHighest,
width: 1.5,
),
splashRadius: 0,
value: value,
onChanged: onChanged,
checkColor: colorScheme.onPrimary,
fillColor: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
fillColor: WidgetStateProperty.resolveWith<Color?>(
(Set<WidgetState> states) {
if (states.contains(WidgetState.selected)) {
return colorScheme.primary;
}
return null;

View File

@ -121,7 +121,8 @@ class ViewCodePane extends StatelessWidget {
: Theme.of(context).colorScheme.primaryContainer)
.withOpacity(kForegroundOpacity),
Theme.of(context).colorScheme.surface),
border: Border.all(color: Theme.of(context).colorScheme.surfaceVariant),
border: Border.all(
color: Theme.of(context).colorScheme.surfaceContainerHighest),
borderRadius: kBorderRadius8,
);

View File

@ -93,7 +93,7 @@ class _TextFieldEditorState extends State<TextFieldEditor> {
enabledBorder: OutlineInputBorder(
borderRadius: kBorderRadius8,
borderSide: BorderSide(
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
),
),
filled: true,

View File

@ -110,7 +110,7 @@ class _JsonTextFieldEditorState extends State<JsonTextFieldEditor> {
enabledBorder: OutlineInputBorder(
borderRadius: kBorderRadius8,
borderSide: BorderSide(
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
),
),
filled: true,

View File

@ -43,7 +43,7 @@ class CellField extends StatelessWidget {
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: clrScheme.surfaceVariant,
color: clrScheme.surfaceContainerHighest,
),
),
),

View File

@ -57,7 +57,7 @@ class ObscurableCellField extends HookWidget {
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: clrScheme.surfaceVariant,
color: clrScheme.surfaceContainerHighest,
),
),
),

View File

@ -93,7 +93,7 @@ class _HeaderFieldState extends State<HeaderField> {
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: colorScheme.surfaceVariant,
color: colorScheme.surfaceContainerHighest,
),
),
),

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:apidash/consts.dart';
class RawTextField extends StatelessWidget {
const RawTextField({
@ -24,6 +25,7 @@ class RawTextField extends StatelessWidget {
isDense: true,
border: InputBorder.none,
hintText: hintText,
contentPadding: kPv8,
),
onTapOutside: (PointerDownEvent event) {
FocusManager.instance.primaryFocus?.unfocus();

View File

@ -246,9 +246,11 @@ class _JsonPreviewerState extends State<JsonPreviewer> {
),
Container(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.background,
color: Theme.of(context).colorScheme.surface,
border: Border.all(
color: Theme.of(context).colorScheme.surfaceVariant),
color: Theme.of(context)
.colorScheme
.surfaceContainerHighest),
borderRadius: kBorderRadius8,
),
child: Row(

View File

@ -405,7 +405,8 @@ class _BodySuccessState extends State<BodySuccess> {
: Theme.of(context).colorScheme.primaryContainer)
.withOpacity(kForegroundOpacity),
Theme.of(context).colorScheme.surface),
border: Border.all(color: Theme.of(context).colorScheme.surfaceVariant),
border: Border.all(
color: Theme.of(context).colorScheme.surfaceContainerHighest),
borderRadius: kBorderRadius8,
);
@ -425,7 +426,7 @@ class _BodySuccessState extends State<BodySuccess> {
? const SizedBox()
: SegmentedButton<ResponseBodyView>(
style: const ButtonStyle(
padding: MaterialStatePropertyAll(
padding: WidgetStatePropertyAll(
EdgeInsets.symmetric(
horizontal: 8,
),

View File

@ -35,7 +35,7 @@ class DashboardSplitViewState extends State<DashboardSplitView> {
data: MultiSplitViewThemeData(
dividerThickness: 3,
dividerPainter: DividerPainters.background(
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
highlightedColor: Theme.of(context).colorScheme.outline.withOpacity(
kHintOpacity,
),

View File

@ -60,7 +60,7 @@ class DrawerSplitView extends StatelessWidget {
child: IconButton(
icon: Icon(
rightDrawerIcon ?? Icons.arrow_forward,
color: Theme.of(context).colorScheme.onBackground,
color: Theme.of(context).colorScheme.onSurface,
),
onPressed: () {
scaffoldKey.currentState!.openEndDrawer();

View File

@ -30,7 +30,7 @@ class _EqualSplitViewState extends State<EqualSplitView> {
data: MultiSplitViewThemeData(
dividerThickness: 3,
dividerPainter: DividerPainters.background(
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
highlightedColor: Theme.of(context).colorScheme.outline.withOpacity(
kHintOpacity,
),

View File

@ -18,7 +18,7 @@ class MapTable extends StatelessWidget {
return Table(
border: TableBorder(
horizontalInside: BorderSide(
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
),
),
columnWidths: const <int, TableColumnWidth>{