how to add boxshadow only at the top side in flutter
I wanted to add shadow to a box inside BoxDecoration
only on top side. Is it possible in flutter ? This is my approach so far but not getting the desired results. Thanks in advannce.
class SectionHeaderDelegate extends SliverPersistentHeaderDelegate {
final String title;
final double height;
SectionHeaderDelegate(this.title, [this.height = 50]);
@override
Widget build(context, double shrinkOffset, bool overlapsContent) {
return Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 5 * SizeConfig.widthMultiplier),
decoration: BoxDecoration(
color: AppColors.colorWhite,
borderRadius: BorderRadius.only(
topRight: Radius.circular(30), topLeft: Radius.circular(30)),
boxShadow: <BoxShadow>[
BoxShadow(
color: AppColors.colorLightGrey,
blurRadius: 20.0,
offset: Offset(0.0, 1.0))
],
),
child: Text(title, style: AppStyles.complaints),
);
}
@override
double get maxExtent => height;
@override
double get minExtent => height;
@override
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) => false;
}```
See also questions close to this topic
-
fluttter: permission pop up not seen on release mode with package permission_handler: ^5.0.1+1
permission pop up not seen on release mode with package permission_handler: ^5.0.1+1 with flutter version Flutter 1.22.5 • channel stable
-
Is there a way or it is necessary to close/dispose a StreamProvider from the Provider package?
I don't know if there's a way to manually close/dispose of a StreamProvider that I am using from the Provider package. I am afraid that using multiple stream providers simultaneously when using my app can possibly open for some memory leak issues? resulting in a bad app performance?
Since I can't find an answer from the web or from the docs itself, May I ask if the StreamProvider automatically closed/disposed of in the background whenever I leave the current page it was used? and then just re-open when I go back again? or any idea how it works and handles streams of data? Thanks.
- What is this extra space above my appbar?
-
im doing this for hours its a flutter code anyone
'''. ../../flutter_windows_1.22.4-stable/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:88:26: Error: Type 'DiagnosticableMixin' not found. class PictureStream with DiagnosticableMixin { ^^^^^^^^^^^^^^^^^^^ ../../flutter_windows_1.22.4-stable/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:192:44: Error: Type 'DiagnosticableMixin' not found. abstract class PictureStreamCompleter with DiagnosticableMixin { ^^^^^^^^^^^^^^^^^^^ ../../flutter_windows_1.22.4-stable/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:88:7: Error: The type 'DiagnosticableMixin' can't be mixed in. class PictureStream with DiagnosticableMixin { ^ ../../flutter_windows_1.22.4-stable/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:192:16: Error: The type 'DiagnosticableMixin' can't be mixed in. abstract class PictureStreamCompleter with DiagnosticableMixin { ^
../../flutter_windows_1.22.4-stable/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:167:11: Error: Superclass has no method named 'debugFillProperties'. super.debugFillProperties(properties); ^^^^^^^^^^^^^^^^^^^ ../../flutter_windows_1.22.4-stable/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:171:30: Error: The method 'toStringShort' isn't defined for the class 'PictureStreamCompleter'.
'PictureStreamCompleter' is from 'package:flutter_svg/src/picture_stream.dart' ('../../flutter_windows_1.22.4-stable/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart'). Try correcting the name to the name of an existing method, or defining a method named 'toStringShort'.
ifPresent: _completer?.toStringShort(), ^^^^^^^^^^^^^ ../../flutter_windows_1.22.4-stable/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:266:11: Error: Superclass has no method named 'debugFillProperties'. super.debugFillProperties(description); ^^^^^^^^^^^^^^^^^^^
2
FAILURE: Build failed with an exception.
Where: Script 'C:\Users\tejes\Downloads\flutter_windows_1.22.4-stable\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 904
What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\Users\tejes\Downloads\flutter_windows_1.22.4-stable\flutter\bin\flutter.bat'' finished with non-zero exit value 1
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 2m 37s Exception: Gradle task assembleDebug failed with exit code 1 Exited (sigterm)
'''
-
How to Callback from Swift Framework to Flutter project?
I have the framework written in Swift 5 language and now i need to integrate that framework into the new flutter project and there is more number of callbacks to notify from Swift Framework to Flutter project. In that I don't know how to do that, what is the way to callback/delegate to the flutter project from Swift Framework.
-
sqljocky5 connectionPool not importing
I am trying to implement a very simple DB query select statement using dart and sqljocky5 library, but ConnectionPool is not importing when I already install dependencies and add relevant import statements
import 'dart:io'; import 'package:sqljocky5/sqljocky.dart'; import 'package:sqljocky5/constants.dart'; import 'dart:async'; void main(List<String> arguments) async { var pool = new ConnectionPool( host: 'localhost', port: 3306, user: 'manoj', password: 'admin', db: 'school', max: 5); var results = await pool.query('select * from teachers'); print('Results ${await results.length} rows'); pool.closeConnectionsNow(); exit(0); }
my pubspec.yml file
name: hello description: A sample command-line application. # version: 1.0.0 # homepage: https://www.example.com environment: sdk: '>=2.10.0 <3.0.0' dependencies: http: ^0.12.2 path: ^1.7.0 archive: ^2.0.13 pointycastle: ^2.0.0 sqljocky5: ^2.2.1 dev_dependencies: pedantic: ^1.9.0 test: ^1.14.4
what are posible reason and how to resolve this?
- android studio can't find the flutter sdk saying flutter sdk path not given i have gave the path what is the soultion?
-
Flutter Center Widget in CustomScrollView
How do I center an element in custom child scrollview silverlist?
return CustomScrollView( physics: BouncingScrollPhysics(), slivers: <Widget>[ SliverList( delegate: SliverChildListDelegate([ SizedBox(height: widget.height), HeaderTitle("Hello there"), (data.length == 0) ? Center( child: Container( // padding: EdgeInsets.fromLTRB(0, 150, 0, 0), child: Column( children: [ Text("No Data Yet"), OutlineButton( onPressed: () { Navigator.of(context).pop(); }, textColor: Colors.black, child: Text("Do Something"), ), ], ), ), ) : Container() ])), SliverGrid( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( childAspectRatio: 10.0 / 10.0, crossAxisCount: 2, ), delegate: SliverChildBuilderDelegate((BuildContext context, int index) { return CastCard(data[index], null); }, childCount: data.length), ), ], );
I have tried to wrap with Center and Column with center property but the text No Date yet is not positioned in the cetner of the screen (with the remaining space available)
-
How do I get rid of "Incorrect use of ParentDataWidget" error?
I can't avoid the "Incorrect use of ParentDataWidget" error. The code below works - I want to be able to drop a draggable widget onto a dragTarget in the bottomSheet, but also want the widget to be draggable in the body.
The code works fine in the emulator, but when the draggable is accepted on the dragTarget, the error is flagged up in the console.
Is there something obvious that I'm doing wrong?
void main() => runApp(MyApp()); bool isAccepted = false; DragMe niceBox = new DragMe('Hello', 50.0, 100.0, Colors.green); DragMe nastyBox = new DragMe('Yucky', 150.0, 100.0, Colors.brown[300]); TargetBox targetBox = new TargetBox(); MyDragTarget myDragTarget = new MyDragTarget(); const kTopSpace = 96; // Height of Appbar plus the icon bar above class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData( fontFamily: 'PressStart'), home: MyHomeScreen(), ); } } class MyHomeScreen extends StatefulWidget { MyHomeScreen({Key key}) : super(key: key); createState() => MyHomeScreenState(); } class MyHomeScreenState extends State<MyHomeScreen> { @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.red[100], appBar: AppBar( toolbarHeight: 70.0, title: Center(child: Text('My brain hurts')), backgroundColor: Colors.pink, ), body: Stack(children: [niceBox, nastyBox]), bottomSheet: Container( color: Colors.lightBlue, height: 100.0, child: Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: [myDragTarget], ), ), ); } // End build() } // End class MyHomeScreenState class DragMe extends StatefulWidget { DragMe(this.myText, this.xPos, this.yPos, this.myColor); final String myText; double xPos; double yPos; final Color myColor; @override _DragMeState createState() => _DragMeState(); } class _DragMeState extends State<DragMe> { @override Widget build(BuildContext context) { return Positioned( left: widget.xPos, top: widget.yPos, // left: widget.xPos, // top: widget.yPos, child: Draggable( data: widget.myText, feedback: Container(height: 50, width: 70, color: Colors.grey), childWhenDragging: Container(), onDragStarted: () {}, onDragEnd: (details) { setState(() { widget.xPos = details.offset.dx; widget.yPos = details.offset.dy - kTopSpace; }); }, onDragCompleted: () {}, onDraggableCanceled: (velocity, offset) {}, child: Container( child: Center(child: Text(widget.myText)), color: widget.myColor, height: 50, width: 70, ), ), ); } } class MyDragTarget extends StatelessWidget { @override Widget build(BuildContext context) { return DragTarget<String>( builder: (context, List<String> acceptedData, rejectedData) { if (isAccepted) { return niceBox; } else { return targetBox; } }, onWillAccept: (data) { if (data == 'Hello') { isAccepted = true; return true; } else { isAccepted = false; return false; } }, onAccept: (strData) {}, onLeave: (strData) { return true; }, onMove: (moveData) { return true; }, onAcceptWithDetails: (data) {}, ); } } class TargetBox extends StatelessWidget { @override Widget build(BuildContext context) { return Container( child: Center(child: Text('Drop Here')), color: Colors.yellow, height: 50.0, width: 100.0); } }
-
How to convert curl to HTTP to fetch data in Dart
I've been trying to use Watson REST API , but I don't know to use that curl command in dart language.
curl -u "apikey:{apikey}" "{url}/v3/classify?url=https://watson-developer-cloud.github.io/doc-tutorial-downloads/visual-recognition/fruitbowl.jpg&version=2018-03-19"
Please help me to convert it into a http.post() request in dart , or is there any other solution to implement this.
-
FlutterFirebaseCorePlugin.java uses or overrides a deprecated API
Ok so I run my program without importing firebase core, firebase auth and cloud firestore, and my code runs just fine but I register my app with firebase and it still runs fine but as soon as I import
Firebase_auth
,Firebase_core
andcloud_Firestore
... I get the following errorNote: C:\appflutter\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.7.0\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: C:\appflutter\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.16.0\android\src\main\java\io\flutter\plugins\firebase\firestore\streamhandler\TransactionStreamHandler.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. D8: Cannot fit requested classes in a single dex file (# methods: 89543 > 65536) com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: The number of method references in a .dex file cannot exceed 64K.
Please help me.