Problem integrating SpeedDialChild() into a Flutter_Webview app

31 Views Asked by At

I just started with flutter, it's only been a week. and I can't integrate SpeedDialChild() into a Flutter Webview app, I've already spent a whole day because of this bug, can you help me fix this problem and move forward? because I realize the power and complexity of flutter, and I would like to master this tool.

This is my "main.dart" file

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter/services.dart';
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

void main() {
  // for portrait only
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);

  runApp(const MaterialApp(
    debugShowCheckedModeBanner: false,
    home: Scaffold(

      body: SafeArea(
        child: WebView(
          initialUrl: "https://mydomaine.com/",
          javascriptMode: JavascriptMode.unrestricted,


        ),

      ),
      floatingActionButton: SpeedDial(
          animatedIcon: AnimatedIcons.menu_close,
          overlayColor: Colors.black,
          overlayOpacity: 0.4,
          spaceBetweenChildren: 12,
          closeManually: true,
          
          
          children: [
            // my mistake starts exactly here
            SpeedDialChild(
              child: Icon(FontAwesomeIcons.servicestack),
              label: 'Services',
            ),
            SpeedDialChild(
              child: Icon(FontAwesomeIcons.whatsapp),
              label: 'Contact Me',
            )

          ]

      )

    ),

  ));
}

 

in "pubspec.yaml" i use this dependencies



dependencies:
  flutter:
    sdk: flutter
  webview_flutter: ^2.0.9


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2

  # menu flotant
  flutter_speed_dial: ^4.3.0

  # Icon social
  font_awesome_flutter: ^10.5.0

  # les messages infos bulle
  fluttertoast: ^8.2.4

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: "^0.10.0"
  flutter_native_splash: ^2.2.11


flutter_native_splash:
  color : "#ffffff"
  image : "assets/icons/icon.png"
  android: true
  ios: true


flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/icons/icon.png"
  min_sdk_android: 21 # android min sdk min:16, default 21
  web:
    generate: true
    image_path: "assets/icons/icon.png"
    background_color: "#hexcode"
    theme_color: "#hexcode"
  windows:
    generate: true
    image_path: "assets/icons/icon.png"
    icon_size: 48 # min:48, max:256, default: 48

and finally when i run app, i have this error

Launching lib\main.dart on Infinix X693 in debug mode...
Running Gradle task 'assembleDebug'...
lib/main.dart:33:13: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
            SpeedDialChild(
            ^^^^^^^^^^^^^^
lib/main.dart:37:13: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
            SpeedDialChild(
            ^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\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 31s
Exception: Gradle task assembleDebug failed with exit code 1

0

There are 0 best solutions below