betto_recordset 0.1.0-dev.1
betto_recordset: ^0.1.0-dev.1 copied to clipboard
A pure-Dart package for managing tabular data as typed, validated sets of records.
// Copyright 2026 The Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import 'package:betto_recordset/betto_recordset.dart';
import 'package:collection/collection.dart';
void main() {
const csvData = [
'id,name,rating',
'1,Black Forest Cake,5.0',
'2,Trifle,3.5',
'3,Ice cream cake,2.0',
'4,Tiramisu,4.5',
'5,Chocolate cake,3.0,Very Dry',
'6,Fruit Pizza,0.5',
];
final rs = RecordSet(
header: RecordSetHeader.fromStrings(csvData[0].split(',')),
);
for (final row in csvData.slice(1)) {
rs.newRecord(row.split(','));
}
print('HTML: ');
final html = Renderer(formatHtml).render(rs);
print(html);
print('\n\nJSON: ');
final json = Renderer(formatJson).render(rs);
print(json);
print('\nText: ');
final text = Renderer(formatText).render(rs);
print(text);
}