code_preview 0.1.5 copy "code_preview: ^0.1.5" to clipboard
code_preview: ^0.1.5 copied to clipboard

flutter code preview

example/lib/main.dart

import 'package:code_preview/code_preview.dart';
import 'package:example/widgets/test_widget.dart';
import 'package:flutter/material.dart';

import 'widgets/one_widget.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: Center(
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Text('You have pushed the button this many times:'),
              Text('$_counter'),
              Container(
                margin: const EdgeInsets.all(30),
                child: CodePreview(
                  className: "OneWidget",
                  customBuilder: (Widget codeWidget, CustomParam? param) {
                    debugPrint(param?.parseParam['title'].toString());
                    debugPrint(param?.parseParam['content'].toString());
                    debugPrint(param?.parseParam['description'].toString());
                    return codeWidget;
                  },
                ),
              ),
            ],
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
7
likes
130
pub points
63%
popularity

Publisher

unverified uploader

flutter code preview

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on code_preview