From 876ff515a74b11aada7ae0d412cbd0558928390d Mon Sep 17 00:00:00 2001 From: Ajay Kumar Date: Tue, 20 Dec 2022 15:59:25 +0530 Subject: [PATCH] Dart analysis --- .flutter-plugins-dependencies | 2 +- dry_run.sh | 14 +++++ example/.flutter-plugins-dependencies | 2 +- example/lib/main.dart | 6 +- .../screens/custom_offline_widget_screen.dart | 42 +++++++------ example/lib/screens/menu_screen.dart | 28 +++++---- .../screens/network_aware_widget_screen.dart | 24 ++++---- .../lib/screens/scaffold_example_screen.dart | 61 ++++++++++--------- example/lib/utils/ui_helper.dart | 4 +- example/lib/utils/utils.dart | 10 +-- example/test/widget_test.dart | 5 +- publish.sh | 13 ++++ 12 files changed, 126 insertions(+), 85 deletions(-) create mode 100755 dry_run.sh create mode 100755 publish.sh diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index c140c0b..f480196 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":[]}],"date_created":"2022-12-20 15:49:52.195478","version":"3.3.7"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":[]}],"date_created":"2022-12-20 15:53:54.182602","version":"3.3.7"} \ No newline at end of file diff --git a/dry_run.sh b/dry_run.sh new file mode 100755 index 0000000..68b8fea --- /dev/null +++ b/dry_run.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +START=$(date +%s) +flutter clean +flutter pub get +flutter test +if [[ $? == 0 ]]; then + flutter pub publish --dry-run +else + echo "FLUTTER TEST FAILED" +fi +END=$(date +%s) +DIFF=$(echo "$END - $START" | bc) +echo "It took $DIFF seconds" \ No newline at end of file diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 54b254a..b9f4850 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":[]}],"date_created":"2022-12-20 15:49:52.469159","version":"3.3.7"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus","path":"/Users/ajaykumar/SDK/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-3.0.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":[]}],"date_created":"2022-12-20 15:53:53.377289","version":"3.3.7"} \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 5674c94..41f35db 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -2,9 +2,11 @@ import 'package:connectivity_wrapper/connectivity_wrapper.dart'; import 'package:connectivity_wrapper_example/screens/menu_screen.dart'; import 'package:flutter/material.dart'; -void main() => runApp(MyApp()); +void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { + const MyApp({Key key}) : super(key: key); + @override Widget build(BuildContext context) { return ConnectivityAppWrapper( @@ -16,9 +18,9 @@ class MyApp extends StatelessWidget { home: MenuScreen(), builder: (buildContext, widget) { return ConnectivityWidgetWrapper( - child: widget, disableInteraction: true, height: 80, + child: widget, ); }, ), diff --git a/example/lib/screens/custom_offline_widget_screen.dart b/example/lib/screens/custom_offline_widget_screen.dart index cc08ef3..dc4a9cc 100644 --- a/example/lib/screens/custom_offline_widget_screen.dart +++ b/example/lib/screens/custom_offline_widget_screen.dart @@ -4,15 +4,17 @@ import 'package:connectivity_wrapper_example/utils/ui_helper.dart'; import 'package:flutter/material.dart'; class CustomOfflineWidgetScreen extends StatelessWidget { + const CustomOfflineWidgetScreen({Key key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(Strings.example2), + title: const Text(Strings.example2), ), body: ConnectivityWidgetWrapper( disableInteraction: true, - offlineWidget: OfflineWidget(), + offlineWidget: const OfflineWidget(), child: ListView.builder( itemBuilder: (BuildContext context, int index) { return ListTile( @@ -26,27 +28,27 @@ class CustomOfflineWidgetScreen extends StatelessWidget { } class OfflineWidget extends StatelessWidget { + const OfflineWidget({Key key}) : super(key: key); + @override Widget build(BuildContext context) { - return Container( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Image( - height: 300, - image: AssetImage('assets/dog.gif'), - ), - PA5(), - Center( - child: Text( - Strings.offlineMessage, - style: TextStyle(color: Colors.white, fontSize: 30.0), - ), + return Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: const [ + Image( + height: 300, + image: AssetImage('assets/dog.gif'), + ), + PA5(), + Center( + child: Text( + Strings.offlineMessage, + style: TextStyle(color: Colors.white, fontSize: 30.0), ), - PA5(), - ], - ), + ), + PA5(), + ], ); } } diff --git a/example/lib/screens/menu_screen.dart b/example/lib/screens/menu_screen.dart index 52c515a..4883b63 100644 --- a/example/lib/screens/menu_screen.dart +++ b/example/lib/screens/menu_screen.dart @@ -8,14 +8,16 @@ import 'custom_offline_widget_screen.dart'; import 'network_aware_widget_screen.dart'; class MenuScreen extends StatelessWidget { - final GlobalKey _scaffoldKey = new GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); + + MenuScreen({Key key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( key: _scaffoldKey, appBar: AppBar( - title: Text("Connectivity Wrapper Example"), + title: const Text("Connectivity Wrapper Example"), ), body: ConnectivityScreenWrapper( disableInteraction: false, @@ -25,28 +27,28 @@ class MenuScreen extends StatelessWidget { child: ListView( children: [ ListTile( - title: Text(Strings.example1), + title: const Text(Strings.example1), onTap: () async { - AppRoutes.push(context, ScaffoldExampleScreen()); + AppRoutes.push(context, const ScaffoldExampleScreen()); }, ), - Divider(), + const Divider(), ListTile( - title: Text(Strings.example2), + title: const Text(Strings.example2), onTap: () { - AppRoutes.push(context, CustomOfflineWidgetScreen()); + AppRoutes.push(context, const CustomOfflineWidgetScreen()); }, ), - Divider(), + const Divider(), ListTile( - title: Text(Strings.example3), + title: const Text(Strings.example3), onTap: () { - AppRoutes.push(context, NetworkAwareWidgetScreen()); + AppRoutes.push(context, const NetworkAwareWidgetScreen()); }, ), - Divider(), + const Divider(), ListTile( - title: Text(Strings.example4), + title: const Text(Strings.example4), onTap: () async { if (await ConnectivityWrapper.instance.isConnected) { showSnackBar( @@ -62,7 +64,7 @@ class MenuScreen extends StatelessWidget { } }, ), - Divider(), + const Divider(), ], ), ), diff --git a/example/lib/screens/network_aware_widget_screen.dart b/example/lib/screens/network_aware_widget_screen.dart index becabc8..e539462 100644 --- a/example/lib/screens/network_aware_widget_screen.dart +++ b/example/lib/screens/network_aware_widget_screen.dart @@ -5,23 +5,25 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class NetworkAwareWidgetScreen extends StatelessWidget { + const NetworkAwareWidgetScreen({Key key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(Strings.example3), + title: const Text(Strings.example3), ), body: ListView( - padding: EdgeInsets.all(20.0), + padding: const EdgeInsets.all(20.0), children: [ - TextField( + const TextField( decoration: InputDecoration(labelText: 'Email'), ), - PA5(), - TextField( + const PA5(), + const TextField( decoration: InputDecoration(labelText: 'Password'), ), - PA5(), + const PA5(), ConnectivityWidgetWrapper( stacked: false, offlineWidget: ElevatedButton( @@ -33,7 +35,7 @@ class NetworkAwareWidgetScreen extends StatelessWidget { padding: const EdgeInsets.all(8.0), child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ Text( "Connecting", style: TextStyle( @@ -48,15 +50,15 @@ class NetworkAwareWidgetScreen extends StatelessWidget { ), child: ElevatedButton( onPressed: () {}, - child: Text( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.all(Colors.blue), + ), + child: const Text( "Sign In", style: TextStyle( color: Colors.white, ), ), - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all(Colors.blue), - ), ), ), ], diff --git a/example/lib/screens/scaffold_example_screen.dart b/example/lib/screens/scaffold_example_screen.dart index a1bcf15..65083a6 100644 --- a/example/lib/screens/scaffold_example_screen.dart +++ b/example/lib/screens/scaffold_example_screen.dart @@ -4,8 +4,10 @@ import 'package:connectivity_wrapper_example/utils/ui_helper.dart'; import 'package:flutter/material.dart'; class ScaffoldExampleScreen extends StatefulWidget { + const ScaffoldExampleScreen({Key key}) : super(key: key); + @override - _ScaffoldExampleScreenState createState() => _ScaffoldExampleScreenState(); + State createState() => _ScaffoldExampleScreenState(); } class _ScaffoldExampleScreenState extends State { @@ -24,7 +26,7 @@ class _ScaffoldExampleScreenState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(Strings.example1), + title: const Text(Strings.example1), ), body: ConnectivityWidgetWrapper( alignment: _alignment, @@ -33,7 +35,7 @@ class _ScaffoldExampleScreenState extends State { height: _height, message: _message, messageStyle: _customMessage - ? TextStyle( + ? const TextStyle( color: Colors.white, fontSize: 40.0, ) @@ -41,16 +43,19 @@ class _ScaffoldExampleScreenState extends State { child: ListView( children: [ CheckboxListTile( - title: Text(Strings.customDecoration), + title: const Text(Strings.customDecoration), value: _customDecoration, onChanged: (value) { setState(() { _customDecoration = value; if (_customDecoration) { - _decoration = BoxDecoration( + _decoration = const BoxDecoration( color: Colors.purple, - gradient: new LinearGradient( - colors: [Colors.red, Colors.cyan], + gradient: LinearGradient( + colors: [ + Colors.red, + Colors.cyan, + ], ), ); } else { @@ -59,10 +64,10 @@ class _ScaffoldExampleScreenState extends State { }); }, ), - Divider(), - PA5(), + const Divider(), + const PA5(), CheckboxListTile( - title: Text(Strings.customHeight), + title: const Text(Strings.customHeight), value: _customHeight, onChanged: (value) { setState(() { @@ -75,10 +80,10 @@ class _ScaffoldExampleScreenState extends State { }); }, ), - Divider(), - PA5(), + const Divider(), + const PA5(), CheckboxListTile( - title: Text(Strings.customMessage), + title: const Text(Strings.customMessage), value: _customMessage, onChanged: (value) { setState(() { @@ -91,44 +96,44 @@ class _ScaffoldExampleScreenState extends State { }); }, ), - Divider(), - PA5(), - ListTile( + const Divider(), + const PA5(), + const ListTile( title: Text(Strings.customAlignment), ), - PA5(), + const PA5(), IconButton( - icon: Icon(Icons.arrow_upward), + icon: const Icon(Icons.arrow_upward), onPressed: () { setState(() { _alignment = Alignment.topCenter; }); }, ), - Divider(), - PA5(), + const Divider(), + const PA5(), IconButton( - icon: Icon(Icons.center_focus_strong), + icon: const Icon(Icons.center_focus_strong), onPressed: () { setState(() { _alignment = Alignment.center; }); }, ), - Divider(), - PA5(), + const Divider(), + const PA5(), IconButton( - icon: Icon(Icons.arrow_downward), + icon: const Icon(Icons.arrow_downward), onPressed: () { setState(() { _alignment = Alignment.bottomCenter; }); }, ), - Divider(), - PA5(), + const Divider(), + const PA5(), CheckboxListTile( - title: Text(Strings.userInteraction), + title: const Text(Strings.userInteraction), value: _disableInteraction, onChanged: (value) { setState(() { @@ -136,7 +141,7 @@ class _ScaffoldExampleScreenState extends State { }); }, ), - PA5(), + const PA5(), ], ), ), diff --git a/example/lib/utils/ui_helper.dart b/example/lib/utils/ui_helper.dart index c92f74d..e859f76 100644 --- a/example/lib/utils/ui_helper.dart +++ b/example/lib/utils/ui_helper.dart @@ -1,8 +1,10 @@ import 'package:flutter/material.dart'; class PA5 extends StatelessWidget { + const PA5({Key key}) : super(key: key); + @override Widget build(BuildContext context) { - return Padding(padding: EdgeInsets.all(5.0)); + return const Padding(padding: EdgeInsets.all(5.0)); } } diff --git a/example/lib/utils/utils.dart b/example/lib/utils/utils.dart index 9b04297..c62848d 100644 --- a/example/lib/utils/utils.dart +++ b/example/lib/utils/utils.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; class AppRoutes { static void push(BuildContext context, Widget page) { Navigator.of(context).push( - new MaterialPageRoute(builder: (context) => page), + MaterialPageRoute(builder: (context) => page), ); } } @@ -16,20 +16,20 @@ showSnackBar( TextStyle style, }) { ScaffoldMessenger.of(context).showSnackBar( - new SnackBar( + SnackBar( backgroundColor: color ?? Colors.red, duration: Duration(milliseconds: milliseconds), content: Container( - constraints: BoxConstraints(minHeight: 50), + constraints: const BoxConstraints(minHeight: 50), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - new Text( + Text( title, style: style ?? - TextStyle( + const TextStyle( fontSize: 15.0, color: Colors.white, inherit: false, diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 419ecae..3672e49 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -5,15 +5,14 @@ // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. +import 'package:connectivity_wrapper_example/main.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:connectivity_wrapper_example/main.dart'; - void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); + await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); diff --git a/publish.sh b/publish.sh new file mode 100755 index 0000000..00b4b33 --- /dev/null +++ b/publish.sh @@ -0,0 +1,13 @@ +#!/bin/bash +START=$(date +%s) +flutter clean +flutter pub get +flutter test +if [[ $? == 0 ]]; then + flutter pub publish +else + echo "FLUTTER TEST FAILED" +fi +END=$(date +%s) +DIFF=$(echo "$END - $START" | bc) +echo "It took $DIFF seconds"