Skip to content

Commit c212293

Browse files
Merge pull request #807 from sfHariHaraSudhan/master
FLUT-6666 - [Others]: Updated the widgets sources for 2022 Volume 2 release
2 parents cf3e68b + 093150e commit c212293

File tree

943 files changed

+258203
-2204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

943 files changed

+258203
-2204
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import 'package:flutter/material.dart';
2+
import '../../../barcodes.dart';
3+
4+
/// Returns the codabar generator
5+
SfBarcodeGenerator getCodabarGenerator(String sample) {
6+
late SfBarcodeGenerator barcodeGenerator;
7+
switch (sample) {
8+
case 'with-value':
9+
{
10+
barcodeGenerator = SfBarcodeGenerator(
11+
value: '123456',
12+
symbology: Codabar(),
13+
);
14+
}
15+
break;
16+
17+
case 'with-value1':
18+
{
19+
barcodeGenerator = SfBarcodeGenerator(
20+
value: '714411106011348790',
21+
symbology: Codabar(),
22+
);
23+
}
24+
break;
25+
26+
case 'with-specialcharcter':
27+
{
28+
barcodeGenerator = SfBarcodeGenerator(
29+
value: '6738989812:/+',
30+
symbology: Codabar(),
31+
);
32+
}
33+
break;
34+
35+
case 'enable-showValue':
36+
{
37+
barcodeGenerator = SfBarcodeGenerator(
38+
value: '123456',
39+
showValue: true,
40+
symbology: Codabar(),
41+
);
42+
}
43+
break;
44+
45+
case 'show value for longest digit':
46+
{
47+
barcodeGenerator = SfBarcodeGenerator(
48+
value: '714411106011348790123654',
49+
showValue: true,
50+
symbology: Codabar(),
51+
);
52+
}
53+
break;
54+
55+
case 'change bar color':
56+
{
57+
barcodeGenerator = SfBarcodeGenerator(
58+
value: '7144111060113487',
59+
barColor: Colors.green,
60+
symbology: Codabar(),
61+
);
62+
}
63+
break;
64+
65+
case 'chnage background color':
66+
{
67+
barcodeGenerator = SfBarcodeGenerator(
68+
value: '7144111060113487',
69+
backgroundColor: Colors.yellow,
70+
symbology: Codabar(),
71+
);
72+
}
73+
break;
74+
75+
case 'set text spacing with show value':
76+
{
77+
barcodeGenerator = SfBarcodeGenerator(
78+
value: '7144111060113487',
79+
textSpacing: 10,
80+
showValue: true,
81+
symbology: Codabar(),
82+
);
83+
}
84+
break;
85+
86+
case 'text align as start with showValue':
87+
{
88+
barcodeGenerator = SfBarcodeGenerator(
89+
value: '7144111060113487',
90+
textAlign: TextAlign.start,
91+
showValue: true,
92+
symbology: Codabar(),
93+
);
94+
}
95+
break;
96+
97+
case 'set text style with all the properties':
98+
{
99+
barcodeGenerator = SfBarcodeGenerator(
100+
value: '7144111060113487',
101+
textSpacing: 10,
102+
showValue: true,
103+
backgroundColor: Colors.yellow,
104+
barColor: Colors.green,
105+
textAlign: TextAlign.right,
106+
textStyle: const TextStyle(
107+
fontSize: 20,
108+
fontStyle: FontStyle.italic,
109+
fontWeight: FontWeight.bold),
110+
symbology: Codabar(),
111+
);
112+
}
113+
break;
114+
115+
case 'set module with all properties':
116+
{
117+
barcodeGenerator = SfBarcodeGenerator(
118+
value: '7144111060113487',
119+
showValue: true,
120+
textSpacing: 10,
121+
backgroundColor: Colors.yellow,
122+
barColor: Colors.green,
123+
textAlign: TextAlign.end,
124+
textStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
125+
symbology: Codabar(module: 2),
126+
);
127+
}
128+
break;
129+
}
130+
131+
return barcodeGenerator;
132+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import 'codabar_testcases.dart';
2+
3+
/// Codabar test scripts
4+
void codabarTestCases() {
5+
codabarSamples();
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
import 'package:flutter/material.dart';
2+
// ignore: depend_on_referenced_packages
3+
import 'package:flutter_test/flutter_test.dart';
4+
import '../../../barcodes.dart';
5+
import 'codabar_samples.dart';
6+
7+
/// Unit test scripts of Codabar
8+
void codabarSamples() {
9+
SfBarcodeGenerator? barcode;
10+
late Codabar symbology;
11+
group('Default-rendering', () {
12+
testWidgets('Default-rendering', (WidgetTester tester) async {
13+
final _CodabarTestCasesExamples container =
14+
_codabarTestCases('with-value') as _CodabarTestCasesExamples;
15+
await tester.pumpWidget(container);
16+
barcode = container._barcode;
17+
symbology = barcode!.symbology as Codabar;
18+
});
19+
20+
test('to test with-value', () {
21+
expect(barcode!.symbology, symbology);
22+
expect(barcode?.value, '123456');
23+
});
24+
});
25+
26+
group('with-value1', () {
27+
testWidgets('Default-rendering', (WidgetTester tester) async {
28+
final _CodabarTestCasesExamples container =
29+
_codabarTestCases('with-value1') as _CodabarTestCasesExamples;
30+
await tester.pumpWidget(container);
31+
barcode = container._barcode;
32+
symbology = barcode!.symbology as Codabar;
33+
});
34+
35+
test('to test with-value1', () {
36+
expect(barcode!.symbology, symbology);
37+
expect(barcode?.value, '714411106011348790');
38+
});
39+
});
40+
41+
group('with-specialcharcter', () {
42+
testWidgets('Default-rendering', (WidgetTester tester) async {
43+
final _CodabarTestCasesExamples container =
44+
_codabarTestCases('with-specialcharcter')
45+
as _CodabarTestCasesExamples;
46+
await tester.pumpWidget(container);
47+
barcode = container._barcode;
48+
symbology = barcode!.symbology as Codabar;
49+
});
50+
51+
test('to test with-specialcharcter', () {
52+
expect(barcode!.symbology, symbology);
53+
expect(barcode?.value, '6738989812:/+');
54+
});
55+
});
56+
57+
group('enable-showValue', () {
58+
testWidgets('enable-showValue', (WidgetTester tester) async {
59+
final _CodabarTestCasesExamples container =
60+
_codabarTestCases('enable-showValue') as _CodabarTestCasesExamples;
61+
await tester.pumpWidget(container);
62+
barcode = container._barcode;
63+
symbology = barcode!.symbology as Codabar;
64+
});
65+
66+
test('to test enable-showValue', () {
67+
expect(barcode!.symbology, symbology);
68+
expect(barcode?.value, '123456');
69+
});
70+
});
71+
72+
group('show value for longest digit', () {
73+
testWidgets('show value for longest digit', (WidgetTester tester) async {
74+
final _CodabarTestCasesExamples container =
75+
_codabarTestCases('show value for longest digit')
76+
as _CodabarTestCasesExamples;
77+
await tester.pumpWidget(container);
78+
barcode = container._barcode;
79+
symbology = barcode!.symbology as Codabar;
80+
});
81+
82+
test('to test show value for longest digit', () {
83+
expect(barcode!.symbology, symbology);
84+
expect(barcode?.value, '714411106011348790123654');
85+
});
86+
});
87+
88+
group('change bar color', () {
89+
testWidgets('change bar color', (WidgetTester tester) async {
90+
final _CodabarTestCasesExamples container =
91+
_codabarTestCases('change bar color') as _CodabarTestCasesExamples;
92+
await tester.pumpWidget(container);
93+
barcode = container._barcode;
94+
symbology = barcode!.symbology as Codabar;
95+
});
96+
97+
test('to test change bar color', () {
98+
expect(barcode!.symbology, symbology);
99+
expect(barcode?.value, '7144111060113487');
100+
expect(barcode?.barColor, Colors.green);
101+
});
102+
});
103+
104+
group('chnage background color', () {
105+
testWidgets('chnage background color', (WidgetTester tester) async {
106+
final _CodabarTestCasesExamples container =
107+
_codabarTestCases('chnage background color')
108+
as _CodabarTestCasesExamples;
109+
await tester.pumpWidget(container);
110+
barcode = container._barcode;
111+
symbology = barcode!.symbology as Codabar;
112+
});
113+
114+
test('to test chnage background color', () {
115+
expect(barcode!.symbology, symbology);
116+
expect(barcode?.value, '7144111060113487');
117+
expect(barcode?.backgroundColor, Colors.yellow);
118+
});
119+
});
120+
121+
group('set text spacing with show value', () {
122+
testWidgets('set text spacing with show value',
123+
(WidgetTester tester) async {
124+
final _CodabarTestCasesExamples container =
125+
_codabarTestCases('set text spacing with show value')
126+
as _CodabarTestCasesExamples;
127+
await tester.pumpWidget(container);
128+
barcode = container._barcode;
129+
symbology = barcode!.symbology as Codabar;
130+
});
131+
132+
test('to test set text spacing with show value', () {
133+
expect(barcode!.symbology, symbology);
134+
expect(barcode?.value, '7144111060113487');
135+
expect(barcode?.textSpacing, 10);
136+
expect(barcode?.showValue, true);
137+
});
138+
});
139+
140+
group('text align as start with showValue', () {
141+
testWidgets('text align as start with showValue',
142+
(WidgetTester tester) async {
143+
final _CodabarTestCasesExamples container =
144+
_codabarTestCases('text align as start with showValue')
145+
as _CodabarTestCasesExamples;
146+
await tester.pumpWidget(container);
147+
barcode = container._barcode;
148+
symbology = barcode!.symbology as Codabar;
149+
});
150+
151+
test('to test text align as start with showValue', () {
152+
expect(barcode!.symbology, symbology);
153+
expect(barcode?.value, '7144111060113487');
154+
expect(barcode?.showValue, true);
155+
expect(barcode?.textAlign, TextAlign.start);
156+
});
157+
});
158+
159+
group('set text style with all the properties', () {
160+
testWidgets('set text style with all the properties',
161+
(WidgetTester tester) async {
162+
final _CodabarTestCasesExamples container =
163+
_codabarTestCases('set text style with all the properties')
164+
as _CodabarTestCasesExamples;
165+
await tester.pumpWidget(container);
166+
barcode = container._barcode;
167+
symbology = barcode!.symbology as Codabar;
168+
});
169+
170+
test('set text style with all the properties', () {
171+
expect(barcode!.symbology, symbology);
172+
expect(barcode?.value, '7144111060113487');
173+
expect(barcode?.textSpacing, 10);
174+
expect(barcode?.backgroundColor, Colors.yellow);
175+
expect(barcode?.barColor, Colors.green);
176+
expect(barcode?.textAlign, TextAlign.right);
177+
expect(barcode?.showValue, true);
178+
expect(
179+
barcode?.textStyle,
180+
const TextStyle(
181+
fontSize: 20,
182+
fontStyle: FontStyle.italic,
183+
fontWeight: FontWeight.bold));
184+
});
185+
});
186+
187+
group('set module with all properties', () {
188+
testWidgets('set module with all properties', (WidgetTester tester) async {
189+
final _CodabarTestCasesExamples container =
190+
_codabarTestCases('set module with all properties')
191+
as _CodabarTestCasesExamples;
192+
await tester.pumpWidget(container);
193+
barcode = container._barcode;
194+
symbology = barcode!.symbology as Codabar;
195+
});
196+
197+
test('set module with all properties', () {
198+
expect(barcode!.symbology, symbology);
199+
expect(symbology.module, 2);
200+
expect(barcode?.showValue, true);
201+
expect(barcode?.textSpacing, 10);
202+
expect(barcode?.barColor, Colors.green);
203+
expect(barcode?.backgroundColor, Colors.yellow);
204+
expect(barcode?.textStyle,
205+
const TextStyle(fontSize: 16, fontWeight: FontWeight.bold));
206+
expect(barcode?.textAlign, TextAlign.end);
207+
expect(barcode?.value, '7144111060113487');
208+
});
209+
});
210+
}
211+
212+
StatelessWidget _codabarTestCases(String sampleName) {
213+
return _CodabarTestCasesExamples(sampleName);
214+
}
215+
216+
// ignore: must_be_immutable
217+
class _CodabarTestCasesExamples extends StatelessWidget {
218+
// ignore: prefer_const_constructors_in_immutables
219+
_CodabarTestCasesExamples(String sampleName) {
220+
_barcode = getCodabarGenerator(sampleName);
221+
}
222+
223+
late SfBarcodeGenerator _barcode;
224+
225+
@override
226+
Widget build(BuildContext context) {
227+
return MaterialApp(
228+
title: 'Flutter Demo',
229+
home: Scaffold(
230+
appBar: AppBar(
231+
title: const Text('Test Chart Widget'),
232+
),
233+
body: Center(
234+
child: Container(
235+
margin: EdgeInsets.zero,
236+
child: _barcode,
237+
))),
238+
);
239+
}
240+
}

0 commit comments

Comments
 (0)