Author: Nafiz

  • Flutter video player example

    Flutter video player example

    Very easy Flutter video player example, using chewie and and video_player library.

    The app plays video from a remote HTTP URL and it plays in portrait mode, when you exit the video player it maintains portrait mode on your device.

    pubspec.yaml

    name: video_player
    description: Flutter video player project.
    
    # The following line prevents the package from being accidentally published to
    # pub.dev using `pub publish`. This is preferred for private packages.
    publish_to: 'none' # Remove this line if you wish to publish to pub.dev
    
    # The following defines the version and build number for your application.
    # A version number is three numbers separated by dots, like 1.2.43
    # followed by an optional build number separated by a +.
    # Both the version and the builder number may be overridden in flutter
    # build by specifying --build-name and --build-number, respectively.
    # In Android, build-name is used as versionName while build-number used as versionCode.
    # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
    # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
    # Read more about iOS versioning at
    # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
    version: 1.0.0+1
    
    environment:
      sdk: ">=2.12.0 <3.0.0"
    
    dependencies:
      flutter:
        sdk: flutter
    
    
      # The following adds the Cupertino Icons font to your application.
      # Use with the CupertinoIcons class for iOS style icons.
      cupertino_icons: ^1.0.2
      video_player: ^2.1.14
      chewie: ^1.2.2
      
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
    
    # For information on the generic Dart part of this file, see the
    # following page: https://dart.dev/tools/pub/pubspec
    
    # The following section is specific to Flutter.
    flutter:
    
      # The following line ensures that the Material Icons font is
      # included with your application, so that you can use the icons in
      # the material Icons class.
      uses-material-design: true
    
      # To add assets to your application, add an assets section, like this:
      #assets:
      #   - images/a_dot_ham.jpeg
    
      # An image asset can refer to one or more resolution-specific "variants", see
      # https://flutter.dev/assets-and-images/#resolution-aware.
    
      # For details regarding adding assets from package dependencies, see
      # https://flutter.dev/assets-and-images/#from-packages
    
      # To add custom fonts to your application, add a fonts section here,
      # in this "flutter" section. Each entry in this list should have a
      # "family" key with the font family name, and a "fonts" key with a
      # list giving the asset and other descriptors for the font. For
      # example:
      # fonts:
      #   - family: Schyler
      #     fonts:
      #       - asset: fonts/Schyler-Regular.ttf
      #       - asset: fonts/Schyler-Italic.ttf
      #         style: italic
      #   - family: Trajan Pro
      #     fonts:
      #       - asset: fonts/TrajanPro.ttf
      #       - asset: fonts/TrajanPro_Bold.ttf
      #         weight: 700
      #
      # For details regarding fonts from package dependencies,
      # see https://flutter.dev/custom-fonts/#from-packages
    

    In your main function, make sure you run the app in portrait mode,

    void main() {
      WidgetsFlutterBinding.ensureInitialized();
    
      SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
          .then((_) {
        runApp(MyApp());
      });
    }

    main.dart

    import 'package:flutter/material.dart';
    import 'package:flutter/services.dart';
    import 'package:inspiration_show/pages/home.dart';
    
    void main() {
      WidgetsFlutterBinding.ensureInitialized();
    
      SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
          .then((_) {
        runApp(MyApp());
      });
    }
    
    class MyApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Video Player',
          theme: ThemeData(
            // This is the theme of your application.
            //
            // Try running your application with "flutter run". You'll see the
            // application has a blue toolbar. Then, without quitting the app, try
            // changing the primarySwatch below to Colors.green and then invoke
            // "hot reload" (press "r" in the console where you ran "flutter run",
            // or simply save your changes to "hot reload" in a Flutter IDE).
            // Notice that the counter didn't reset back to zero; the application
            // is not restarted.
            primarySwatch: Colors.red,
          ),
          home: MyHomePage(title: 'Video Player Demo Page'),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      MyHomePage({Key? key, required this.title}) : super(key: key);
    
      // This widget is the home page of your application. It is stateful, meaning
      // that it has a State object (defined below) that contains fields that affect
      // how it looks.
    
      // This class is the configuration for the state. It holds the values (in this
      // case the title) provided by the parent (in this case the App widget) and
      // used by the build method of the State. Fields in a Widget subclass are
      // always marked "final".
    
      final String title;
    
      @override
      _MyHomePageState createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      String appBarTitle = "Home";
    
      @override
      Widget build(BuildContext context) {
        // This method is rerun every time setState is called, for instance as done
        // by the _incrementCounter method above.
        //
        // The Flutter framework has been optimized to make rerunning build methods
        // fast, so that you can just rebuild anything that needs updating rather
        // than having to individually change instances of widgets.
        return Scaffold(
          appBar: AppBar(
            // Here we take the value from the MyHomePage object that was created by
            // the App.build method, and use it to set our appbar title.
            title: Text(appBarTitle),
          ),
          body: HomeWidget(),
        );
      }
    }
    

    home.dart

    import 'package:flutter/material.dart';
    import 'package:flutter/services.dart';
    import 'package:video_player/video_player.dart';
    import 'package:chewie/chewie.dart';
    
    class HomeWidget extends StatefulWidget {
      @override
      _VideoWidget createState() => _VideoWidget();
    }
    
    class _VideoWidget extends State<HomeWidget> {
      late VideoPlayerController videoPlayerController;
      late ChewieController chewieController;
    
      bool isReady = false;
    
      @override
      void initState() {
        super.initState();
        initializeVideoPlayer();
      }
    
      @override
      Widget build(BuildContext context) {
        return Container(
          margin: const EdgeInsets.all(16),
          child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
            Center(
              child: Container(
                height: 200,
                child: isReady == true
                    ? Chewie(controller: chewieController)
                    : Center(child: CircularProgressIndicator()),
              ),
            ),
          ]),
        );
      }
    
      @override
      void dispose() {
        super.dispose();
        videoPlayerController.dispose();
        chewieController.videoPlayerController.dispose();
    
        SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
      }
    
      Future<void> initializeVideoPlayer() async {
        videoPlayerController = VideoPlayerController.network(
            "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_1920_18MG.mp4");
        await Future.wait([videoPlayerController.initialize()]);
    
        chewieController = ChewieController(
            videoPlayerController: videoPlayerController,
            autoPlay: false,
            aspectRatio: 16 / 9,
            autoInitialize: true);
    
        setState(() {
          isReady = true;
        });
    
        chewieController.addListener(() {
          if (!chewieController.isFullScreen) {
            SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
          }
        });
      }
    }
    

    Download source code

    Spread the love
  • iOS-iPadOS app store submission checklist and how to

    iOS-iPadOS app store submission checklist and how to

    When you are ready to submit your app to App Store for TestFlight or App Store you want to make sure few things are available to you.

    1. First you need a developer account or an Apple ID which has privilege to developer resources ask your Team Admin for more help.
    2. There are two websites one https://developer.apple.com/account/ for creating app bundle, certificates and another one https://appstoreconnect.apple.com where you create your App and upload its assets and binary.
    3. After login to https://appstoreconnect.apple.com create an app first.

    In this step you need few more information.

    4. After creating the app you can now go to app detail page where you will add more information.

    Click on the left sidebar Prepare for Submission and add following information

    Version Information

    • Promotional Text
    • Description
    • Keywords 
    • Support URL
    • Marketing URL (Optional)

    General App Information

    • Version
    • Copyright

    App Review Information

    If your app needs username and password to access then you need to give working username and password here.

    5. Go to App Information under General. Here you can set your app Localizable Information, app category(primary and secondary), app content rights and age rating. Finally there is a license agreement, usually you don’t have to edit it.

    6. Click on the Pricing and Availability link and set your app’s pricing, if it is free then you don’t have to do anything. Here also you can choose which app store your app will be available, usually you don’t have to do anything here.

    7. Set your app privacy information from App Privacy

    These are the main things you need to get your app on the app store besides a well tested binary you develop on your Xcode.

    Spread the love
  • iOS-iPadOS app icon sizes with sketch file

    DeviceIcon Size
    App Icons
    iPhone60×60 pt
    20×120 px @2x
    180×180 px @3x
    iPad Pro83.5×83.5 pt
    167×167 px @2x
    iPad, iPad mini76×76 pt
    152×152 px @2x
    App Store1024×1024 pt (1024×1024 px @1x)
    Device Spotlight icon size
    iPhone40×40 pt (120×120 px @3x)
    40×40 pt (80×80 px @2x)
    iPad Pro, iPad, iPad mini 40×40 pt (80×80 px @2x)
    Device Settings icon size
    iPhone29×29 pt (87×87 px @3x)
    29×29 pt (58×58 px @2x)
    iPad Pro, iPad, iPad mini29×29 pt (58×58 px @2x)
    Device Notification icon size
    iPhone20×20 pt (60×60 px @3x)
    20×20 pt (40×40 px @2x)
    iPad Pro, iPad, iPad mini20×20 pt (40×40 px @2x)

    Download sketch file

    Spread the love