I don't understand why i got an error with quill.QuillToolbar.basic
This is what i have in my page, 3 tabs and each tab should display a richtextfield. I don't understand where the error comes from on line 134 (quill.QuillToolbar.basic) and also on line 147 (readOnly) in the widget _buildRichTextField(.........)
i'm using flutter_quill: ^11.2.0 and sdk: ^3.7.0
This is my code:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../services/info_service.dart';
import '../models/info.dart';
import 'package:flutter_quill/flutter_quill.dart' as quill;
class InfoPage extends StatefulWidget {
@override
_InfoPageState createState() => _InfoPageState();
}
class _InfoPageState extends State<InfoPage>
with SingleTickerProviderStateMixin {
late TabController _tabController;
final InfoService _infoService = InfoService();
Info? _info;
// Quill controllers
final quill.QuillController _appInfoController =
quill.QuillController.basic();
final quill.QuillController _privacyPolicyController =
quill.QuillController.basic();
final quill.QuillController _contactController =
quill.QuillController.basic();
@override
void initState() {
super.initState();
_tabController = TabController(length: 3, vsync: this);
_loadInfo();
}
Future<void> _loadInfo() async {
Info? info = await _infoService.getInfo();
if (info != null) {
setState(() {
_info = info;
_appInfoController.document = quill.Document()..insert(0, info.appInfo);
_privacyPolicyController.document =
quill.Document()..insert(0, info.privacyPolicy);
_contactController.document =
quill.Document()..insert(0, info.contactDetails);
});
}
}
Future<void> _saveInfo() async {
Info newInfo = Info(
id: "app_info",
appInfo: _appInfoController.document.toPlainText(),
privacyPolicy: _privacyPolicyController.document.toPlainText(),
contactDetails: _contactController.document.toPlainText(),
);
await _infoService.saveInfo(newInfo);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Center(
child: Text(
'Beheer Informatie',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
backgroundColor: Color.fromARGB(255, 48, 86, 147),
elevation: 4,
bottom: PreferredSize(
preferredSize: Size.fromHeight(65.0), // Adjust height as needed
child: Column(
children: [
Divider(
color: Colors.white,
thickness: 1.5,
height: 1, // Ensure the divider has no extra space
),
Container(
color: Colors.white.withAlpha(
50,
), // Transparent white background
child: TabBar(
controller: _tabController,
labelColor: Colors.white,
unselectedLabelColor: Colors.white70,
indicator: BoxDecoration(
color: Colors.white.withAlpha(
100,
), // Slightly darker for the selected tab
borderRadius: BorderRadius.circular(8),
),
indicatorSize: TabBarIndicatorSize.tab,
labelPadding: EdgeInsets.only(bottom: 8.0),
tabs: [
Tab(text: 'Info'),
Tab(text: 'Privacy'),
Tab(text: 'Contact'),
],
),
),
],
),
),
),
body: TabBarView(
controller: _tabController,
children: [
_buildRichTextField(_appInfoController, 'Informatie over de app'),
_buildRichTextField(_privacyPolicyController, 'Privacybeleid'),
_buildRichTextField(_contactController, 'Contactgegevens'),
],
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.green,
onPressed: () async {
await _saveInfo();
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text('Gegevens opgeslagen!')));
},
child: Icon(Icons.save, color: Colors.white),
),
);
}
Widget _buildRichTextField(quill.QuillController controller, String hint) {
return Column(
children: [
quill.QuillToolbar.basic(
controller: controller,
), // Corrected capitalization
Expanded(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
borderRadius: BorderRadius.circular(8),
),
child: quill.QuillEditor.basic(
controller: controller,
readOnly: false, // Editing enabled
),
),
),
),
],
);
}
}