increase min sdk and apply new formatter

This commit is contained in:
Fabian Freund
2025-02-18 15:37:03 +01:00
parent f7885fc829
commit a1ee8bef35
266 changed files with 11329 additions and 10058 deletions
@@ -39,21 +39,13 @@ class PageInfoFamily extends Family<AsyncValue<WebPageInfo>> {
const PageInfoFamily();
/// See also [pageInfo].
PageInfoProvider call(
Uri url,
) {
return PageInfoProvider(
url,
);
PageInfoProvider call(Uri url) {
return PageInfoProvider(url);
}
@override
PageInfoProvider getProviderOverride(
covariant PageInfoProvider provider,
) {
return call(
provider.url,
);
PageInfoProvider getProviderOverride(covariant PageInfoProvider provider) {
return call(provider.url);
}
static const Iterable<ProviderOrFamily>? _dependencies = null;
@@ -74,23 +66,19 @@ class PageInfoFamily extends Family<AsyncValue<WebPageInfo>> {
/// See also [pageInfo].
class PageInfoProvider extends FutureProvider<WebPageInfo> {
/// See also [pageInfo].
PageInfoProvider(
Uri url,
) : this._internal(
(ref) => pageInfo(
ref as PageInfoRef,
url,
),
from: pageInfoProvider,
name: r'pageInfoProvider',
debugGetCreateSourceHash:
const bool.fromEnvironment('dart.vm.product')
? null
: _$pageInfoHash,
dependencies: PageInfoFamily._dependencies,
allTransitiveDependencies: PageInfoFamily._allTransitiveDependencies,
url: url,
);
PageInfoProvider(Uri url)
: this._internal(
(ref) => pageInfo(ref as PageInfoRef, url),
from: pageInfoProvider,
name: r'pageInfoProvider',
debugGetCreateSourceHash:
const bool.fromEnvironment('dart.vm.product')
? null
: _$pageInfoHash,
dependencies: PageInfoFamily._dependencies,
allTransitiveDependencies: PageInfoFamily._allTransitiveDependencies,
url: url,
);
PageInfoProvider._internal(
super._createNotifier, {
@@ -155,5 +143,6 @@ class _PageInfoProviderElement extends FutureProviderElement<WebPageInfo>
@override
Uri get url => (origin as PageInfoProvider).url;
}
// ignore_for_file: type=lint
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package
@@ -6,9 +6,6 @@ AsyncSnapshot<T> useCachedFuture<T>(
List<Object?> keys = const <Object>[],
]) {
// ignore: discarded_futures
final cachedFuture = useMemoized(
valueBuilder,
keys,
);
final cachedFuture = useMemoized(valueBuilder, keys);
return useFuture(cachedFuture);
}
@@ -11,13 +11,17 @@ class _DraggableScrollableControllerHook
@override
HookState<DraggableScrollableController, Hook<DraggableScrollableController>>
createState() {
createState() {
return _DraggableScrollableControllerHookState();
}
}
class _DraggableScrollableControllerHookState extends HookState<
DraggableScrollableController, _DraggableScrollableControllerHook> {
class _DraggableScrollableControllerHookState
extends
HookState<
DraggableScrollableController,
_DraggableScrollableControllerHook
> {
late final _controller = DraggableScrollableController();
@override
@@ -6,11 +6,8 @@ void useListenableCallback(
void Function() callback, [
List<Object?>? keys,
]) {
useEffect(
() {
listenable?.addListener(callback);
return () => listenable?.removeListener(callback);
},
keys ?? [listenable],
);
useEffect(() {
listenable?.addListener(callback);
return () => listenable?.removeListener(callback);
}, keys ?? [listenable]);
}
+3 -6
View File
@@ -2,10 +2,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
void useOnDispose(VoidCallback onDispose) {
useEffect(
() {
return onDispose;
},
const [],
);
useEffect(() {
return onDispose;
}, const []);
}
@@ -3,11 +3,8 @@ import 'dart:async';
import 'package:flutter_hooks/flutter_hooks.dart';
void useOnInitialization(FutureOr<void> Function() callback) {
useEffect(
() {
Future.microtask(callback);
return null;
},
[],
);
useEffect(() {
Future.microtask(callback);
return null;
}, []);
}
@@ -10,7 +10,7 @@ class _OverlayPortalControllerHook extends Hook<OverlayPortalController> {
@override
HookState<OverlayPortalController, Hook<OverlayPortalController>>
createState() {
createState() {
return _OverlayPortalControllerHookState();
}
}
+24 -27
View File
@@ -6,34 +6,31 @@ void useSyncPageWithTab(
PageController pageController, {
void Function(int index)? onIndexChanged,
}) {
useEffect(
() {
Future<void> syncPage() async {
await pageController.animateToPage(
tabController.index,
curve: Curves.linear,
duration: const Duration(milliseconds: 300),
);
onIndexChanged?.call(tabController.index);
useEffect(() {
Future<void> syncPage() async {
await pageController.animateToPage(
tabController.index,
curve: Curves.linear,
duration: const Duration(milliseconds: 300),
);
onIndexChanged?.call(tabController.index);
}
void syncTab() {
if (!tabController.indexIsChanging) {
final index = pageController.page!.round();
tabController.animateTo(index);
onIndexChanged?.call(index);
}
}
void syncTab() {
if (!tabController.indexIsChanging) {
final index = pageController.page!.round();
tabController.addListener(syncPage);
pageController.addListener(syncTab);
tabController.animateTo(index);
onIndexChanged?.call(index);
}
}
tabController.addListener(syncPage);
pageController.addListener(syncTab);
return () {
tabController.removeListener(syncPage);
pageController.removeListener(syncTab);
};
},
[tabController, pageController],
);
return () {
tabController.removeListener(syncPage);
pageController.removeListener(syncTab);
};
}, [tabController, pageController]);
}
@@ -19,8 +19,8 @@ class AnimateGradientShader extends StatefulWidget {
this.duration = const Duration(seconds: 4),
this.animateAlignments = true,
this.reverse = true,
}) : assert(primaryColors.length >= 2),
assert(primaryColors.length == secondaryColors.length);
}) : assert(primaryColors.length >= 2),
assert(primaryColors.length == secondaryColors.length);
/// [controller]: pass this to have a fine control over the [Animation]
final AnimationController? controller;
@@ -131,19 +131,22 @@ class _AnimateGradientShaderState extends State<AnimateGradientShader>
animation: _animation!,
builder: (BuildContext context, Widget? child) {
final gradient = LinearGradient(
begin: widget.animateAlignments
? begin.evaluate(_animation!)
: widget.primaryBegin,
end: widget.animateAlignments
? end.evaluate(_animation!)
: widget.primaryEnd,
begin:
widget.animateAlignments
? begin.evaluate(_animation!)
: widget.primaryBegin,
end:
widget.animateAlignments
? end.evaluate(_animation!)
: widget.primaryEnd,
colors: _evaluateColors(_animation!),
);
return ShaderMask(
shaderCallback: (Rect bounds) {
return gradient
.createShader(Rect.fromLTWH(0, 0, bounds.width, bounds.height));
return gradient.createShader(
Rect.fromLTWH(0, 0, bounds.width, bounds.height),
);
},
child: widget.child,
);
@@ -160,10 +163,7 @@ class _AnimateGradientShaderState extends State<AnimateGradientShader>
for (int i = 0; i < primaryColors.length; i++) {
colorTweens.add(
ColorTween(
begin: primaryColors[i],
end: secondaryColors[i],
),
ColorTween(begin: primaryColors[i], end: secondaryColors[i]),
);
}
@@ -204,17 +204,12 @@ class _AnimateGradientShaderState extends State<AnimateGradientShader>
void _setAnimations() {
_controller?.dispose();
_controller = (widget.controller ??
AnimationController(
vsync: this,
duration: widget.duration,
))
..repeat(reverse: widget.reverse);
_controller =
(widget.controller ??
AnimationController(vsync: this, duration: widget.duration))
..repeat(reverse: widget.reverse);
_animation = CurvedAnimation(
parent: _controller!,
curve: Curves.easeInOut,
);
_animation = CurvedAnimation(parent: _controller!, curve: Curves.easeInOut);
}
@override
@@ -77,7 +77,8 @@ class AnimatedIndexedStack extends StatefulWidget {
Widget child,
Animation<double> primaryAnimation,
Animation<double> secondaryAnimation,
) transitionBuilder;
)
transitionBuilder;
/// A function that lays out all the children in this IndexedStack.
/// This defaults to [PageTransitionSwitcher.defaultLayoutBuilder].
@@ -91,10 +92,7 @@ class AnimatedIndexedStack extends StatefulWidget {
/// The default layout builder for [AnimatedIndexedStack].
/// Contains all the children in a [Stack].
static Widget defaultLayoutBuilder(List<Widget> entries) {
return Stack(
alignment: Alignment.center,
children: entries,
);
return Stack(alignment: Alignment.center, children: entries);
}
@override
@@ -173,8 +171,9 @@ class _AnimatedIndexedStackState extends State<AnimatedIndexedStack>
for (final child in widget.children) {
// We find the previous entry by looking for an identical child widget.
// If the children of this Stack share widget types, they must be given unique keys.
final int existingIndex =
_entries.indexWhere((entry) => Widget.canUpdate(entry.child, child));
final int existingIndex = _entries.indexWhere(
(entry) => Widget.canUpdate(entry.child, child),
);
_ChildEntry? existingEntry;
if (existingIndex != -1) {
@@ -276,17 +275,17 @@ class _AnimatedIndexedStackState extends State<AnimatedIndexedStack>
}
_ChildEntry _newEntry(Widget child) => _ChildEntry(
key: GlobalKey(),
child: child,
primaryController: AnimationController(
duration: widget.duration,
vsync: this,
),
secondaryController: AnimationController(
duration: widget.duration,
vsync: this,
),
);
key: GlobalKey(),
child: child,
primaryController: AnimationController(
duration: widget.duration,
vsync: this,
),
secondaryController: AnimationController(
duration: widget.duration,
vsync: this,
),
);
@override
void dispose() {
@@ -297,30 +296,28 @@ class _AnimatedIndexedStackState extends State<AnimatedIndexedStack>
}
Widget _buildChild(_ChildEntry entry) => AnimatedBuilder(
animation: Listenable.merge([
animation: Listenable.merge([
entry.primaryController,
entry.secondaryController,
]),
builder: (context, child) {
final bool isVisible =
entry.primaryController.isAnimating ||
entry.secondaryController.isAnimating ||
entry == _currentEntry;
return Visibility(
visible: isVisible,
maintainState: true,
child: widget.transitionBuilder(
KeyedSubtree(key: entry.key, child: child!),
entry.primaryController,
entry.secondaryController,
]),
builder: (context, child) {
final bool isVisible = entry.primaryController.isAnimating ||
entry.secondaryController.isAnimating ||
entry == _currentEntry;
return Visibility(
visible: isVisible,
maintainState: true,
child: widget.transitionBuilder(
KeyedSubtree(
key: entry.key,
child: child!,
),
entry.primaryController,
entry.secondaryController,
),
);
},
child: entry.child,
),
);
},
child: entry.child,
);
@override
Widget build(BuildContext context) {
@@ -123,14 +123,15 @@ class AutoSuggestTextField extends HookWidget {
text: suggestion!.substring(text.length),
style: TextStyle(
height: 1.2,
color: Theme.of(context)
.colorScheme
.onSurfaceVariant,
backgroundColor: suggestionHighlightColor ??
Theme.of(context)
.colorScheme
.primary
.withValues(alpha: 0.40),
color:
Theme.of(
context,
).colorScheme.onSurfaceVariant,
backgroundColor:
suggestionHighlightColor ??
Theme.of(
context,
).colorScheme.primary.withValues(alpha: 0.40),
),
),
],
@@ -147,7 +148,8 @@ class AutoSuggestTextField extends HookWidget {
focusNode: focusNode,
decoration: baseDecoration.copyWith(
label: baseDecoration.label ?? const Text(''),
floatingLabelBehavior: baseDecoration.floatingLabelBehavior ??
floatingLabelBehavior:
baseDecoration.floatingLabelBehavior ??
FloatingLabelBehavior.never,
),
style: style,
+46 -45
View File
@@ -39,18 +39,18 @@ class ExternalResultsAutocomplete<T extends Object> extends StatefulWidget {
this.onSelected,
this.textEditingController,
this.initialValue,
}) : assert(
fieldViewBuilder != null ||
(key != null &&
focusNode != null &&
textEditingController != null),
'Pass in a fieldViewBuilder, or otherwise create a separate field and pass in the FocusNode, TextEditingController, and a key. Use the key with RawAutocomplete.onFieldSubmitted.',
),
assert((focusNode == null) == (textEditingController == null)),
assert(
!(textEditingController != null && initialValue != null),
'textEditingController and initialValue cannot be simultaneously defined.',
);
}) : assert(
fieldViewBuilder != null ||
(key != null &&
focusNode != null &&
textEditingController != null),
'Pass in a fieldViewBuilder, or otherwise create a separate field and pass in the FocusNode, TextEditingController, and a key. Use the key with RawAutocomplete.onFieldSubmitted.',
),
assert((focusNode == null) == (textEditingController == null)),
assert(
!(textEditingController != null && initialValue != null),
'textEditingController and initialValue cannot be simultaneously defined.',
);
/// {@template flutter.widgets.RawAutocomplete.fieldViewBuilder}
/// Builds the field whose input is used to get the options.
@@ -131,7 +131,7 @@ class ExternalResultsAutocomplete<T extends Object> extends StatefulWidget {
final AutocompleteOnSelected<T>? onSelected;
final FutureOr<void> Function(TextEditingValue textEditingValue)
onTextChanged;
onTextChanged;
/// The [TextEditingController] that is used for the text field.
///
@@ -194,31 +194,31 @@ class _RawAutocompleteState<T extends Object>
TextEditingController? _internalTextEditingController;
TextEditingController get _textEditingController {
return widget.textEditingController ??
(_internalTextEditingController ??= TextEditingController()
..addListener(_onChangedField));
(_internalTextEditingController ??=
TextEditingController()..addListener(_onChangedField));
}
FocusNode? _internalFocusNode;
FocusNode get _focusNode {
return widget.focusNode ??
(_internalFocusNode ??= FocusNode()
..addListener(_updateOptionsViewVisibility));
(_internalFocusNode ??=
FocusNode()..addListener(_updateOptionsViewVisibility));
}
late final Map<Type, CallbackAction<Intent>> _actionMap =
<Type, CallbackAction<Intent>>{
AutocompletePreviousOptionIntent:
_AutocompleteCallbackAction<AutocompletePreviousOptionIntent>(
onInvoke: _highlightPreviousOption,
isEnabledCallback: () => _canShowOptionsView,
),
AutocompleteNextOptionIntent:
_AutocompleteCallbackAction<AutocompleteNextOptionIntent>(
onInvoke: _highlightNextOption,
isEnabledCallback: () => _canShowOptionsView,
),
DismissIntent: CallbackAction<DismissIntent>(onInvoke: _hideOptions),
};
AutocompletePreviousOptionIntent:
_AutocompleteCallbackAction<AutocompletePreviousOptionIntent>(
onInvoke: _highlightPreviousOption,
isEnabledCallback: () => _canShowOptionsView,
),
AutocompleteNextOptionIntent:
_AutocompleteCallbackAction<AutocompleteNextOptionIntent>(
onInvoke: _highlightNextOption,
isEnabledCallback: () => _canShowOptionsView,
),
DismissIntent: CallbackAction<DismissIntent>(onInvoke: _hideOptions),
};
late StreamSubscription<Iterable<T>> _optionsSubscription;
Iterable<T> _options = Iterable<T>.empty();
@@ -230,11 +230,11 @@ class _RawAutocompleteState<T extends Object>
static const Map<ShortcutActivator, Intent> _shortcuts =
<ShortcutActivator, Intent>{
SingleActivator(LogicalKeyboardKey.arrowUp):
AutocompletePreviousOptionIntent(),
SingleActivator(LogicalKeyboardKey.arrowDown):
AutocompleteNextOptionIntent(),
};
SingleActivator(LogicalKeyboardKey.arrowUp):
AutocompletePreviousOptionIntent(),
SingleActivator(LogicalKeyboardKey.arrowDown):
AutocompleteNextOptionIntent(),
};
bool get _canShowOptionsView =>
_focusNode.hasFocus && _selection == null && _options.isNotEmpty;
@@ -324,17 +324,15 @@ class _RawAutocompleteState<T extends Object>
Widget _buildOptionsView(BuildContext context) {
final TextDirection textDirection = Directionality.of(context);
final Alignment followerAlignment =
switch (widget.optionsViewOpenDirection) {
final Alignment followerAlignment = switch (widget
.optionsViewOpenDirection) {
OptionsViewOpenDirection.up => AlignmentDirectional.bottomStart,
OptionsViewOpenDirection.down => AlignmentDirectional.topStart,
}
.resolve(textDirection);
}.resolve(textDirection);
final Alignment targetAnchor = switch (widget.optionsViewOpenDirection) {
OptionsViewOpenDirection.up => AlignmentDirectional.topStart,
OptionsViewOpenDirection.down => AlignmentDirectional.bottomStart,
}
.resolve(textDirection);
}.resolve(textDirection);
return CompositedTransformFollower(
link: _optionsLayerLink,
@@ -345,8 +343,9 @@ class _RawAutocompleteState<T extends Object>
child: AutocompleteHighlightedOption(
highlightIndexNotifier: _highlightedOptionIndex,
child: Builder(
builder: (BuildContext context) =>
widget.optionsViewBuilder(context, _select, _options),
builder:
(BuildContext context) =>
widget.optionsViewBuilder(context, _select, _options),
),
),
),
@@ -358,8 +357,9 @@ class _RawAutocompleteState<T extends Object>
super.initState();
final TextEditingController initialController =
widget.textEditingController ??
(_internalTextEditingController =
TextEditingController.fromValue(widget.initialValue));
(_internalTextEditingController = TextEditingController.fromValue(
widget.initialValue,
));
initialController.addListener(_onChangedField);
widget.focusNode?.addListener(_updateOptionsViewVisibility);
_optionsSubscription = widget.optionsStream.listen(_onUpateOptions);
@@ -406,7 +406,8 @@ class _RawAutocompleteState<T extends Object>
@override
Widget build(BuildContext context) {
final Widget fieldView = widget.fieldViewBuilder?.call(
final Widget fieldView =
widget.fieldViewBuilder?.call(
context,
_textEditingController,
_focusNode,
+11 -13
View File
@@ -23,19 +23,17 @@ class UrlIcon extends HookConsumerWidget {
enabled: !icon.hasData,
child: SizedBox.square(
dimension: iconSize,
child: (icon.data != null)
? RepaintBoundary(
child: RawImage(
image: icon.data?.image.value,
height: iconSize,
width: iconSize,
fit: BoxFit.fill,
),
)
: Icon(
MdiIcons.web,
size: iconSize,
),
child:
(icon.data != null)
? RepaintBoundary(
child: RawImage(
image: icon.data?.image.value,
height: iconSize,
width: iconSize,
fit: BoxFit.fill,
),
)
: Icon(MdiIcons.web, size: iconSize),
),
);
}
@@ -22,27 +22,31 @@ class FailureWidget extends StatelessWidget {
children: [
ListTile(
title: Text(title ?? 'Something went wrong'),
subtitle: exception != null
? switch (exception) {
final String string => Text(string),
_ => Text(exception.runtimeType.toString())
}
: null,
trailing: compact && onRetry != null
? IconButton.outlined(
onPressed: onRetry,
style: IconButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
icon: const Icon(Icons.refresh_outlined),
)
: null,
subtitle:
exception != null
? switch (exception) {
final String string => Text(string),
_ => Text(exception.runtimeType.toString()),
}
: null,
trailing:
compact && onRetry != null
? IconButton.outlined(
onPressed: onRetry,
style: IconButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
icon: const Icon(Icons.refresh_outlined),
)
: null,
textColor: Theme.of(context).colorScheme.error,
),
if (!compact && onRetry != null)
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
padding: const EdgeInsets.symmetric(
horizontal: 12.0,
vertical: 8.0,
),
child: SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
+1 -3
View File
@@ -62,9 +62,7 @@ class MainApp extends HookConsumerWidget {
darkTheme: darkTheme,
themeMode: themeMode,
home: Scaffold(
appBar: AppBar(
title: const Text('Initiallization Error'),
),
appBar: AppBar(title: const Text('Initiallization Error')),
body: Center(
child: FailureWidget(
title: 'Could not initialize App',
@@ -9,12 +9,7 @@ class _BadgeWrapper extends StatelessWidget {
@override
Widget build(BuildContext context) {
return count != null
? Badge.count(
count: count!,
child: child,
)
: child;
return count != null ? Badge.count(count: count!, child: child) : child;
}
}
@@ -57,15 +52,9 @@ class SelectableChips<T extends S, S, K> extends StatelessWidget {
(item) => itemId(item) == itemId(selectedItem),
);
if (selectedIndex < 0) {
items = [
selectedItem,
...items,
];
items = [selectedItem, ...items];
} else {
items = [
items.removeAt(selectedIndex),
...items,
];
items = [items.removeAt(selectedIndex), ...items];
}
}
@@ -84,7 +73,8 @@ class SelectableChips<T extends S, S, K> extends StatelessWidget {
child: _BadgeWrapper(
count: itemBadgeCount?.call(item),
child: FilterChip(
selected: selectedItem != null &&
selected:
selectedItem != null &&
itemId(item) == itemId(selectedItem as S),
showCheckmark: false,
onSelected: (value) {
@@ -94,11 +84,12 @@ class SelectableChips<T extends S, S, K> extends StatelessWidget {
onDeleted?.call(item);
}
},
onDeleted: deleteIcon
? () {
onDeleted?.call(item);
}
: null,
onDeleted:
deleteIcon
? () {
onDeleted?.call(item);
}
: null,
label: itemLabel.call(item),
avatar: itemAvatar?.call(item),
),
@@ -11,18 +11,15 @@ class SpeechToTextButton extends StatelessWidget {
Widget build(BuildContext context) {
return IconButton(
onPressed: () async {
final isServiceAvailable =
await SpeechToTextGoogleDialog.getInstance().showGoogleDialog(
onTextReceived: onTextReceived,
// locale: "en-US",
);
final isServiceAvailable = await SpeechToTextGoogleDialog.getInstance()
.showGoogleDialog(
onTextReceived: onTextReceived,
// locale: "en-US",
);
if (!isServiceAvailable) {
if (context.mounted) {
ui_helper.showErrorMessage(
context,
'Service is not available',
);
ui_helper.showErrorMessage(context, 'Service is not available');
}
}
},
@@ -13,9 +13,10 @@ class WebsiteTitleTile extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final pageInfoAsync = (precachedInfo?.isPageInfoComplete ?? false)
? AsyncValue.data(precachedInfo!)
: ref.watch(pageInfoProvider(url));
final pageInfoAsync =
(precachedInfo?.isPageInfoComplete ?? false)
? AsyncValue.data(precachedInfo!)
: ref.watch(pageInfoProvider(url));
return Skeletonizer(
enabled: pageInfoAsync.isLoading && precachedInfo == null,
@@ -38,22 +39,24 @@ class WebsiteTitleTile extends HookConsumerWidget {
onRetry: () => ref.refresh(pageInfoProvider(url)),
);
},
loading: () => (precachedInfo != null)
? ListTile(
leading: RawImage(
image: precachedInfo!.favicon?.image.value,
height: 24,
width: 24,
),
contentPadding: EdgeInsets.zero,
title: Text(precachedInfo!.title ?? 'Unknown Title'),
subtitle: Text(url.authority),
)
: const ListTile(
contentPadding: EdgeInsets.zero,
title: Bone.text(),
subtitle: Bone.text(),
),
loading:
() =>
(precachedInfo != null)
? ListTile(
leading: RawImage(
image: precachedInfo!.favicon?.image.value,
height: 24,
width: 24,
),
contentPadding: EdgeInsets.zero,
title: Text(precachedInfo!.title ?? 'Unknown Title'),
subtitle: Text(url.authority),
)
: const ListTile(
contentPadding: EdgeInsets.zero,
title: Bone.text(),
subtitle: Bone.text(),
),
),
);
}