Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Enable strong language analyzer #305

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/home_widget/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
include: package:flutter_lints/flutter.yaml

analyzer:
language:
strict-raw-types: true
strict-inference: true
strict-casts: true

linter:
rules:
- public_member_api_docs
Expand Down
15 changes: 8 additions & 7 deletions packages/home_widget/lib/src/home_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ class HomeWidget {
/// This method renders the widget to an image (png) file with the provided filename.
/// The png file is saved to the App Group container and the full path is returned as a string.
/// The filename is saved to UserDefaults using the provided key.
static Future renderFlutterWidget(
///
/// This method can throw in case the widget could not be converted to an
/// image or if the image could not be saved to a file.
static Future<String> renderFlutterWidget(
Widget widget, {
required String key,
Size logicalSize = const Size(200, 200),
Expand Down Expand Up @@ -271,13 +274,11 @@ class HomeWidget {
/// currently pinned on the home screen.
/// Returns an empty list if no widgets are pinned.
static Future<List<HomeWidgetInfo>> getInstalledWidgets() async {
final List<dynamic>? result =
await _channel.invokeMethod('getInstalledWidgets');
final result =
await _channel.invokeMethod('getInstalledWidgets') as List<dynamic>?;
return result
?.map(
(widget) =>
HomeWidgetInfo.fromMap(widget.cast<String, dynamic>()),
)
?.map((widget) => (widget as Map).cast<String, dynamic>())
.map(HomeWidgetInfo.fromMap)
.toList() ??
[];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Future<void> callbackDispatcher() async {
final args = call.arguments;

final callback = PluginUtilities.getCallbackFromHandle(
CallbackHandle.fromRawHandle(args[0]),
CallbackHandle.fromRawHandle(args[0] as int),
) as FutureOr<void> Function(Uri?);

final rawUri = args[1] as String?;
Expand Down
9 changes: 6 additions & 3 deletions packages/home_widget/test/home_widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void main() {

test('getWidgetData', () async {
const dataId = 'TestId';
expect(await HomeWidget.getWidgetData(dataId), 'TestData');
expect(await HomeWidget.getWidgetData<String>(dataId), 'TestData');
final arguments = await passedArguments.future;

expect(arguments['id'], dataId);
Expand Down Expand Up @@ -264,8 +264,11 @@ void main() {
when(() => file.create(recursive: true))
.thenAnswer((invocation) async => file);
when(() => file.writeAsBytes(any())).thenAnswer((invocation) async {
byteCompleter
.complete(Uint8List.fromList(invocation.positionalArguments.first));
byteCompleter.complete(
Uint8List.fromList(
invocation.positionalArguments.first as List<int>,
),
);
return file;
});

Expand Down
Loading