0

我是 Flutter 的初学者,我在我的应用程序中使用了 Flutter(空安全版本)carousel_slider 4.0.0,滑块工作,但是我想知道如何使用这个滑块加载本地图像。任何想法?

谢谢

import 'package:flutter/material.dart';

    import 'package:provider/provider.dart';
    import 'package:flutter_svg/svg.dart';
    import 'package:carousel_slider/carousel_slider.dart';
    import 'package:rmapp/provider/theme_provider.dart';
    
    class HomeScreen extends StatefulWidget {
      @override
      _HomeScreenState createState() => _HomeScreenState();
    }
    
    class _HomeScreenState extends State<HomeScreen> {
      //swiper current index
    
      late final List<String> imageList = [
        "https://www.setaswall.com/wp-content/uploads/2018/08/Spiderman-Wallpaper-76-1280x720.jpg",
        "https://lh3.googleusercontent.com/proxy/yL2FmQfZA79S5eIDza9MH2NjKGIKWPOGRHxHdYwiNPcYDW26YmK6qnP01ZDLsBENZpiADc1ohkj3LzVjrwoX8Pb-crT6MYZb3Jp9gy3ZrlET_yvoFS0qtUHLq4DtVPcqIdxPiNWI_j08omBVACv-YJc",
    
      ];
      @override
      Widget build(BuildContext context) {
        Provider.of<ThemeProvider>(context).themeMode == ThemeMode.dark
            ? 'DarkTheme'
            : 'LightTheme';
        return Scaffold(
          // Setting up AppBar
          appBar: AppBar(
            automaticallyImplyLeading: false,
            iconTheme: Theme.of(context).iconTheme,

          ),
    
          // Setting up Background Color
    
    
          // Body
          body: Container(
            child: ListView(
              physics: ClampingScrollPhysics(),
              children: <Widget>[
    
                Padding(
                  padding: EdgeInsets.only(left: 16, bottom: 10, top: 10,),
                  child: Text(
                    'Hi, Welcome back!',
                    //style: mTitleStyle,
                  ),
                ),
                //Promo Slider
                _promoSlider(),
    
              ],
            ),
          ),
        );
      }
    
    
      //Promo Slider
      Widget _promoSlider() {
        return Container(
   
                child: CarouselSlider(
                  options: CarouselOptions(
                    enlargeCenterPage: true,
                    enableInfiniteScroll: false,
                    autoPlay: true,
                  ),
                  items: imageList.map((e) => ClipRRect(
                    borderRadius: BorderRadius.circular(8),
                    child: Stack(
                      fit: StackFit.expand,
                      children: <Widget>[
                        Image.network(e,
                          width: 1050,
                          height: 350,
                          fit: BoxFit.cover,)
                      ],
                    ) ,
                  )).toList(),
                    ),);
    
      }
    
    }
4

0 回答 0