icalendar_parser 0.1.1+1 icalendar_parser: ^0.1.1+1 copied to clipboard
Package to parse iCalendar (.ics) files written in pure Dart.
import 'package:flutter/material.dart';
import 'package:icalendar_parser/icalendar_parser.dart';
import 'package:flutter/services.dart' show rootBundle;
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
padding: EdgeInsets.all(16),
child: FutureBuilder<String>(
future: rootBundle.loadString('assets/calendar.ics'),
builder: (_, snapshot) {
if (!snapshot.hasData)
return Center(child: CircularProgressIndicator());
final iCalendar = ICalendar.fromString(snapshot.data);
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("${iCalendar?.toString()}"),
],
);
},
),
),
);
}
}