-
-
Notifications
You must be signed in to change notification settings - Fork 261
Description
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