Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Crash when trying to paste to a cell with an empty clipboard #1123

Open
itsnotmeman opened this issue Nov 22, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@itsnotmeman
Copy link

Steps to reproduce the bug

  1. Clear your clipboard.
  2. Paste into any PlutoGrid cell (ctrl + v)
  3. The program will crash. (_TypeError (Null check operator used on a null value))

Expected results

Nothing should happen.

Actual results

The program will crash. (_TypeError (Null check operator used on a null value))

Code sample

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'PlutoGrid Example',
      home: Scaffold(
        appBar: AppBar(title: const Text('PlutoGrid Example')),
        body: const SimplePlutoGrid(),
      ),
    );
  }
}

class SimplePlutoGrid extends StatelessWidget {
  const SimplePlutoGrid({super.key});

  @override
  Widget build(BuildContext context) {
    // Define the columns for the grid
    final List<PlutoColumn> columns = [
      PlutoColumn(
        title: 'ID',
        field: 'id',
        minWidth: 40,
        width: 40,
        enableContextMenu: false,
        enableDropToResize: false,
        type: PlutoColumnType.number(),
      ),
      PlutoColumn(
        title: 'Name',
        field: 'name',
        type: PlutoColumnType.text(),
      ),
      PlutoColumn(
        title: 'Age',
        field: 'age',
        type: PlutoColumnType.number(),
      ),
    ];

    // Define the rows for the grid
    final List<PlutoRow> rows = [
      PlutoRow(cells: {
        'id': PlutoCell(value: 1),
        'name': PlutoCell(value: 'Alice'),
        'age': PlutoCell(value: 25),
      }),
      PlutoRow(cells: {
        'id': PlutoCell(value: 2),
        'name': PlutoCell(value: 'Bob'),
        'age': PlutoCell(value: 30),
      }),
      PlutoRow(cells: {
        'id': PlutoCell(value: 3),
        'name': PlutoCell(value: 'Charlie'),
        'age': PlutoCell(value: 35),
      }),
    ];

    return PlutoGrid(
      columns: columns,
      rows: rows,
      configuration: PlutoGridConfiguration(
        enableMoveHorizontalInEditing: true, // Allow horizontal navigation
      ),
    );
  }
}

Execution Environment

Flutter version
Flutter version is 3.24.5

PlutoGrid version
PlutoGrid version is 8.0.0

OS
Windows 11

@itsnotmeman itsnotmeman added the bug Something isn't working label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant