-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Hello! Android magnifier doesnt work properly. I noticed the issue with editText widget but it is not working for every type of View.
Steps to Reproduce
1) Execute flutter run on the code sample
Lib folder is also available here
https://drive.google.com/file/d/1mL3YV9kRTDJ8HwAtfywQW47jN9KLSBCn/view?usp=sharing
Main.dart
import 'dart:io' show Platform;
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'EditText Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: AppBar(
title: Text('EditText - Platform View'),
),
body: Center(
child: Padding(
padding: EdgeInsets.fromLTRB(40, 0, 40, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: const <Widget>[
const Text('Android EditText:'),
SizedBox(height: 8),
SizedBox(
height: 50,
child: NativeTextBox(),
),
],
),
),
),
),
);
}
}
class NativeTextBox extends StatelessWidget {
const NativeTextBox({super.key});
@override
Widget build(BuildContext context) {
const String viewType = 'native-widget';
const Map<String, dynamic> creationParams = <String, dynamic>{};
if(!Platform.isAndroid) {
return Text('Implemented only for Android!');
}
return PlatformViewLink(
viewType: viewType,
surfaceFactory:
(context, controller) {
return AndroidViewSurface(
controller: controller as AndroidViewController,
gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
);
},
onCreatePlatformView: (params) {
return PlatformViewsService.initSurfaceAndroidView(
id: params.id,
viewType: viewType,
layoutDirection: TextDirection.ltr,
creationParams: creationParams,
creationParamsCodec: const StandardMessageCodec(),
onFocus: () {
params.onFocusChanged(true);
},
)
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
..create();
},
);
}
}
Expected results:
Magnifier glass should display magnified text as in this video below.
Screenrecorder-2022-09-30-16-46-26-557.mp4
Actual results:
Here is a video showing the issue. It is worth noticing that the magnifier widget appears on the proper gesture, but its background is transparent, its position seems not correct, and it doesn’t display the magnified text. From other tests I noticed that magnifier glass do not work with every type of view, not just the textfield.
Screenrecorder-2022-09-30-16-35-07-84.mp4
Flutter doctor:
[✓] Flutter (Channel stable, 3.3.2, on macOS 12.2 21D49 darwin-arm, locale en-IT)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
✗ cmdline-tools component is missing
Run path/to/sdkmanager --install "cmdline-tools;latest"
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability