From aa6364d9f8e747e97c87da62f18a6c632766efaa Mon Sep 17 00:00:00 2001 From: luismdsleite Date: Tue, 26 Apr 2022 22:41:34 +0100 Subject: [PATCH] Fixing Warnings: missing consts, unused imports --- flutter_prototype/lib/main.dart | 4 ++- .../lib/src/objects/chatmessage.dart | 2 -- .../lib/src/views/chatdetailpage.dart | 34 ++++++++++--------- .../lib/src/views/facility_view.dart | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/flutter_prototype/lib/main.dart b/flutter_prototype/lib/main.dart index 1d96ba2..c88509c 100644 --- a/flutter_prototype/lib/main.dart +++ b/flutter_prototype/lib/main.dart @@ -13,7 +13,7 @@ class MyApp extends StatelessWidget { return MaterialApp( title: 'FEUPQ', theme: ThemeData(primarySwatch: Colors.deepOrange), - home: LoginView(), + home: const HomeView(), ); } } @@ -70,6 +70,8 @@ class HomeView extends StatelessWidget { } class LoginView extends StatefulWidget { + const LoginView({Key? key}) : super(key: key); + @override LoginViewState createState() => LoginViewState(); } diff --git a/flutter_prototype/lib/src/objects/chatmessage.dart b/flutter_prototype/lib/src/objects/chatmessage.dart index 094f7a6..83e4bd4 100644 --- a/flutter_prototype/lib/src/objects/chatmessage.dart +++ b/flutter_prototype/lib/src/objects/chatmessage.dart @@ -1,5 +1,3 @@ -import 'package:flutter/cupertino.dart'; - class ChatMessage { String messageContent; String messageType; diff --git a/flutter_prototype/lib/src/views/chatdetailpage.dart b/flutter_prototype/lib/src/views/chatdetailpage.dart index 8032e9a..a0e8d2a 100644 --- a/flutter_prototype/lib/src/views/chatdetailpage.dart +++ b/flutter_prototype/lib/src/views/chatdetailpage.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_code/src/objects/chatmessage.dart'; class ChatDetailPage extends StatefulWidget { + const ChatDetailPage({Key? key}) : super(key: key); + @override _ChatDetailPageState createState() => _ChatDetailPageState(); } @@ -24,26 +26,26 @@ class _ChatDetailPageState extends State { backgroundColor: Colors.red, flexibleSpace: SafeArea( child: Container( - padding: EdgeInsets.only(right: 16), + padding: const EdgeInsets.only(right: 16), child: Row( children: [ IconButton( onPressed: () { Navigator.pop(context); }, - icon: Icon( + icon: const Icon( Icons.arrow_back, color: Colors.black, ), ), - SizedBox( + const SizedBox( width: 2, ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ Text( "Chat", style: TextStyle(height: 3, fontSize: 15), @@ -64,12 +66,12 @@ class _ChatDetailPageState extends State { ListView.builder( itemCount: messages.length, shrinkWrap: true, - padding: EdgeInsets.only(top: 10, bottom: 10), - physics: NeverScrollableScrollPhysics(), + padding: const EdgeInsets.only(top: 10, bottom: 10), + physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { return Container( - padding: - EdgeInsets.only(left: 16, right: 16, top: 10, bottom: 10), + padding: const EdgeInsets.only( + left: 16, right: 16, top: 10, bottom: 10), child: Align( alignment: (messages[index].messageType == "receiver" ? Alignment.topLeft @@ -81,10 +83,10 @@ class _ChatDetailPageState extends State { ? Colors.grey.shade200 : Colors.blue[200]), ), - padding: EdgeInsets.all(16), + padding: const EdgeInsets.all(16), child: Text( messages[index].messageContent, - style: TextStyle(fontSize: 15), + style: const TextStyle(fontSize: 15), ), ), ), @@ -94,7 +96,7 @@ class _ChatDetailPageState extends State { Align( alignment: Alignment.bottomLeft, child: Container( - padding: EdgeInsets.only(left: 10, bottom: 10, top: 10), + padding: const EdgeInsets.only(left: 10, bottom: 10, top: 10), height: 60, width: double.infinity, color: Colors.white, @@ -109,17 +111,17 @@ class _ChatDetailPageState extends State { color: Colors.lightBlue, borderRadius: BorderRadius.circular(30), ), - child: Icon( + child: const Icon( Icons.add, color: Colors.white, size: 20, ), ), ), - SizedBox( + const SizedBox( width: 15, ), - Expanded( + const Expanded( child: TextField( decoration: InputDecoration( hintText: "Write message...", @@ -127,12 +129,12 @@ class _ChatDetailPageState extends State { border: InputBorder.none), ), ), - SizedBox( + const SizedBox( width: 15, ), FloatingActionButton( onPressed: () {}, - child: Icon( + child: const Icon( Icons.send, color: Colors.white, size: 18, diff --git a/flutter_prototype/lib/src/views/facility_view.dart b/flutter_prototype/lib/src/views/facility_view.dart index 27ed353..ad056a8 100644 --- a/flutter_prototype/lib/src/views/facility_view.dart +++ b/flutter_prototype/lib/src/views/facility_view.dart @@ -92,7 +92,7 @@ class FacilityView extends StatelessWidget { onPressed: () { Navigator.push( context, - MaterialPageRoute(builder: (context) => ChatDetailPage()), + MaterialPageRoute(builder: (context) => const ChatDetailPage()), ); }, ),