Migrate deprecated code in flutter 3.16

This commit is contained in:
Ming Ming 2024-05-21 23:39:24 +08:00
parent 65b66d306f
commit 302cc3938e
6 changed files with 76 additions and 76 deletions

View file

@ -23,8 +23,8 @@ class ContentUriImage extends ImageProvider<ContentUriImage>
}
@override
ImageStreamCompleter loadBuffer(
ContentUriImage key, DecoderBufferCallback decode) {
ImageStreamCompleter loadImage(
ContentUriImage key, ImageDecoderCallback decode) {
return MultiFrameImageStreamCompleter(
codec: _loadAsync(key, decode),
scale: key.scale,
@ -36,7 +36,7 @@ class ContentUriImage extends ImageProvider<ContentUriImage>
}
Future<ui.Codec> _loadAsync(
ContentUriImage key, DecoderBufferCallback decode) async {
ContentUriImage key, ImageDecoderCallback decode) async {
assert(key == this);
final bytes = await ContentUri.readUri(uri);
if (bytes.lengthInBytes == 0) {

View file

@ -18,8 +18,8 @@ class DialogScaffold extends StatelessWidget {
Navigator.of(context).pop();
}
},
child: WillPopScope(
onWillPop: () => Future.value(canPop),
child: PopScope(
canPop: canPop,
child: Scaffold(
backgroundColor: Colors.transparent,
body: GestureDetector(

View file

@ -8,8 +8,8 @@ class ProcessingDialog extends StatelessWidget {
@override
build(BuildContext context) {
return WillPopScope(
onWillPop: () => Future.value(false),
return PopScope(
canPop: false,
child: AlertDialog(
content: Row(
mainAxisSize: MainAxisSize.min,

View file

@ -146,80 +146,81 @@ class _WrappedAccountSettingsState extends State<_WrappedAccountSettings>
},
),
],
child: WillPopScope(
onWillPop: () async => !_bloc.state.shouldReload,
child: CustomScrollView(
slivers: [
SliverAppBar(
pinned: true,
title: Text(L10n.global().settingsAccountTitle),
leading: _BlocSelector<bool>(
selector: (state) => state.shouldReload,
builder: (_, state) =>
state ? const _DoneButton() : const BackButton(),
child: _BlocSelector<bool>(
selector: (state) => state.shouldReload,
builder: (_, shouldReload) => PopScope(
canPop: !shouldReload,
child: CustomScrollView(
slivers: [
SliverAppBar(
pinned: true,
title: Text(L10n.global().settingsAccountTitle),
leading:
shouldReload ? const _DoneButton() : const BackButton(),
),
),
SliverList(
delegate: SliverChildListDelegate(
[
_BlocSelector<String?>(
selector: (state) => state.label,
builder: (context, state) => ListTile(
title: Text(L10n.global().settingsAccountLabelTitle),
subtitle: Text(state ??
L10n.global().settingsAccountLabelDescription),
onTap: () => _onLabelPressed(context),
SliverList(
delegate: SliverChildListDelegate(
[
_BlocSelector<String?>(
selector: (state) => state.label,
builder: (context, state) => ListTile(
title: Text(L10n.global().settingsAccountLabelTitle),
subtitle: Text(state ??
L10n.global().settingsAccountLabelDescription),
onTap: () => _onLabelPressed(context),
),
),
),
_BlocSelector<Account>(
selector: (state) => state.account,
builder: (context, state) => ListTile(
title: Text(L10n.global().settingsIncludedFoldersTitle),
subtitle:
Text(state.roots.map((e) => "/$e").join("; ")),
onTap: () => _onIncludedFoldersPressed(context),
_BlocSelector<Account>(
selector: (state) => state.account,
builder: (context, state) => ListTile(
title:
Text(L10n.global().settingsIncludedFoldersTitle),
subtitle:
Text(state.roots.map((e) => "/$e").join("; ")),
onTap: () => _onIncludedFoldersPressed(context),
),
),
),
_BlocSelector<String>(
selector: (state) => state.shareFolder,
builder: (context, state) => ListTile(
title: Text(L10n.global().settingsShareFolderTitle),
subtitle: Text("/$state"),
onTap: () => _onShareFolderPressed(context),
_BlocSelector<String>(
selector: (state) => state.shareFolder,
builder: (context, state) => ListTile(
title: Text(L10n.global().settingsShareFolderTitle),
subtitle: Text("/$state"),
onTap: () => _onShareFolderPressed(context),
),
),
),
SettingsListCaption(
label: L10n.global().settingsServerAppSectionTitle,
),
_BlocSelector<PersonProvider>(
selector: (state) => state.personProvider,
builder: (context, state) {
if (_bloc.highlight ==
AccountSettingsOption.personProvider) {
return AnimatedBuilder(
animation: _highlightAnimation,
builder: (context, child) => ListTile(
SettingsListCaption(
label: L10n.global().settingsServerAppSectionTitle,
),
_BlocSelector<PersonProvider>(
selector: (state) => state.personProvider,
builder: (context, state) {
if (_bloc.highlight ==
AccountSettingsOption.personProvider) {
return AnimatedBuilder(
animation: _highlightAnimation,
builder: (context, child) => ListTile(
title: Text(
L10n.global().settingsPersonProviderTitle),
subtitle: Text(state.toUserString()),
onTap: () => _onPersonProviderPressed(context),
tileColor: _highlightAnimation.value,
),
);
} else {
return ListTile(
title: Text(
L10n.global().settingsPersonProviderTitle),
subtitle: Text(state.toUserString()),
onTap: () => _onPersonProviderPressed(context),
tileColor: _highlightAnimation.value,
),
);
} else {
return ListTile(
title:
Text(L10n.global().settingsPersonProviderTitle),
subtitle: Text(state.toUserString()),
onTap: () => _onPersonProviderPressed(context),
);
}
},
),
],
);
}
},
),
],
),
),
),
],
],
),
),
),
),

View file

@ -70,8 +70,8 @@ class _SplashState extends State<Splash> {
@override
build(BuildContext context) {
return Scaffold(
body: WillPopScope(
onWillPop: () => Future.value(false),
body: PopScope(
canPop: false,
child: Builder(builder: (context) => _buildContent(context)),
),
);

View file

@ -17,8 +17,7 @@ class PixelImage extends ImageProvider<PixelImage> {
SynchronousFuture<PixelImage>(this);
@override
ImageStreamCompleter loadBuffer(
PixelImage key, DecoderBufferCallback decode) =>
ImageStreamCompleter loadImage(PixelImage key, ImageDecoderCallback decode) =>
OneFrameImageStreamCompleter(_createImageInfo());
Future<ImageInfo> _createImageInfo() async {