-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
I'm experiencing weird issues with the latest stable version of Flutter: 1.7.8+hotfix.4.
I have a simple textfield widget that has an onTap() action. The textfield widget also has a prefix icon which has its own onTap() action. When I press the prefix icon, it completes everything inside the prefix onTap() but it also then goes and completes everything in the textfield onTap().
I've been able to replicate it with the below code. Both onTap methods print outputs to the console. When the prefix icon is clicked, it is outputting the icon onTap as well as the textfield onTap actions.
Replicated in below code
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
void _incrementCounter() {
setState(() {
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
color: Colors.red,
child: TextField(
onTap: () {
print('Hello this is a print out');
},
decoration: InputDecoration(
hintText: 'Hint text',
border: InputBorder.none,
contentPadding: EdgeInsets.only(left: 25.0, top: 16.0),
prefixIcon: IconButton(
icon: Icon(Icons.hotel, color: Colors.green, size: 40.0,),
onPressed: () {
print("Hi this is a second print out");
},
),
),
),
)
],
),
),
);
}
}
Flutter Doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.6 18G87, locale en-NZ)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.37.1)
[✓] Connected device (1 available)
• No issues found!
I have switched back to the master channel in the mean time to get around this issue but would be good to have it fixed.
Thanks.