View alertbox.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
showDialogBox() => showCupertinoDialog<String>( | |
context: context, | |
builder: (BuildContext context) => CupertinoAlertDialog( | |
title: const Text('No Connection'), | |
content: const Text('Please check your internet connectivity'), | |
actions: <Widget>[ | |
TextButton( | |
onPressed: () async { | |
Navigator.pop(context, 'Cancel'); | |
setState(() => isAlertSet = false); |
View homepage.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
late StreamSubscription subscription; | |
bool isDeviceConnected = false; | |
bool isAlertSet = false; | |
@override | |
void initState() { | |
getConnectivity(); | |
super.initState(); | |
} |
View ui.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: const Text('Connectivity Checker'), | |
), | |
body: Center( | |
child: ElevatedButton( | |
onPressed: () => Navigator.push( | |
context, |
View home_page_ui_2.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body: Center( | |
child: ElevatedButton( | |
onPressed: () async { | |
await homePageData.saveJsonData(rawData); | |
homePageData.getJsonData(); | |
}, | |
child: const Text('Save Data'), | |
), | |
), |
View raw_data.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final rawData = <String, dynamic>{'name': 'Alice', 'age': 20}; | |
final defaultData = <String, dynamic>{ | |
'name': 'name not found.', | |
'age': 00, | |
}; |
View home_page_model.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomePageModel { | |
final String name; | |
final int? age; | |
HomePageModel( | |
this.name, | |
this.age, | |
); | |
View home_page_ui.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: ElevatedButton( | |
onPressed: () {}, | |
child: const Text('Save Data'), |
View function.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Future<void> _changeOpacity() async { | |
setState(() => _visible = !_visible); | |
await Future.delayed(const Duration(milliseconds: 650)); | |
setState(() => showPayBtn = !showPayBtn); | |
setState(() => _visible = !_visible); | |
} |
View animated_opacity.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AnimatedOpacity( | |
opacity: _visible ? 1.0 : 0.0, | |
duration: const Duration(milliseconds: 650), | |
child: ElevatedButton( | |
... | |
), | |
), |
NewerOlder