You can copy paste run full code below
Step 1: In initState, listen open/close
@override
void initState() {
slimyCard.stream.listen((value) {
if (value) {
handleFuture();
}
});
Step 2: Use ValueNotifier and ValueListenableBuilder to build bottomCardWidget
final ValueNotifier<String> _notify = ValueNotifier<String>("");
void handleFuture() async {
String text = await _getfromlist(1);
_notify.value = text;
}
...
Widget bottomCardWidget() {
return ValueListenableBuilder(
valueListenable: _notify,
builder: (BuildContext context, String value, Widget child) {
return Text(
value,
style: TextStyle(
color: Colors.white,
fontSize: 19,
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
);
});
}
working demo

full code
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:slimy_card/slimy_card.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
//Don't worry about these codes here, as they are not relevant for this example.
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark,
systemNavigationBarColor: Colors.white,
systemNavigationBarIconBrightness: Brightness.dark,
systemNavigationBarDividerColor: Colors.transparent,
));
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
scaffoldBackgroundColor: Colors.white,
fontFamily: 'Poppins',
),
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
final ValueNotifier<String> _notify = ValueNotifier<String>("");
void handleFuture() async {
String text = await _getfromlist(1);
_notify.value = text;
}
@override
void initState() {
slimyCard.stream.listen((value) {
if (value) {
handleFuture();
}
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: StreamBuilder(
// This streamBuilder reads the real-time status of SlimyCard.
initialData: false,
stream: slimyCard.stream, //Stream of SlimyCard
builder: ((BuildContext context, AsyncSnapshot snapshot) {
return ListView(
padding: EdgeInsets.zero,
children: <Widget>[
SizedBox(height: 100),
SlimyCard(
// In topCardWidget below, imagePath changes according to the
// status of the SlimyCard(snapshot.data).
topCardWidget: topCardWidget((snapshot.data)
? 'https://picsum.photos/250?image=9'
: 'https://picsum.photos/250?image=15'),
bottomCardWidget: bottomCardWidget(),
)
],
);
}),
),
);
}
// This widget will be passed as Top Card's Widget.
Widget topCardWidget(String imagePath) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
height: 70,
width: 70,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15),
image: DecorationImage(image: NetworkImage(imagePath)),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 20,
spreadRadius: 1,
),
],
),
),
SizedBox(height: 15),
Text(
'The Rock',
style: TextStyle(color: Colors.white, fontSize: 20),
),
SizedBox(height: 15),
Text(
'He asks, what your name is. But!',
style: TextStyle(
color: Colors.white.withOpacity(0.8),
fontSize: 12,
fontWeight: FontWeight.w500),
),
SizedBox(height: 10),
],
);
}
// This widget will be passed as Bottom Card's Widget.
Widget bottomCardWidget() {
return ValueListenableBuilder(
valueListenable: _notify,
builder: (BuildContext context, String value, Widget child) {
return Text(
value,
style: TextStyle(
color: Colors.white,
fontSize: 19,
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
);
});
}
// _getfromlist func
Future<String> _getfromlist(int type) async {
final getter = Random().nextInt(100);
//var setter = myList[type][getter];
var text = '$getter';
return Future.value(text);
}
}