Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
.
  • Loading branch information
jaydipnasit-oceanmtech committed Jun 6, 2024
1 parent 7d4155e commit 6ac1d49
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions flutter_ffi_plugin/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:example_app/messages/counter_number.pb.dart';
import 'package:example_app/messages/fractal_art.pb.dart';

void main() async {
// Wait for Rust initialization to be completed first.
await initializeRust();
runApp(const MyApp());
}
Expand All @@ -20,7 +19,6 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
final _appLifecycleListener = AppLifecycleListener(
onExitRequested: () async {
// Terminate Rust tasks before closing the Flutter app.
await finalizeRust();
return AppExitResponse.exit;
},
Expand Down Expand Up @@ -56,8 +54,6 @@ class MyHomePage extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// `StreamBuilder` listens to a stream
// and rebuilds the widget accordingly.
StreamBuilder(
stream: SampleFractal.rustSignalStream,
builder: (context, snapshot) {
Expand Down Expand Up @@ -93,16 +89,11 @@ class MyHomePage extends StatelessWidget {
);
}),
StreamBuilder(
// This stream is generated from a marked Protobuf message.
stream: SampleNumberOutput.rustSignalStream,
builder: (context, snapshot) {
final rustSignal = snapshot.data;
// If the app has just started and widget is built
// without receiving a Rust signal,
// the snapshot data will be null.
// It's when the widget is being built for the first time.

if (rustSignal == null) {
// Return the initial widget if the snapshot data is null.
return Text('Initial value 0');
}
final sampleNumberOutput = rustSignal.message;
Expand All @@ -113,10 +104,8 @@ class MyHomePage extends StatelessWidget {
],
),
),
// This is a button that calls the generated function.
floatingActionButton: FloatingActionButton(
onPressed: () async {
// The method is generated from a marked Protobuf message.
SampleNumberInput(
letter: "HELLO FROM DART!",
dummyOne: 25,
Expand Down

0 comments on commit 6ac1d49

Please sign in to comment.