David PHAM-VAN

Null-safety fixes

... ... @@ -2,18 +2,19 @@ name: Dart CI
on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
with:
channel: dev
- name: Install utils
run: sudo apt install poppler-utils imagemagick
- name: Run analysis
... ...
... ... @@ -121,7 +121,7 @@ test-demo: $(FONTS) demo/pubspec.lock .coverage
test-readme: $(FONTS) test/pubspec.lock
cd test; $(DART_BIN) extract_readme.dart
cd test; dartanalyzer readme-*.dart
cd test; $(DART_BIN) analyze
test: test-pdf test-printing test-demo node_modules
cat pdf/lcov.info printing/lcov.info demo/lcov.info | node_modules/.bin/lcov-summary
... ...
... ... @@ -38,7 +38,8 @@ Future<Uint8List> generateDocument(PdfPageFormat format) async {
border: pw.Border(
bottom: pw.BorderSide(width: 0.5, color: PdfColors.grey))),
child: pw.Text('Portable Document Format',
style: pw.Theme.of(context).defaultTextStyle
style: pw.Theme.of(context)
.defaultTextStyle
.copyWith(color: PdfColors.grey)));
},
footer: (pw.Context context) {
... ... @@ -47,7 +48,8 @@ Future<Uint8List> generateDocument(PdfPageFormat format) async {
margin: const pw.EdgeInsets.only(top: 1.0 * PdfPageFormat.cm),
child: pw.Text(
'Page ${context.pageNumber} of ${context.pagesCount}',
style: pw.Theme.of(context).defaultTextStyle
style: pw.Theme.of(context)
.defaultTextStyle
.copyWith(color: PdfColors.grey)));
},
build: (pw.Context context) => <pw.Widget>[
... ...
... ... @@ -4,8 +4,8 @@ description: Pdf Printing Demo
version: 1.0.0+1
environment:
sdk: '>=2.12.0-224.0.dev <3.0.0'
flutter: ">=1.26.0-17.1.pre <2.0.0"
sdk: ">=2.12.0-0 <3.0.0"
flutter: ">=1.16.0"
dependencies:
flutter:
... ...
... ... @@ -7,7 +7,7 @@ Future<void> main() async {
pdf.addPage(
pw.Page(
build: (pw.Context? context) => pw.Center(
build: (pw.Context context) => pw.Center(
child: pw.Text('Hello World!'),
),
),
... ...
... ... @@ -94,7 +94,7 @@ class BarDataSet extends Dataset {
return;
}
final grid = Chart.of(context)!.grid;
final grid = Chart.of(context).grid;
if (drawSurface) {
for (final value in data) {
... ...
... ... @@ -60,7 +60,7 @@ class Chart extends Widget implements Inherited {
late Widget _child;
// ignore: avoid_as
static Chart? of(Context context) => context.dependsOn<Chart>();
static Chart of(Context context) => context.dependsOn<Chart>()!;
PdfPoint _computeSize(BoxConstraints constraints) {
if (constraints.isTight) {
... ...
... ... @@ -244,9 +244,6 @@ class FixedAxis<T extends num> extends GridAxis {
@override
void layout(Context context, BoxConstraints constraints,
{bool parentUsesSize = false}) {
assert(Chart.of(context) != null,
'$runtimeType cannot be used without a Chart widget');
final size = constraints.biggest;
var maxWidth = 0.0;
... ... @@ -379,7 +376,7 @@ class FixedAxis<T extends num> extends GridAxis {
}
// ignore: avoid_as
final grid = Chart.of(context)!.grid as CartesianGrid;
final grid = Chart.of(context).grid as CartesianGrid;
switch (direction) {
case Axis.horizontal:
... ...
... ... @@ -39,11 +39,9 @@ class CartesianGrid extends ChartGrid {
@override
void layout(Context context, BoxConstraints constraints,
{bool parentUsesSize = false}) {
assert(Chart.of(context) != null,
'$runtimeType cannot be used without a Chart widget');
super.layout(context, constraints, parentUsesSize: parentUsesSize);
final datasets = Chart.of(context)!.datasets;
final datasets = Chart.of(context).datasets;
final size = constraints.biggest;
// In simple conditions, this loop will run only 2 times.
... ... @@ -104,7 +102,7 @@ class CartesianGrid extends ChartGrid {
void paint(Context context) {
super.paint(context);
final datasets = Chart.of(context)!.datasets;
final datasets = Chart.of(context).datasets;
clip(context, box!.size);
for (var dataSet in datasets) {
... ...
... ... @@ -69,10 +69,7 @@ class ChartLegend extends StatelessWidget {
@override
Widget build(Context context) {
assert(Chart.of(context) != null,
'$runtimeType cannot be used without a Chart widget');
final datasets = Chart.of(context)!.datasets;
final datasets = Chart.of(context).datasets;
final Widget wrap = Wrap(
direction: direction,
... ...
... ... @@ -136,7 +136,7 @@ class LineDataSet extends Dataset {
return;
}
final grid = Chart.of(context)!.grid;
final grid = Chart.of(context).grid;
if (drawSurface) {
_drawSurface(context, grid);
... ... @@ -167,7 +167,7 @@ class LineDataSet extends Dataset {
return;
}
final grid = Chart.of(context)!.grid;
final grid = Chart.of(context).grid;
if (drawLine) {
_drawLine(context, grid, true);
... ...
... ... @@ -20,6 +20,7 @@ import 'package:meta/meta.dart';
import 'package:pdf/pdf.dart';
import 'package:vector_math/vector_math_64.dart';
import 'basic.dart';
import 'document.dart';
import 'flex.dart';
import 'geometry.dart';
... ... @@ -91,7 +92,7 @@ class MultiPage extends Page {
MultiPage({
PageTheme? pageTheme,
PdfPageFormat? pageFormat,
BuildListCallback? build,
required BuildListCallback build,
this.mainAxisAlignment = MainAxisAlignment.start,
this.crossAxisAlignment = CrossAxisAlignment.start,
this.header,
... ... @@ -106,13 +107,14 @@ class MultiPage extends Page {
super(
pageTheme: pageTheme,
pageFormat: pageFormat,
build: (_) => SizedBox(),
margin: margin,
theme: theme,
orientation: orientation,
textDirection: textDirection,
);
final BuildListCallback? _buildList;
final BuildListCallback _buildList;
final CrossAxisAlignment crossAxisAlignment;
... ... @@ -149,10 +151,6 @@ class MultiPage extends Page {
@override
void generate(Document document, {bool insert = true, int? index}) {
if (_buildList == null) {
return;
}
assert(pageFormat.width > 0 && pageFormat.width < double.infinity);
assert(pageFormat.height > 0 && pageFormat.height < double.infinity);
... ... @@ -184,7 +182,7 @@ class MultiPage extends Page {
if (pageTheme.textDirection != null)
InheritedDirectionality(pageTheme.textDirection),
]);
final children = _buildList!(baseContext);
final children = _buildList(baseContext);
WidgetContext? widgetContext;
while (_index < children.length) {
... ...
... ... @@ -37,7 +37,7 @@ class Page {
Page({
PageTheme? pageTheme,
PdfPageFormat? pageFormat,
BuildCallback? build,
required BuildCallback build,
ThemeData? theme,
PageOrientation? orientation,
EdgeInsets? margin,
... ... @@ -69,7 +69,7 @@ class Page {
PageOrientation get orientation => pageTheme.orientation;
final BuildCallback? _build;
final BuildCallback _build;
ThemeData? get theme => pageTheme.theme;
... ... @@ -136,8 +136,7 @@ class Page {
Widget? content;
Widget? foreground;
if (_build != null) {
content = _build!(context);
content = _build(context);
final size = layout(content, context, constraints);
... ... @@ -152,7 +151,6 @@ class Page {
maxWidth: _pdfPage!.pageFormat.width - _margin.horizontal,
maxHeight: _pdfPage!.pageFormat.height - _margin.vertical);
}
}
if (pageTheme.buildBackground != null) {
background = pageTheme.buildBackground!(context);
... ... @@ -175,9 +173,7 @@ class Page {
paint(background, context);
}
if (content != null) {
paint(content, context);
}
if (foreground != null) {
paint(foreground, context);
... ...
... ... @@ -7,7 +7,7 @@ issue_tracker: https://github.com/DavBfr/dart_pdf/issues
version: 3.0.0-nullsafety.0
environment:
sdk: '>=2.12.0-224.0.dev <3.0.0'
sdk: ">=2.12.0-0 <3.0.0"
dependencies:
archive: ^3.0.0-nullsafety
... ...
... ... @@ -464,7 +464,7 @@ void main() {
test('Text Widgets Arabic', () {
pdf.addPage(Page(
build: (Context? context) => RichText(
build: (Context context) => RichText(
textDirection: TextDirection.rtl,
text: TextSpan(
text: 'قهوة\n',
... ...
... ... @@ -28,8 +28,8 @@ class Color extends StatelessWidget {
final String? varient;
@override
Widget build(Context? context) {
final style = Theme.of(context!).defaultTextStyle.copyWith(
Widget build(Context context) {
final style = Theme.of(context).defaultTextStyle.copyWith(
color: color.luminance < 0.2 ? PdfColors.white : PdfColors.black,
fontSize: 14);
final hexStyle = style.copyWith(font: Font.courier(), fontSize: 10);
... ... @@ -73,7 +73,7 @@ class ColorWheel extends Widget {
final ColorSpace colorSpace;
@override
void layout(Context? context, BoxConstraints? constraints,
void layout(Context context, BoxConstraints? constraints,
{bool parentUsesSize = false}) {
box = PdfRect.fromPoints(PdfPoint.zero, constraints!.biggest);
}
... ... @@ -672,11 +672,11 @@ void main() {
wheels.forEach((ColorSpace colorSpace, String name) {
pdf.addPage(Page(
build: (Context? context) => Column(
build: (Context context) => Column(
children: <Widget>[
Header(text: name, outlineStyle: PdfOutlineStyle.italic),
SizedBox(
height: context!.page.pageFormat.availableWidth,
height: context.page.pageFormat.availableWidth,
child: ColorWheel(
colorSpace: colorSpace,
),
... ...
... ... @@ -38,7 +38,7 @@ void compute(Message message) {
message.image,
);
pdf.addPage(Page(build: (Context? context) => Center(child: Image(image))));
pdf.addPage(Page(build: (Context context) => Center(child: Image(image))));
message.sendPort.send(pdf.save());
}
... ...
... ... @@ -38,14 +38,14 @@ void main() {
test('Pdf Jpeg Download', () async {
pdf.addPage(Page(
build: (Context? context) => Center(child: Image(image)),
build: (Context context) => Center(child: Image(image)),
));
});
test('Pdf Jpeg Orientations', () {
pdf.addPage(
Page(
build: (Context? context) => GridView(
build: (Context context) => GridView(
crossAxisCount: 4,
crossAxisSpacing: 10,
children: List<Widget>.generate(
... ... @@ -95,7 +95,7 @@ void main() {
pdf.addPage(
Page(
build: (Context? context) => Center(
build: (Context context) => Center(
child: Wrap(
spacing: 20,
runSpacing: 20,
... ...
... ... @@ -113,7 +113,7 @@ void main() {
.codeUnits) {
pdf.addPage(Page(
pageFormat: const PdfPageFormat(500, 500, marginAll: 20),
build: (Context? context) {
build: (Context context) {
return ConstrainedBox(
constraints: const BoxConstraints.expand(),
child: FittedBox(
... ...
... ... @@ -22,7 +22,7 @@ import 'package:pdf/widgets.dart';
late Document pdf;
Widget content(Context? context) {
Widget content(Context context) {
return ListView(children: contentMultiPage(context));
}
... ... @@ -38,7 +38,7 @@ Widget header(Context context) {
);
}
List<Widget> contentMultiPage(Context? context) {
List<Widget> contentMultiPage(Context context) {
return List<Widget>.generate(
150,
(int n) => Container(
... ...
... ... @@ -31,7 +31,7 @@ void main() {
test('Pdf Roll Paper', () async {
pdf.addPage(Page(
pageFormat: PdfPageFormat.roll80,
build: (Context? context) => Padding(
build: (Context context) => Padding(
padding: const EdgeInsets.all(30),
child: Center(
child: Text('Hello World!'),
... ... @@ -43,7 +43,7 @@ void main() {
test('Pdf Automatic Paper', () async {
pdf.addPage(Page(
pageFormat: PdfPageFormat.undefined,
build: (Context? context) => Text('Hello World!')));
build: (Context context) => Text('Hello World!')));
});
tearDownAll(() async {
... ...
... ... @@ -30,7 +30,7 @@ void main() {
test('Basic Widgets Align 1', () {
pdf.addPage(Page(
build: (Context? context) => Align(
build: (Context context) => Align(
alignment: Alignment.bottomRight,
child: SizedBox(width: 100, height: 100, child: PdfLogo()),
)));
... ... @@ -38,7 +38,7 @@ void main() {
test('Basic Widgets Align 2', () {
pdf.addPage(Page(
build: (Context? context) => Align(
build: (Context context) => Align(
alignment: const Alignment(0.8, 0.2),
child: SizedBox(width: 100, height: 100, child: PdfLogo()),
)));
... ... @@ -46,7 +46,7 @@ void main() {
test('Basic Widgets AspectRatio', () {
pdf.addPage(Page(
build: (Context? context) => AspectRatio(
build: (Context context) => AspectRatio(
aspectRatio: 1.618,
child: Placeholder(),
)));
... ... @@ -54,14 +54,14 @@ void main() {
test('Basic Widgets Center', () {
pdf.addPage(Page(
build: (Context? context) => Center(
build: (Context context) => Center(
child: SizedBox(width: 100, height: 100, child: PdfLogo()),
)));
});
test('Basic Widgets ConstrainedBox', () {
pdf.addPage(Page(
build: (Context? context) => ConstrainedBox(
build: (Context context) => ConstrainedBox(
constraints: const BoxConstraints.tightFor(height: 300),
child: Placeholder()),
));
... ... @@ -69,7 +69,7 @@ void main() {
test('Basic Widgets CustomPaint', () {
pdf.addPage(Page(
build: (Context? context) => CustomPaint(
build: (Context context) => CustomPaint(
size: const PdfPoint(200, 200),
painter: (PdfGraphics canvas, PdfPoint size) {
canvas
... ... @@ -79,7 +79,7 @@ void main() {
},
)));
pdf.addPage(Page(
build: (Context? context) => CustomPaint(
build: (Context context) => CustomPaint(
size: const PdfPoint(200, 200),
painter: (PdfGraphics canvas, PdfPoint size) {
canvas
... ... @@ -93,7 +93,7 @@ void main() {
test('Basic Widgets FittedBox', () {
pdf.addPage(Page(
build: (Context? context) => Column(
build: (Context context) => Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
... ... @@ -151,7 +151,7 @@ void main() {
test('Basic Widgets LimitedBox', () {
pdf.addPage(Page(
build: (Context? context) => ListView(
build: (Context context) => ListView(
children: <Widget>[
LimitedBox(
maxHeight: 40,
... ... @@ -163,7 +163,7 @@ void main() {
test('Basic Widgets Padding', () {
pdf.addPage(Page(
build: (Context? context) => Center(
build: (Context context) => Center(
child: Padding(
padding: const EdgeInsets.all(20),
child: PdfLogo(),
... ... @@ -173,7 +173,7 @@ void main() {
test('Basic Widgets SizedBox', () {
pdf.addPage(Page(
build: (Context? context) => SizedBox(
build: (Context context) => SizedBox(
width: 200,
height: 100,
child: Placeholder(),
... ... @@ -182,7 +182,7 @@ void main() {
test('Basic Widgets Transform', () {
pdf.addPage(Page(
build: (Context? context) => Transform.scale(
build: (Context context) => Transform.scale(
scale: 0.5,
child: Transform.rotate(
angle: 0.1,
... ... @@ -193,7 +193,7 @@ void main() {
test('Basic Widgets Transform rotateBox', () {
pdf.addPage(Page(
build: (Context? context) => Center(
build: (Context context) => Center(
child: Transform.rotateBox(
angle: 3.1416 / 2,
child: Text('Hello'),
... ...
... ... @@ -32,7 +32,7 @@ void main() {
test('Default LineChart', () {
pdf.addPage(Page(
pageFormat: PdfPageFormat.standard.landscape,
build: (Context? context) => Chart(
build: (Context context) => Chart(
grid: CartesianGrid(
xAxis: FixedAxis<int>(<int>[0, 1, 2, 3, 4, 5, 6]),
yAxis: FixedAxis<int>(<int>[0, 3, 6, 9], divisions: true),
... ... @@ -53,7 +53,7 @@ void main() {
test('Default LineChart without lines connecting points', () {
pdf.addPage(Page(
pageFormat: PdfPageFormat.standard.landscape,
build: (Context? context) => Chart(
build: (Context context) => Chart(
grid: CartesianGrid(
xAxis: FixedAxis<int>(<int>[0, 1, 2, 3, 4, 5, 6]),
yAxis: FixedAxis<int>(<int>[0, 3, 6, 9], divisions: true),
... ... @@ -74,7 +74,7 @@ void main() {
test('Default ScatterChart without dots', () {
pdf.addPage(Page(
build: (Context? context) => Chart(
build: (Context context) => Chart(
grid: CartesianGrid(
xAxis: FixedAxis<int>(<int>[0, 1, 2, 3, 4, 5, 6]),
yAxis: FixedAxis<int>(<int>[0, 3, 6, 9], divisions: true),
... ... @@ -96,7 +96,7 @@ void main() {
test('ScatterChart with custom points and lines', () {
pdf.addPage(Page(
pageFormat: PdfPageFormat.standard.landscape,
build: (Context? context) => Chart(
build: (Context context) => Chart(
grid: CartesianGrid(
xAxis: FixedAxis<int>(<int>[0, 1, 2, 3, 4, 5, 6]),
yAxis: FixedAxis<int>(<int>[0, 3, 6, 9], divisions: true),
... ... @@ -122,7 +122,7 @@ void main() {
test('ScatterChart with custom size', () {
pdf.addPage(Page(
pageFormat: PdfPageFormat.standard.landscape,
build: (Context? context) => SizedBox(
build: (Context context) => SizedBox(
width: 200,
height: 100,
child: Chart(
... ... @@ -147,7 +147,7 @@ void main() {
test('LineChart with curved lines', () {
pdf.addPage(Page(
pageFormat: PdfPageFormat.standard.landscape,
build: (Context? context) => Chart(
build: (Context context) => Chart(
grid: CartesianGrid(
xAxis: FixedAxis<int>(<int>[0, 1, 2, 3, 4, 5, 6]),
yAxis: FixedAxis<int>(<int>[0, 3, 6, 9], divisions: true),
... ... @@ -172,7 +172,7 @@ void main() {
test('Default BarChart', () {
pdf.addPage(Page(
pageFormat: PdfPageFormat.standard.landscape,
build: (Context? context) => Chart(
build: (Context context) => Chart(
grid: CartesianGrid(
xAxis: FixedAxis<int>(<int>[0, 1, 2, 3, 4, 5, 6]),
yAxis: FixedAxis<int>(<int>[0, 3, 6, 9], divisions: true),
... ... @@ -193,7 +193,7 @@ void main() {
test('Vertical BarChart', () {
pdf.addPage(Page(
pageFormat: PdfPageFormat.standard.landscape,
build: (Context? context) => Chart(
build: (Context context) => Chart(
grid: CartesianGrid(
xAxis: FixedAxis<int>(<int>[0, 1, 2, 3, 4, 5, 6]),
yAxis: FixedAxis<int>(<int>[0, 3, 6, 9], divisions: true),
... ...
... ... @@ -30,7 +30,7 @@ void main() {
test('Clip Widgets ClipRect', () {
pdf.addPage(Page(
build: (Context? context) => ClipRect(
build: (Context context) => ClipRect(
child: Transform.rotate(
angle: 0.1,
child: Container(
... ... @@ -45,7 +45,7 @@ void main() {
test('Clip Widgets ClipRRect', () {
pdf.addPage(Page(
build: (Context? context) => ClipRRect(
build: (Context context) => ClipRRect(
horizontalRadius: 30,
verticalRadius: 30,
child: Container(
... ... @@ -59,7 +59,7 @@ void main() {
test('Clip Widgets ClipOval', () {
pdf.addPage(Page(
build: (Context? context) => ClipOval(
build: (Context context) => ClipOval(
child: Container(
decoration: const BoxDecoration(
color: PdfColors.blue,
... ...
... ... @@ -32,7 +32,7 @@ void main() {
test('Container Widgets Flat', () {
pdf.addPage(Page(
build: (Context? context) => Container(
build: (Context context) => Container(
alignment: Alignment.center,
margin: const EdgeInsets.all(30),
padding: const EdgeInsets.all(20),
... ... @@ -92,7 +92,7 @@ void main() {
test('Container Widgets BoxShape Border', () {
pdf.addPage(Page(
build: (Context? context) => Center(
build: (Context context) => Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
... ... @@ -121,7 +121,7 @@ void main() {
test('Container Widgets LinearGradient', () {
pdf.addPage(Page(
build: (Context? context) => Container(
build: (Context context) => Container(
alignment: Alignment.center,
margin: const EdgeInsets.all(30),
padding: const EdgeInsets.all(20),
... ... @@ -150,7 +150,7 @@ void main() {
test('Container Widgets RadialGradient', () {
pdf.addPage(Page(
build: (Context? context) => Container(
build: (Context context) => Container(
alignment: Alignment.center,
margin: const EdgeInsets.all(30),
padding: const EdgeInsets.all(20),
... ... @@ -180,7 +180,7 @@ void main() {
test('Container Widgets BoxShadow', () {
pdf.addPage(Page(
build: (Context? context) => Container(
build: (Context context) => Container(
margin: const EdgeInsets.all(30),
padding: const EdgeInsets.all(20),
decoration: const BoxDecoration(
... ...
... ... @@ -31,7 +31,7 @@ void main() {
test('Flex Widgets ListView', () {
pdf.addPage(
Page(
build: (Context? context) => ListView(
build: (Context context) => ListView(
spacing: 20,
padding: const EdgeInsets.all(10),
children: <Widget>[
... ... @@ -47,7 +47,7 @@ void main() {
test('Flex Widgets ListView.builder', () {
pdf.addPage(
Page(
build: (Context? context) => ListView.builder(
build: (Context context) => ListView.builder(
itemBuilder: (Context context, int index) => Text('Line $index'),
itemCount: 30,
spacing: 2,
... ... @@ -60,7 +60,7 @@ void main() {
test('Flex Widgets ListView.separated', () {
pdf.addPage(
Page(
build: (Context? context) => ListView.separated(
build: (Context context) => ListView.separated(
separatorBuilder: (Context context, int index) => Container(
color: PdfColors.grey,
height: 0.5,
... ... @@ -76,7 +76,7 @@ void main() {
test('Flex Widgets Spacer', () {
pdf.addPage(
Page(
build: (Context? context) => Column(
build: (Context context) => Column(
children: <Widget>[
Text('Begin'),
Spacer(), // Defaults to a flex of one.
... ...
... ... @@ -74,7 +74,7 @@ void main() {
() {
pdf.addPage(
Page(
build: (Context? context) => Wrap(
build: (Context context) => Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: <Widget>[
Label(label: 'Given Name:', width: 100),
... ...
... ... @@ -51,7 +51,7 @@ void main() {
test('Pdf Widgets GridView Horizontal', () {
pdf.addPage(Page(
build: (Context? context) => GridView(
build: (Context context) => GridView(
crossAxisCount: 5,
direction: Axis.horizontal,
childAspectRatio: 1,
... ...
... ... @@ -47,7 +47,7 @@ void main() {
final pdf = Document();
pdf.addPage(Page(build: (Context? context) => Column(children: lines)));
pdf.addPage(Page(build: (Context context) => Column(children: lines)));
final file = File('widgets-monopage.pdf');
await file.writeAsBytes(await pdf.save());
... ...
... ... @@ -30,7 +30,7 @@ void main() {
test('Opacity Widgets', () {
pdf.addPage(
Page(
build: (Context? context) => Stack(
build: (Context context) => Stack(
alignment: Alignment.center,
children: <Widget>[
Text('Background', textScaleFactor: 5),
... ...
... ... @@ -71,13 +71,13 @@ void main() {
test('Table Widget empty', () {
pdf.addPage(Page(
build: (Context? context) => Table(),
build: (Context context) => Table(),
));
});
test('Table Widget filled', () {
pdf.addPage(Page(
build: (Context? context) => Table(
build: (Context context) => Table(
children: buildTable(context: context, count: 20),
border: TableBorder.all(),
tableWidth: TableWidth.max,
... ... @@ -135,7 +135,7 @@ void main() {
test('Table Widget Widths', () {
pdf.addPage(Page(
build: (Context? context) => Table(
build: (Context context) => Table(
children: buildTable(context: context, count: 20),
border: TableBorder.all(),
columnWidths: <int, TableColumnWidth>{
... ... @@ -189,7 +189,7 @@ void main() {
test('Table fromTextArray', () {
pdf.addPage(Page(
build: (Context? context) => Table.fromTextArray(
build: (Context context) => Table.fromTextArray(
context: context,
tableWidth: TableWidth.min,
data: <List<dynamic>>[
... ... @@ -203,7 +203,7 @@ void main() {
test('Table fromTextArray with formatting', () {
pdf.addPage(Page(
build: (Context? context) => Table.fromTextArray(
build: (Context context) => Table.fromTextArray(
border: null,
cellAlignment: Alignment.center,
headerDecoration: const BoxDecoration(
... ... @@ -239,7 +239,7 @@ void main() {
theme: ThemeData.withFont(
base: loadFont('hacen-tunisia.ttf'),
),
build: (Context? context) => Directionality(
build: (Context context) => Directionality(
textDirection: TextDirection.rtl,
child: Table.fromTextArray(
headers: <dynamic>['ثلاثة', 'اثنان', 'واحد'],
... ... @@ -256,7 +256,7 @@ void main() {
test('Table fromTextArray with alignment', () {
pdf.addPage(
Page(
build: (Context? context) => Table.fromTextArray(
build: (Context context) => Table.fromTextArray(
cellAlignment: Alignment.center,
data: <List<String>>[
<String>['line 1', 'Text\n\n\ntext'],
... ...
... ... @@ -51,7 +51,7 @@ void main() {
pdf.addPage(Page(
pageFormat: const PdfPageFormat(400, 400),
margin: const EdgeInsets.all(10),
build: (Context? context) => Column(children: <Widget>[
build: (Context context) => Column(children: <Widget>[
Container(
padding: const EdgeInsets.all(5),
margin: const EdgeInsets.only(bottom: 10),
... ... @@ -114,7 +114,7 @@ void main() {
"That's all Folks!",
tightBounds: true,
textAlign: TextAlign.center,
style: Theme.of(context!).defaultTextStyle.copyWith(
style: Theme.of(context).defaultTextStyle.copyWith(
font: Font.timesBoldItalic(),
),
textScaleFactor: 3,
... ... @@ -128,7 +128,7 @@ void main() {
Page(
pageFormat: const PdfPageFormat(400, 400),
margin: const EdgeInsets.all(10),
build: (Context? context) => Center(
build: (Context context) => Center(
child: GridView(
crossAxisCount: 3,
direction: Axis.vertical,
... ... @@ -205,7 +205,7 @@ void main() {
Page(
pageFormat: const PdfPageFormat(400, 200),
margin: const EdgeInsets.all(10),
build: (Context? context) => Stack(
build: (Context context) => Stack(
overflow: Overflow.visible,
// fit: StackFit.expand,
// alignment: Alignment.bottomRight,
... ... @@ -227,7 +227,7 @@ void main() {
child: RichText(
text: TextSpan(
text: 'Hello ',
style: Theme.of(context!).defaultTextStyle,
style: Theme.of(context).defaultTextStyle,
children: <TextSpan>[
TextSpan(
text: 'bold',
... ...
... ... @@ -53,12 +53,12 @@ void main() {
test('Text Widgets Quotes', () {
pdf.addPage(Page(
build: (Context? context) => Text('Text containing \' or " works!')));
build: (Context context) => Text('Text containing \' or " works!')));
});
test('Text Widgets Unicode Quotes', () {
pdf.addPage(Page(
build: (Context? context) => Text('Text containing ’ and ” works!',
build: (Context context) => Text('Text containing ’ and ” works!',
style: TextStyle(font: ttf))));
});
... ... @@ -249,7 +249,7 @@ void main() {
test('Text Widgets RichText Multiple lang', () {
pdf.addPage(Page(
build: (Context? context) => RichText(
build: (Context context) => RichText(
text: TextSpan(
text: 'Hello ',
style: TextStyle(
... ... @@ -276,7 +276,7 @@ void main() {
pdf.addPage(
Page(
build: (Context? context) => RichText(
build: (Context context) => RichText(
maxLines: 3,
text: TextSpan(
text: para,
... ...
... ... @@ -55,7 +55,7 @@ void main() {
color: PdfColors.blue);
pdf.addPage(Page(
build: (Context? context) => ListView(
build: (Context context) => ListView(
children: <Widget>[
Text(
style.font!.fontName!,
... ... @@ -71,7 +71,7 @@ void main() {
pdf.addPage(Page(
theme: theme,
build: (Context? context) => Center(
build: (Context context) => Center(
child: Text('Hello'),
),
));
... ... @@ -85,7 +85,7 @@ void main() {
pdf.addPage(Page(
theme: theme,
build: (Context? context) => Center(
build: (Context context) => Center(
child: Table.fromTextArray(context: context, data: <List<String>>[
<String>['Header', '123'],
<String>['Cell', '456']
... ... @@ -96,7 +96,7 @@ void main() {
test('Theme Page 3', () {
pdf.addPage(Page(
build: (Context? context) => Center(
build: (Context context) => Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
... ... @@ -121,7 +121,7 @@ void main() {
theme: ThemeData(
defaultTextStyle: TextStyle(font: Font.courier(), fontSize: 10.0),
),
build: (Context? context) {
build: (Context context) {
return Center(child: Text('Text'));
}));
});
... ...
... ... @@ -48,7 +48,7 @@ void main() {
pdf.addPage(
Page(
pageTheme: pageTheme,
build: (Context? context) => Center(
build: (Context context) => Center(
child: Text(
'Hello World',
),
... ...
... ... @@ -53,7 +53,7 @@ void main() {
Page(
pageFormat: const PdfPageFormat(400, 800),
margin: const EdgeInsets.all(10),
build: (Context? context) => Column(
build: (Context context) => Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: wraps,
),
... ... @@ -85,7 +85,7 @@ void main() {
Page(
pageFormat: const PdfPageFormat(800, 400),
margin: const EdgeInsets.all(10),
build: (Context? context) => Row(
build: (Context context) => Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: wraps,
),
... ... @@ -119,7 +119,7 @@ void main() {
Page(
pageFormat: const PdfPageFormat(400, 800),
margin: const EdgeInsets.all(10),
build: (Context? context) => Column(
build: (Context context) => Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: wraps,
),
... ... @@ -153,7 +153,7 @@ void main() {
Page(
pageFormat: const PdfPageFormat(800, 400),
margin: const EdgeInsets.all(10),
build: (Context? context) => Row(
build: (Context context) => Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: wraps,
),
... ... @@ -189,7 +189,7 @@ void main() {
Page(
pageFormat: const PdfPageFormat(400, 800),
margin: const EdgeInsets.all(10),
build: (Context? context) => Column(
build: (Context context) => Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: wraps,
),
... ... @@ -225,7 +225,7 @@ void main() {
Page(
pageFormat: const PdfPageFormat(800, 400),
margin: const EdgeInsets.all(10),
build: (Context? context) => Row(
build: (Context context) => Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: wraps,
),
... ... @@ -239,7 +239,7 @@ void main() {
Page(
pageFormat: const PdfPageFormat(200, 200),
margin: const EdgeInsets.all(10),
build: (Context? context) => Wrap(
build: (Context context) => Wrap(
spacing: 10,
runSpacing: 10,
children: List<Widget>.generate(
... ... @@ -285,7 +285,7 @@ void main() {
});
test('Wrap Widget Empty', () {
pdf.addPage(Page(build: (Context? context) => Wrap()));
pdf.addPage(Page(build: (Context context) => Wrap()));
});
test('Wrap Widget Columns', () {
... ...
... ... @@ -4,7 +4,7 @@ description: Pdf Printing Example
version: 1.0.0+1
environment:
sdk: '>=2.12.0-224.0.dev <3.0.0'
sdk: ">=2.12.0-0 <3.0.0"
dependencies:
flutter:
... ...
... ... @@ -7,8 +7,8 @@ issue_tracker: https://github.com/DavBfr/dart_pdf/issues
version: 5.0.0-nullsafety.0
environment:
sdk: '>=2.12.0-224.0.dev <3.0.0'
flutter: ">=1.12.13+hotfix.5 <2.0.0"
sdk: ">=2.12.0-0 <3.0.0"
flutter: ">=1.16.0"
dependencies:
flutter:
... ...
... ... @@ -7,8 +7,8 @@ issue_tracker: https://github.com/DavBfr/dart_pdf/issues
version: 1.0.0
environment:
sdk: '>=2.12.0-224.0.dev <3.0.0'
flutter: ">=1.12.13+hotfix.5 <2.0.0"
sdk: ">=2.12.0-0 <3.0.0"
flutter: ">=1.16.0"
dependencies:
flutter:
... ...