Search code examples
fluttersummernote

how to scroll in summernote flutter


I'm using the summernote text editor but I don't know how to scroll in the summernote text editor. This is my code:

FlutterSummernote(
  widthImage: '40%',
  hasAttachment: true,
  hint: "Your text here...",
  key: _keyWhatToDo,
  height: 450,
  customToolbar: """
    [
      ['style', ['bold', 'italic', 'underline']],
      ['font', ['strikethrough']],
      ['fontsize', ['fontsize']],
      ['color', ['color']],
      ['para', ['ul', 'ol', 'paragraph']],
    ]"""
),

please let me know if anything wrong or give me some advice.


Solution

  • Updated: As you requested, FlutterSummernote combined with SingleChildScrollView.

    It's working as expected. I don't know which issue you've been facing. Try to write the below-mentioned code into your main.dart file & check the result.

    import "package:flutter/material.dart";
    import "package:flutter_summernote/flutter_summernote.dart";
    
    void main() {
      WidgetsFlutterBinding.ensureInitialized();
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: "Flutter Demo",
          theme: ThemeData(
            colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
            useMaterial3: true,
          ),
          home: const MyHomePage(),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      const MyHomePage({super.key});
    
      @override
      State<MyHomePage> createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      final GlobalKey<FlutterSummernoteState> _keyWhatToDo = GlobalKey();
    
      @override
      void initState() {
        super.initState();
      }
    
      @override
      void dispose() {
        _keyWhatToDo.currentState?.dispose();
        super.dispose();
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: SafeArea(
            child: SingleChildScrollView(
              child: Column(
                children: <Widget>[
                  Container(height: 200, color: Colors.blue),
                  Container(height: 200, color: Colors.pink),
                  FlutterSummernote(
                    widthImage: "40%",
                    hasAttachment: true,
                    hint: "Your text here...",
                    key: _keyWhatToDo,
                    height: 450,
                    customToolbar: """
                  [
                    ['style', ['bold', 'italic', 'underline']],
                    ['font', ['strikethrough']],
                    ['fontsize', ['fontsize']],
                    ['color', ['color']],
                    ['para', ['ul', 'ol', 'paragraph']],
                  ]""",
                  ),
                  Container(height: 200, color: Colors.orange),
                  Container(height: 200, color: Colors.green),
                ],
              ),
            ),
          ),
        );
      }
    }