Reputation: 33
I am referring to the graphite library of flutter to make flowcharts. When I run the example provided , I am able to see the output. But I don't know where to make the changes to change the flowchart as per my requirement. Can anyone please help me on how to modify the example code of graphite to make my own flowchart in flutter
graphite: https://github.com/lempiy/flutter_graphite
Want to make a flowchart something like this
Upvotes: 2
Views: 953
Reputation: 1857
Here is an example to use a graphite package:
The below code shows the connections according to your image.
import 'package:flutter/material.dart';
import 'package:graphite/core/matrix.dart';
import 'package:graphite/core/typings.dart';
import 'package:graphite/graphite.dart';
void main() => runApp(MyApp());
const reqBasic = '[{"id":"A","next":["B"]},{"id":"B","next":["C"]},{"id":"C","next":["D","E"]},{"id":"D","next":[]},{"id":"E","next":["F"]},{"id":"F","next":[]}]';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Graphite',
theme: ThemeData(
primarySwatch: Colors.teal,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
var list = nodeInputFromJson(reqBasic);
return Scaffold(
body: Center(
child: DirectGraph(
list: list,
cellWidth: 136.0,
cellPadding: 24.0,
orientation: MatrixOrientation.Horizontal,
),
),
);
}
}
Upvotes: 1