Giter Club home page Giter Club logo

Comments (4)

JanRegent avatar JanRegent commented on July 21, 2024 1

Hi
that's enough, thanks :)

void handleCurrentSelectionState() {
...
print(stateManager.currentRow.cells.values.first.value); //in first column is Google sheet row number
}

I'm working on an application to easily filter data from google sheets

onCurrentSelected can be nice when you have time

from pluto_grid.

bosskmk avatar bosskmk commented on July 21, 2024

Do you want to receive an event every time the currently selected cell (and Row, Column) changes?

If so, you can achieve it with the example code below.

If this is not the case, please reply again.

import 'package:flutter/material.dart';
import 'package:pluto_grid/pluto_grid.dart';

import '../../dummy_data/development.dart';
import '../../widget/pluto_example_button.dart';
import '../../widget/pluto_example_screen.dart';

class MovingScreen extends StatefulWidget {
  static const routeName = 'feature/moving';

  @override
  _MovingScreenState createState() => _MovingScreenState();
}

class _MovingScreenState extends State<MovingScreen> {
  List<PlutoColumn> columns;

  List<PlutoRow> rows;

  PlutoStateManager stateManager;

  @override
  void dispose() {
    stateManager.removeListener(handleCurrentSelectionState);
    
    super.dispose();
  }

  @override
  void initState() {
    super.initState();

    final dummyDate = DummyData(10, 100);

    columns = dummyDate.columns;

    rows = dummyDate.rows;
  }

  void handleCurrentSelectionState() {
    print(stateManager.currentCell.value);
    print(stateManager.currentRow.key);
    print(stateManager.currentColumn.title);
  }

  @override
  Widget build(BuildContext context) {
    return PlutoExampleScreen(
      title: 'Moving',
      topTitle: 'Moving',
      topContents: [
        Text(
            'Change the current cell position with the arrow keys, enter key, and tab key.'),
      ],
      topButtons: [
        PlutoExampleButton(
          url:
              'https://github.com/bosskmk/pluto_grid/blob/master/example/lib/screen/feature/moving_screen.dart',
        ),
      ],
      body: PlutoGrid(
        columns: columns,
        rows: rows,
        onChanged: (PlutoOnChangedEvent event) {
          print(event);
        },
        onLoaded: (PlutoOnLoadedEvent event) {
          stateManager = event.stateManager;
          stateManager.addListener(handleCurrentSelectionState);
        },
      ),
    );
  }
}

from pluto_grid.

bosskmk avatar bosskmk commented on July 21, 2024

If you want to add it as a feature, I will.
I'll add it with onCurrentSelected or whatever name you suggest.

from pluto_grid.

wwyung avatar wwyung commented on July 21, 2024

Sorry to add a followup question here even though the ticket has been closed. I found register a callback via addListener() not quite working the way I wanted. My pluto grid is situated near the bottom of my phone screen, when I edit a cell, the popup keyboard will block the view, hence I want to scroll the grid into view upwards only once when I start editing the cell, however I found the callback was hit multiple times (3 times to be exact) when I tap a cell to edit. Following code is what's in my callback:

void handleCheckedRow() {
if (_maintenanceHistStateMgr.isEditing) {
Scrollable.ensureVisible(_maintenanceHistkey.currentContext!); <== this is the line that got hit 3 times of the same cell
}
}

What I noticed is that only the 3rd call to the callback, the grid will briefly move upwards momentary after I finished editing. Not sure why the grid didn't move the first time. BTW, _maintenanceHistkey is the key to the grid parent.

from pluto_grid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.