Can you help solve this I have tried to put ! but no use
(snapShot.hasData && snapShot.data! < 10)? '${snapShot.data}' ??'' : 'Future in Flutter'),
(snapShot.hasData && snapShot!.data < 10)? '${snapShot.data}' ??'' : 'Future in Flutter'),
CodePudding user response:
Please try this:
(snapShot.data ?? 0) < 10
CodePudding user response:
Solved the problem
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
info(String a) {
return a;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: StreamBuilder<int>(
stream: Stream.periodic(Duration(seconds: 1) , (a)=> a) ,
builder: (context, snapShot) {
return Scaffold(
appBar: AppBar(
title: Text(
(snapShot.hasData && (snapShot.data ?? 0) < 10)? '${snapShot.data}' : 'Future in Flutter'),
),
body: Center(
child: snapShot.connectionState == ConnectionState.waiting
? const CircularProgressIndicator()
: const Text('Done!'),
),
);
},
),
);
}
}```