Comments (3)
Thank you for using my package.
I made an example for the Focus problem below.
If the problem is solved or not, please leave a comment.
import 'package:flutter/material.dart';
import 'package:pluto_grid/pluto_grid.dart';
import '../dummy_data/development.dart';
/// How to handle the focus of PlutoGrid and other Focus like Dialog or Modal.
///
/// 1. Wrap the PlutoGrid to FocusScope.
///
/// ```dart
/// child: FocusScope(
/// canRequestFocus: _canGridFocus,
/// child: PlutoGrid(
/// columns: dummyData.columns,
/// rows: dummyData.rows,
/// onChanged: (PlutoOnChangedEvent event) {
/// print(event);
/// },
/// ),
/// ),
/// ```
///
/// 2. When opening a dialog or modal, change the canRequestFocus value
/// passed to the FocusScope of PlutoGrid to false.
///
/// ```dart
/// void setGridFocus(bool flag) {
/// if (flag != _canGridFocus) {
/// setState(() {
/// _canGridFocus = flag;
/// });
/// }
/// }
///
/// floatingActionButton: FloatingActionButton.extended(
/// onPressed: () {
/// setGridFocus(false);
///
/// Future<void> futureModal = showModalBottomSheet<void>(
/// ...
/// );
/// ...
/// },
/// ),
/// ```
///
/// 3. When the open dialog or modal is closed,
/// change the canRequestFocus value passed to the FocusScope of PlutoGrid
/// to true.
///
/// ```dart
/// Future<void> futureModal = showModalBottomSheet<void>(
/// ...
/// );
///
/// futureModal.then((_) {
/// setGridFocus(true);
/// });
/// ```
class HandlingFocusScreen extends StatefulWidget {
static const routeName = 'handling-focus';
@override
_HandlingFocusScreenState createState() => _HandlingFocusScreenState();
}
class _HandlingFocusScreenState extends State<HandlingFocusScreen> {
final dummyData = DummyData(10, 100);
bool _canGridFocus = true;
void setGridFocus(bool flag) {
if (flag != _canGridFocus) {
setState(() {
_canGridFocus = flag;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('PlutoGrid - Handling focus'),),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
setGridFocus(false);
Future<void> futureModal = showModalBottomSheet<void>(
context: context,
builder: (BuildContext context) {
return Container(
height: 200,
color: Colors.white,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('Modal BottomSheet'),
TextField(),
RaisedButton(
child: const Text('Close BottomSheet'),
onPressed: () {
Navigator.pop(context);
},
)
],
),
),
);
},
);
futureModal.then((_) {
setGridFocus(true);
});
},
label: Text('PlutoGrid'),
icon: Icon(Icons.thumb_up),
backgroundColor: Colors.pink,
),
body: Container(
padding: const EdgeInsets.all(30),
child: FocusScope(
canRequestFocus: _canGridFocus,
child: PlutoGrid(
columns: dummyData.columns,
rows: dummyData.rows,
onChanged: (PlutoOnChangedEvent event) {
print(event);
},
),
),
),
);
}
}
from pluto_grid.
That solved it, thank you!!!
from pluto_grid.
I had no idea you could do that.
from pluto_grid.
Related Issues (20)
- [Help] Can we create a custom widget in cells instead of standard ones like text, number, date, time, etc? HOT 2
- [Help] how can i make the rows update automatically when a provider value changes HOT 2
- Showing two lines at the end HOT 2
- [Help] How to write text to filter field of the grid? HOT 1
- How can i set fontWeight: FontWeight.bold in PlutoRow => PlutoCell ?[Help] HOT 2
- [Bug] HOT 1
- [Help] HOT 1
- [Help] header or Footer in TextField can't editing on Flutter Web HOT 1
- Onchanged function is not called correctly HOT 1
- [Help] when i build pluto grid the first row be active i want to not activated by default HOT 1
- [Help] I am using Pluto Grid I want to implement drop down in cell selection for that I am using "renderer" and I am implementing a custom searchable drop down the issue I am facing is that the text field is not working I am not able to type in the text field of the drop down HOT 1
- [Bug] Because pluto_grid_export >=1.0.5 depends on pluto_grid >=3.0.2 <8.0.0 and getx_admin_panel depends on pluto_grid ^8.0.0, pluto_grid_export >=1.0.5 is forbidden. So, because getx_admin_panel depends on pluto_grid_export ^1.0.5, version solving failed. You can try the following suggestion to make the pubspec resolve: * Consider downgrading your constraint on pluto_grid: flutter pub add pluto_grid:^7.0.2
- [Bug] No ui feedback when pressing enter when editing cell in last row
- [Help]
- [Feature] Support Flutter Redux
- [Bug] HOT 1
- [Help] How to change row color after changing cells
- Error: The argument type 'RawKeyEvent' can't be assigned to the parameter type 'KeyEvent'.[Bug] HOT 1
- [Help] Dynamic height as the number of Rows of the table HOT 1
- the equal filter sometimes not working correctly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pluto_grid.