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] How to disable cell selection when select mode is setted. HOT 3
- How can I change the text color of ColumnGroup header? HOT 2
- [Bug] ++ pubspec.yaml for pluto_grid_export HOT 3
- [Help] How to create a custom filter for Dates using a datePicker? HOT 2
- [Feature] Custom sorting on column based on value HOT 3
- [Help] - How to detect cell value change without "exiting" the cell HOT 2
- [Help] How to customize the keyboard buttons for numbers value in android HOT 2
- [Help] Copy the content of selecting cell to the clipboard HOT 2
- [Bug] HOT 2
- [Help] Why PlutoDualGridProps onSelected Callback? HOT 2
- TextField Focus issue HOT 2
- [Help] How to disable (showFilterPopup)?[Help] HOT 2
- Show some empty space on the top of first row only in mobile phone HOT 6
- How to move to the next cell automatically when press done button from the android keyboard? HOT 2
- [Feature] Checkbox Column does not respect checkboxTheme of ThemeData HOT 2
- [Issue] date format HOT 2
- [Help] Inline editing date, time or select column HOT 2
- Reagrding Conflict with Pluto_Grid_Plus with Pluto_Grid [Help] HOT 2
- [Help] Is there is a way to remove this extra space/footer HOT 2
- [Help] how to set gridBorderWidth HOT 3
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.