I'm using flutter's latest version to create a bottom model sheet with a text field which is auto focused, so as soon as I click the button to show that bottom model the UI lags while soft keyboard appears. I've tried setting the following property to false, but still no luck.
Scaffold(
...
resizeToAvoidBottomInset: false,
)
Here's the code bottom sheet is being called:
floatingActionButton: FloatingActionButton(
onPressed: () async {
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (context) => const TaskBottomSheet());
}),
There's no lag until I make the soft keyboard appear in the screen. How can I fix this?
Did you try to run it in the profile or release mode? Flutter optimizes your app in these two modes.
flutter run --profile or flutter run --release
Related
I'm using flutter_typeahead: ^4.3.3 package for search bar.
When the onChange event is dispatched, it will call API and show suggestion on that but it's running one keyword behind the actual search and whenever I try to tap on suggestion it will not navigate to next screen.
I had try to navigate on onSuggestionSelected, onTap and suggestionsCallback but it will not navigate to next screen.
The issue you're facing with flutter_typeahead might be due to incorrect implementation of the onSuggestionSelected or onTap event handlers.
To correctly navigate to the next screen, you need to use the Navigator class in Flutter. Here's an example on how to do it using the onSuggestionSelected event handler:
TypeAheadField(
onSuggestionSelected: (suggestion) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => YourNextScreen(suggestion),
),
);
},
// Other TypeAheadField properties and configurations
)
In the code above, YourNextScreen is the widget class for the next screen you want to navigate to. The suggestion argument is the selected suggestion from the suggestions list.
Make sure to pass the appropriate BuildContext to the Navigator and also ensure that you have set up the routing in your Flutter app.
I'm using the persisten_bottom_nav_bar package to handle the bottom navigation in our app. The issue I'm having is that when I call FocusScope.of(context).unfocus(); to get rid of the keyboard, the navigation bar goes dark for a second. Has anyone figure out how to fix this issue?
So I implemented the package incorrectly, I fixed it by changing the parameters to the ones below. The main issue was hideNavigationBarWhenKeyboardShows which was basically rendering the bottomAppBar every-time the keyboard closed.
PersistentTabView(
resizeToAvoidBottomInset: false,
hideNavigationBarWhenKeyboardShows: false
Tip: Add resizeToAvoidBottomInset: false to any screens with textFields to prevent a small white spacing in between the keyboard and the scaffold
Scaffold(
resizeToAvoidBottomInset: false,
I'm developing a chat application which allows users to reply to others' messages. I want to make it so that when user long pressed a chat bubble, a dialog will appear directly on top of the bubble with the options to either reply or forward. I tried using showDialog, but the dialog always appears in the center. Is there any way to do this with flutter? Any help will be appreciated.
Please refer to this focused_menu plugin
Example
or
You can also try flutter menu
You can use show aligned dialog.
Just use flutter_smart_dialog: ^4.5.3+7
or use aligned_dialog: ^0.0.6
Make custom dialog by giving scaffold a transperant background. pass your custom widget to the body, align it wherever you want
showGeneralDialog(
barrierColor: Colors.black.withOpacity(0.8),
context: context,
barrierDismissible: false,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
transitionDuration: const Duration(milliseconds: 200),
pageBuilder: (context, animation1, animation2) {
return Scaffold(
body:CustomWidgetDialog(),
);
},
);
In my flutter app, I want to get a list of buttons inside a popup when a button is tapped. In that list, I wish to have buttons which when clicked should edit a Text widget that I used in my app
Any suggestion for this??
you have to use the dialog
On a button click show dialog as -
showDialog(
context: context,
builder: (_) => Button(),
);
Check this also link
Image understands you the purpose better
https://i.stack.imgur.com/Z45YH.jpg
I tried everything but failed!
Navigating
Navigating to a new Page is easy
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondRoute()),
);
"SecoundRoute" is the Widget you will open in a new Window.
More information about this here.
Swipe gesture
This is a bit more complicated. There is a widget called "Dismissible" but like the name say its to dismiss something from a List. There is an issue which suggests to make it possible to avoid deleting the entry from the ListView directly. However, this is inactive. I don't know whether this feature is there or where it is on the priority list.
dismissible
If you use a prebuild and static list of widgets you can maybe get around it, by navigating to the naw page in the onDismissed: callback and using pushReplacement in the rout back. This will case your main page to get Rebuild. Because your Widgets are static I think they will be their again.
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => Page1(),
),
);
flutter_slidable
There is a plugin called flutter_slidable perhaps a solution can be found with this plugin.