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 kIsMobile = !kIsWeb && (Platform.isIOS || Platform.isAndroid);
final kColorTransparentState = final kColorTransparentState =
MaterialStateProperty.all<Color>(Colors.transparent); WidgetStateProperty.all<Color>(Colors.transparent);
const kColorTransparent = Colors.transparent; const kColorTransparent = Colors.transparent;
const kColorWhite = Colors.white; const kColorWhite = Colors.white;
const kColorBlack = Colors.black; const kColorBlack = Colors.black;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -42,7 +42,8 @@ class SidebarEnvironmentCard extends StatelessWidget {
final colorScheme = Theme.of(context).colorScheme; final colorScheme = Theme.of(context).colorScheme;
final Color color = final Color color =
isGlobal ? colorScheme.secondaryContainer : colorScheme.surface; 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; final Color surfaceTint = colorScheme.primary;
bool isSelected = selectedId == id; bool isSelected = selectedId == id;
bool inEditMode = editRequestId == id; bool inEditMode = editRequestId == id;

View File

@ -42,7 +42,7 @@ class SidebarRequestCard extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Color color = Theme.of(context).colorScheme.surface; final Color color = Theme.of(context).colorScheme.surface;
final Color colorVariant = 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; final Color surfaceTint = Theme.of(context).colorScheme.primary;
bool isSelected = selectedId == id; bool isSelected = selectedId == id;
bool inEditMode = editRequestId == id; bool inEditMode = editRequestId == id;

View File

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

View File

@ -121,7 +121,8 @@ class ViewCodePane extends StatelessWidget {
: Theme.of(context).colorScheme.primaryContainer) : Theme.of(context).colorScheme.primaryContainer)
.withOpacity(kForegroundOpacity), .withOpacity(kForegroundOpacity),
Theme.of(context).colorScheme.surface), 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, borderRadius: kBorderRadius8,
); );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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