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

View file

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

View file

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

View file

@ -146,18 +146,17 @@ class _WrappedAccountSettingsState extends State<_WrappedAccountSettings>
}, },
), ),
], ],
child: WillPopScope( child: _BlocSelector<bool>(
onWillPop: () async => !_bloc.state.shouldReload, selector: (state) => state.shouldReload,
builder: (_, shouldReload) => PopScope(
canPop: !shouldReload,
child: CustomScrollView( child: CustomScrollView(
slivers: [ slivers: [
SliverAppBar( SliverAppBar(
pinned: true, pinned: true,
title: Text(L10n.global().settingsAccountTitle), title: Text(L10n.global().settingsAccountTitle),
leading: _BlocSelector<bool>( leading:
selector: (state) => state.shouldReload, shouldReload ? const _DoneButton() : const BackButton(),
builder: (_, state) =>
state ? const _DoneButton() : const BackButton(),
),
), ),
SliverList( SliverList(
delegate: SliverChildListDelegate( delegate: SliverChildListDelegate(
@ -174,7 +173,8 @@ class _WrappedAccountSettingsState extends State<_WrappedAccountSettings>
_BlocSelector<Account>( _BlocSelector<Account>(
selector: (state) => state.account, selector: (state) => state.account,
builder: (context, state) => ListTile( builder: (context, state) => ListTile(
title: Text(L10n.global().settingsIncludedFoldersTitle), title:
Text(L10n.global().settingsIncludedFoldersTitle),
subtitle: subtitle:
Text(state.roots.map((e) => "/$e").join("; ")), Text(state.roots.map((e) => "/$e").join("; ")),
onTap: () => _onIncludedFoldersPressed(context), onTap: () => _onIncludedFoldersPressed(context),
@ -208,8 +208,8 @@ class _WrappedAccountSettingsState extends State<_WrappedAccountSettings>
); );
} else { } else {
return ListTile( return ListTile(
title: title: Text(
Text(L10n.global().settingsPersonProviderTitle), L10n.global().settingsPersonProviderTitle),
subtitle: Text(state.toUserString()), subtitle: Text(state.toUserString()),
onTap: () => _onPersonProviderPressed(context), onTap: () => _onPersonProviderPressed(context),
); );
@ -223,6 +223,7 @@ class _WrappedAccountSettingsState extends State<_WrappedAccountSettings>
), ),
), ),
), ),
),
); );
} }

View file

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

View file

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