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

NotWorking with DataTable #129

Open
sertancayci opened this issue Jan 11, 2023 · 0 comments
Open

NotWorking with DataTable #129

sertancayci opened this issue Jan 11, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@sertancayci
Copy link

Steps to Reproduce
When I use AutoSizeText under the datatable as in the code I left below, I get an error.

The following assertion was thrown during performLayout():
LayoutBuilder does not support returning intrinsic dimensions.

Calculating the intrinsic dimensions would require running the layout callback speculatively, which might mutate the live render object tree.

The relevant error-causing widget was:
Table Table:file:///C:/Users/Thinkpad/Desktop/project/.fvm/flutter_sdk/packages/flutter/lib/src/material/data_table.dart:1044:16
When the exception was thrown, this was the stack:
#0 _RenderLayoutBuilder._debugThrowIfNotCheckingIntrinsics. (package:flutter/src/widgets/layout_builder.dart:348:9)
#1 _RenderLayoutBuilder._debugThrowIfNotCheckingIntrinsics (package:flutter/src/widgets/layout_builder.dart:355:6)
#2 _RenderLayoutBuilder.computeMaxIntrinsicWidth (package:flutter/src/widgets/layout_builder.dart:288:12)
#3 RenderBox._computeIntrinsicDimension. (package:flutter/src/rendering/box.dart:1416:23)
#4 _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:527:23)
#5 RenderBox._computeIntrinsicDimension (package:flutter/src/rendering/box.dart:1414:57)
#6 RenderBox.getMaxIntrinsicWidth (package:flutter/src/rendering/box.dart:1616:12)
#7 RenderFlex.computeMaxIntrinsicWidth. (package:flutter/src/rendering/flex.dart:618:60)

Code sample

import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:project/res/app_color.dart';
import 'package:project/widgets/bottom_navigation_bar_widget.dart';
import 'package:project/widgets/titled_app_bar_widget.dart';

import '../../res/app_font.dart';

class ComexCoper2View extends StatefulWidget {
  static const routeName = '/tools/comexcopper2';

  const ComexCoper2View({Key? key}) : super(key: key);

  @override
  State<ComexCoper2View> createState() => _ComexCoper2ViewState();
}

class _ComexCoper2ViewState extends State<ComexCoper2View> {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        appBar: TitledAppBar(title: "Test Calculation"),
        bottomNavigationBar: BottomNavigationBarWidget(selectedIndex: 3),
        body: _buildBody(context),
      ),
    );
  }

  _buildBody(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: AppColors.whiteColor,
      ),
      child: DataTable(
        columns: const <DataColumn>[
          DataColumn(
            label: AutoSizeText(
              'Name',
              style: TextStyle(fontStyle: FontStyle.italic),
            ),
          ),
          DataColumn(
            label: Text(
              'Age',
              style: TextStyle(fontStyle: FontStyle.italic),
            ),
          ),
          DataColumn(
            label: Text(
              'Role',
              style: TextStyle(fontStyle: FontStyle.italic),
            ),
          ),
        ],
        rows: const <DataRow>[
          DataRow(
            cells: <DataCell>[
              DataCell(Text('Sarah')),
              DataCell(Text('19')),
              DataCell(Text('Student')),
            ],
          ),
          DataRow(
            cells: <DataCell>[
              DataCell(Text('Janine')),
              DataCell(Text('43')),
              DataCell(Text('Professor')),
            ],
          ),
          DataRow(
            cells: <DataCell>[
              DataCell(Text('William')),
              DataCell(Text('27')),
              DataCell(Text('Associate Professor')),
            ],
          ),
        ],
      ),
    );
  }
}

Version

  • Flutter version: 3.3.9
  • auto_size_text: ^3.0.0
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