From c09dafa321a0929d75ada3947cd0e507c9ddee32 Mon Sep 17 00:00:00 2001 From: Nagaraj Alagusundaram Date: Wed, 3 Aug 2022 12:43:37 +1000 Subject: [PATCH] Updated the README example --- README.md | 72 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 1518bfa..b32192c 100644 --- a/README.md +++ b/README.md @@ -42,12 +42,20 @@ class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - primarySwatch: Colors.blue, + return InternetWidget( + offline: const Center(child: Text('No Internet')), + // ignore: avoid_print + whenOffline: () => print('No Internet'), + // ignore: avoid_print + whenOnline: () => print('Connected to internet'), + loadingWidget: const Center(child: Text('Loading')), + online: MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + home: const MyHomePage(title: 'Flutter Demo Home Page'), ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } @@ -72,31 +80,39 @@ class _MyHomePageState extends State { @override Widget build(BuildContext context) { return Center( - child: InternetWidget( - online: Scaffold( - appBar: AppBar( - title: Text(widget.title), - ), - body: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headline4, - ), - ], - ), - ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), + child: Scaffold( + appBar: AppBar( + title: Text(widget.title), + ), + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + Text( + '$_counter', + style: Theme.of(context).textTheme.headline4, + ), + ElevatedButton( + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const SecondScreen(), + ), + ); + }, + child: const Text('Navigate'), + ) + ], ), ), + floatingActionButton: FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), ), ); }